EXERCISES Unit 3 Conditional Statements

 In Python do the following

1. Write a program that accepts an integer and determines if the number 3 divides the number evenly. ( use mod)

Example 1:

Enter an Integer: 9
3 divides 9 evenly

Example 2:

Enter an Integer: 14
3 does not divide 14 evenly

 

2) Write a program that excepts a numeric grade from the keyboard and determines if the the grade is passing or failing. 60% or higher is passsing.

 

Enter your grade percentage: 77.9

You pass

 

Enter your grade percentage: 50

You fail

 

 

 

 

3) Write a program that excepts two integer values and determines which number is the smallest

Enter an integer:8

Enter another integer:5

5 is the smallest

 

 

Enter an integer:10

Enter another integer:15

10 is the smallest

 

 

4) Write a program that excepts a letter grade from the keyboard and determines if the the grade is passing or failing. A,B,C or D is passsing, F or E. is failing. All other letters are invalid grades.

Enter your grade letter: C

You pass

 

Enter your grade letter: F

You Fail

 

Enter your grade letter:M

Invalid Grade

 

 

 

5.  Quicky Overnite Delivery Service accepts no package heavier than 60 pounds, or larger than 4 cubic feet. Write a program that uses as input the weight of a package in pounds and its dimensions in feet. The program should determine if the package meets the requirements and display an appropriate message (e.g., too large, too heavy or both):

 

Enter weight of package in pounds: 62

Enter length of package in feet: 1

Enter width of package in feet: 2

Enter height of package in feet: 3

 

Package is too large and too heavy

 

6.  The Cluck Egg Company has different prices for their eggs, based upon the number sold:

 

0 up to but not including 4 dozen                                                                         $0.50 per dozen

4 up to but not including 6 dozen                                                                         $0.45 per dozen

6 up to but not including 11 dozen                                                                        $0.40 per dozen

11 or more dozen                                                                                               $0.35 per dozen

 

Extra eggs are priced at 1/12 the per dozen price each.

 

Write a program that allows the user to input the number of eggs wanted, and then calculates the bill:

 

Enter number of eggs: 126

 

Purchase: 10 dozen and 6 extra eggs

Your bill comes to $ 4.20

 

8.  a) Pop's Place pays its employees time and a half for every hour worked over 40 hours. Write a program to calculate weekly wages given the hours worked and the hourly rate:

 

Enter hours worked: 45

Enter hourly rate: 10.00

 

Wages earned = $ 475.00

 

b) Pop employs students who are exempt from taxes and others who are not. Rewrite your program so that if an employee is not exempt, 18% will be deducted from the weekly wage, otherwise "NO TAXES DEDUCTED" will be printed:

 

Enter hours worked: 45

Enter hourly rate: 10.00

Exempt (Y/N)? Y

 

Wages earned       $ 475.00

NO TAXES DEDUCTED

 

Enter hours worked: 20

Enter hourly rate: 4.00

Exempt (Y/N)? N

 

Wages earned       $ 80.00

Taxes deducted = $ 14.40

Wages after taxes = $ 65.60

 

9. What Kind of Triangle, Triangle Side

Write a program that excepts the 3 lengths of the sides of a triangle.

Use four If-Then statements with the appropriate conditions to determine and print

a) None :if it fails the triangle inequality.

b) scalene if all side lenghts are different.

c) Isosceles if two sides are equal

d) Equilateral if three sides are equal