Answer to Question #350995 in Python for gaurav

Question #350995

Create an empty dictionary called Car_0 . Then fill the dictionary with Keys : color , speed , X_position and Y_position.

car_0 = {'x_position': 10, 'y_position': 72, 'speed': 'medium'} .

a) If the speed is slow the coordinates of the X_pos get incremented by 2.

b) If the speed is Medium the coordinates of the X_pos gets incremented by 9

c) Now if the speed is Fast the coordinates of the X_pos gets incremented by 22.

Print the modified dictionary.


1
Expert's answer
2022-06-17T13:56:34-0400
Car_0 = {}
Car_0['x_position'] = 10
Car_0['y_position'] = 72
Car_0['speed'] = 'medium'
Car_0['color'] = 'red'
if Car_0['speed'] == 'slow':
    Car_0['x_position'] += 2
elif Car_0['speed'] == 'medium':
    Car_0['x_position'] += 9
elif Car_0['speed'] == 'fast':
    Car_0['x_position'] += 22
print(Car_0)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS