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...
Create the following tables. The underlined bold column names are the primary keys. Make sure to...
Create the following tables. The underlined bold column names are the primary keys. Make sure to specify the primary and foreign key constraints in your create table statements. customer: (cus_code:integer, cus_lname:varchar(20), cus_fname:varchar(20), cus_initial:char, cus_areacode:integer,cus_phone:integer). invoice: (inv_number:integer, cus_code:integer, inv_date:date,                   foreign key cus_code references customer(cus_code)) vendor:(vend_code:integer,vend_name:varchar(30),vend_contact:varchar(30),vend_areacode:integer,vend_phone:integer) product:(prod_code:integer, prod_desc:varchar(50), prod_price:integer, prod_quant:integer,vend_code:integer, foreign key (vend_code) referenecs Vendor(vend_code)) line: (inv_number:integer, prod_code:integer ,line_units:integer, foreign key (inv_number) references Invoice(inv_number), foreign key (prod_code) references Product (prod_code) )
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT