0% found this document useful (0 votes)
10 views1 page

Python Dict

The document contains a Python dictionary with data related to drivers, including their positions, car indices, lap percentages, and session times. A loop iterates through the data to print each driver's information, but it notes that session times should vary per driver based on lap percentages. The output shows driver positions and lap percentages, but all session times are incorrectly set to the same value.

Uploaded by

ftm2quick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Python Dict

The document contains a Python dictionary with data related to drivers, including their positions, car indices, lap percentages, and session times. A loop iterates through the data to print each driver's information, but it notes that session times should vary per driver based on lap percentages. The output shows driver positions and lap percentages, but all session times are incorrectly set to the same value.

Uploaded by

ftm2quick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

int_dict = {

"pos": ["1", "2", "3"],


"caridx": ["1", "4", "8"],
"lap_pct": ["0.50", "0.25", "0.13"],
"session_time": ["400", "400", "400"]
}

#displays entire dictionary


#print(int_dict)

#access the values based on length in order


#print(int_dict["caridx"][0])

#gives count of how many caridx's are in the server


#print(len(int_dict["caridx"]))

#for i in range(len(int_dict["caridx"])):

for i in range(len(int_dict["caridx"])):
# Access each dictionary in the list
pos_list = int_dict["pos"][i]
caridx_list = int_dict["caridx"][i]
lap_pct_list = int_dict["lap_pct"][i]
session_time_list = int_dict["session_time"][i]

# Print or process the data


print(f"Driver {i+1}: Position: {pos_list}, CarIDx: {caridx_list}, Lap Pct:
{lap_pct_list}, Session Time: {session_time_list}")

****
change session time to update per driver per lap pct, should not be the same

Driver 1: Position: 0, CarIDx: , Lap Pct: -1.0, Session Time: 28257


Driver 2: Position: 6, CarIDx: , Lap Pct: 0.7230823636054993, Session Time: 28257
Driver 3: Position: 3, CarIDx: , Lap Pct: 0.7029251456260681, Session Time: 28257
Driver 4: Position: 4, CarIDx: , Lap Pct: 0.32032665610313416, Session Time: 28257
Driver 5: Position: 8, CarIDx: , Lap Pct: 0.5442788600921631, Session Time: 28257
Driver 6: Position: 2, CarIDx: , Lap Pct: 0.6142193675041199, Session Time: 28257
Driver 7: Position: 9, CarIDx: , Lap Pct: 0.5551369786262512, Session Time: 28257
Driver 8: Position: 10, CarIDx: , Lap Pct: 0.4418381154537201, Session Time: 28257
Driver 9: Position: 1, CarIDx: , Lap Pct: 0.4197373688220978, Session Time: 28257
Driver 10: Position: 7, CarIDx: , Lap Pct: 0.2655758261680603, Session Time: 28257
Driver 11: Position: 5, CarIDx: , Lap Pct: 0.15417388081550598, Session Time: 28257
Driver 12: Position: 0, CarIDx: , Lap Pct: 0.10886377841234207, Session Time: 28257
Driver 13: Position: 0, CarIDx: , Lap Pct: -1.0, Session Time: 28257
Driver 14: Position: 0, CarIDx: , Lap Pct: -1.0, Session Time: 28257
Driver 15: Position: 0, CarIDx: , Lap Pct: -1.0, Session Time: 28257

You might also like