Skip to main content

Section 2.16 Mixed-up Code Questions

Checkpoint 2.16.1.

Create code that first sets the variable x to 3, then sets the variable y to the string “hello”, and then sets the variable z to the string “Python”. Then set x_type, y_type, and z_type to the types of each of these variables. For example, x_type = int. The blocks have been mixed up and include extra blocks that aren't correct.

Checkpoint 2.16.2.

Create code that sets Carla to the sentence “Carla ate 4 apples.”. The blocks have been mixed up and include extra blocks that aren't correct.

Checkpoint 2.16.3.

Create code that calculates John's gross pay for a certain week and inputs it into grossPay given that he worked 45 hours that week, earned 10 dollars per hour, and recieved a 5 percent bonus of his salary that week. The blocks have been mixed up and include extra blocks that aren't correct.

Checkpoint 2.16.4.

Create code that stores the cost of each shirt in the variable pricePerShirt if John purchases 2 shirts and gets the third free with each shirt originally costing $45. The blocks have been mixed up and include an extra block that isn't correct.

Checkpoint 2.16.5.

Create code that assigns the cost per person for a dinner to perPersonCost. tip is a percentage of the bill. The blocks have been mixed up and include an extra block that isn't needed in the solution.

Checkpoint 2.16.6.

Create code that swaps the values of x and y. The blocks have been mixed up and include an extra block that isn't needed in the solution.

Checkpoint 2.16.7.

Create code that assigns the final price you will have to pay for an item that is 60% off the original price of $52.99 to finalPrice. The blocks have been mixed up and include extra blocks that aren't needed in the solution.

Checkpoint 2.16.8.

Create code that sets cookies to the sentence “Chris likes baking cookies more than anything.”. The blocks have been mixed up and include extra blocks that aren't correct.

Checkpoint 2.16.9.

Create code that sets var to the sentence “It takes us 165 minutes to get home from camp.”. Then append the sentence “165 minutes is also 2 hours and 45 minutes.” to the variable. The blocks have been mixed up and include extra blocks that aren't correct.

Checkpoint 2.16.10.

Create code that sets num_quarters to the maximum number of quarters you can provide as change if your friend owed you 17.42 dollars but gave you 20 dollars. The blocks have been mixed up and include an extra block that isn't correct.