In: Computer Science
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.
The code for the required program is given below.
main.py
WeightLifting =
{"Biceps Curl": 10,
"Bench Press": 5,
"Triceps Extension":15,
"Lateral Raise":7,
"The Chest Fly":20}
def printData():
print(" ")
for i in WeightLifting:
print("I did" , WeightLifting[i] , i)
print(" ")
#driver code
def main():
printData()
#updating values
WeightLifting["Bench Press"] = 25
#printing data
print("After Modiying value ")
printData()
#adding new data
WeightLifting["Rear Delt Row"] = 12
print("After Adding Key Pair value ")
printData()
#removing key pair value Bench Press
del WeightLifting["Bench Press"]
print("After Deleting value ")
printData()
main()
Screenshot of
Output and code for indentation