if elif else Problems

Problem 1

Write Python code that asks the user for a number in the range of 1 through 7. Display the corresponding day of the week where

• 1 for Monday

• 2 for Tuesday

• 3 for Wednesday

• 4 for Thursday

• 5 for Friday

• 6 for Saturday

• 7 for Sunday.

• If the user enters a number outside the range of 1 - 7, print “error, out of range”.

Problem 2

Write Python code that asks a user for the day of the week in English and translates it to Spanish.

 English Spanish Sunday Domingo Monday Lunes Tuesday Martes Wednesday Miercoles Thursday Jueves Friday Viernes Saturday Sabado

If the user enters a word other than the ones above, print "Invalido".

Problem 3

Write Python code that asks a user what year they were born in and then prints their Chinese Zodiac symbol.

 Year Chinese Zodiac 1996 Rat 1997 Ox 1998 Tiger 1999 Rabbit 2000 Dragon 2001 Snake 2002 Horse 2003 Goat 2004 Monkey 2005 Rooster 2006 Dog 2007 Pig

Problem 4

Write Python code that asks a user to enter a number from 1 through 10. The program should display the Roman numeral version of that number.

 Number Roman Numeral 1 I 2 II 3 III 4 IV 5 V 6 VI 7 VII 8 VIII 9 IX 10 X

If the number is outside of this range, print "we’ll work on that problem later".

Problem 5

Write Python code that asks a user how much money they spend at the store sale.

• If they spend less than \$75, they receive no discount.

• If the user spends \$75 or more, they receive \$15 off.

• If the user spends \$100 or more, they receive \$25 off.

• If they user spends \$150 or more, they receive \$50 off.

Print the total of the order.

Problem 6

Write Python code that asks a user how much money they spend at the store sale.

• If the user spends \$60 or more, they receive 30% off.

• If the user spends \$50 or more, they receive 25% off.

• Otherwise, the user will always save 20% off.

Print the total of the order.

Problem 7

Write Python code that asks a user how much money they spend at the store sale.

The sale is 15% off \$250+, 20% off \$500+, 25% off \$1000+.

They will not receive a discount if they order less than \$250.

Print the total of the order.

Problem 8

Write Python code that asks a user to enter the magnitude of an earthquake on the Richter scale. Print the descriptor based on the table.

 Magnitude Descriptor Less than 2.0 Micro 2.0 to less than 3.0 Very Minor 3.0 to less than 4.0 Minor 4.0 to less than 5.0 Light 5.0 to less than 6.0 Moderate 6.0 to less than 7.0 Strong 7.0 to less than 8.0 Major 8.0 to less than 10.0 Great 10.0 or more Meteoric

Problem 9

Write Python code that asks the user for their letter grade. Print the Grade Point based on the table.

 Letter Grade Point A+ 4.3 A 4 A- 3.7 B+ 3.3 B 3.0 B- 2.7 C+ 2.3 C 2.0 D+ 1.3 D 1.0 F 0

If the letter is invalid, print an error message.

Problem 10

Write Python code that asks the user for their total points. Print the Letter Grade based on the table.

 Letter Grade Out of 1000 A 940 - 1000 A- 900 - 939 B+ 870 – 899.9 B 840 – 869.9 B- 800 – 839.9 C+ 770 – 799.9 C 700 – 769.9 D 600 – 699.9 F 599 or below

Problem 11

A cell phone plan charges \$50 for up to 12 gigs of data, \$60 for up to 30 gigs of data and \$80 for up to 50 gigs of data. Write Python code that asks the user how much data they used last month and print the cost and add New Jersey sales tax (6.625%)

Problem 12

A shipping company charges a base rate based on the weight of a shipment.

Write Python code that asks the user how much the weight of their shipment is. Print the base price.

Problem 13

A shipping company sells Bankers Boxes in Bundles of 12. Write Python code that asks the user how boxes they want (assume it's a multiple of 12 and Model No. S-6522) and print the total cost.

Last updated