Question

In: Computer Science

ising software pyton 3.5 Weight Lifting Make a dictionary where the keys are the names of...

ising software pyton 3.5

Weight Lifting

Make a dictionary where the keys are the names of weight lifting exercises, and the values are the number of times you did that exercise.(At least 5 exercises,be creative. Nobody should have same values)

Use a for loop to print out a series of statements such as "I did 10 bench presses".

Modify one of the values in your dictionary, to represent doing more of that exercise.

Use a for loop to print out a series of statements such as "I did 10 bench presses".

Add a new key-value pair to your dictionary.
Use a for loop to print out a series of statements such as "I did 10 bench presses".

Remove one of the key-value pairs from your dictionary.

Use a for loop to print out a series of statements such as "I did 10 bench presses".

Use a function to do all of the looping and printing in this problem.

Solutions

Expert Solution

#drop a comment if anything is wrong

#------------------------------------------

#method for printing and looping

def printRoutine(routine):

    for exercise in routine:

        print("I did",str(routine[exercise]), exercise)

    print("")


routine={"bench press":8, "pull ups":8,"deadlifts":5,"squats":5,"crunches":50}


printRoutine(routine)

#increasing value of a key

routine["crunches"]=routine["crunches"]+10

printRoutine(routine)

#adding a new key-value pair

routine["Good mornings"]=10

printRoutine(routine)

#removing a key

routine.pop("crunches")

printRoutine(routine)


#------------------------------------------------------


Related Solutions

Weight Lifting Make a dictionary where the keys are the names of weight lifting exercises, and...
Weight Lifting Make a dictionary where the keys are the names of weight lifting exercises, and the values are the number of times you did that exercise.(At least 5 exercises,be creative. Nobody should have same values) Use a for loop to print out a series of statements such as "I did 10 bench presses". Modify one of the values in your dictionary, to represent doing more of that exercise. Use a for loop to print out a series of statements...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT