ISYS 350, Fall 21, Assignment 2, Due Date: 9/27/21

 

 

Part 1: The part practices the floor division (//) and modulus operator (%).  Don’t use the IF statement to solve this problem.  Create a Python program that uses input statements to ask user to enter the measurement of two lengths in feet and inches as integer values and compute the total length in feet and inches.  For example, the total length of 5 feet 8 inches and 4 feet 6 inches is 10 feet 2 inches; and 3 feet 5 inches and 4 feet 6 inches is 7 feet 11 inches. 

 

Copy the source code and paste to a Word document, and copy the output and  paste it to the same Word document.  Submit the Word document by email attachment.

 

Sample output:

 

Enter feet of length 1:5

Enter inches of length 1:8

Enter feet of length 2:4

Enter inches of length 2:6

Total length is: 10 feet and 2 inches

 

Enter feet of length 1:3

Enter inches of length 1:5

Enter feet of length 2:4

Enter inches of length 2:6

Total length is: 7 feet and 11 inches

 

 

Part 2:

 

Create a Python program that asks a user to enter an integer number of seconds.  And and the program displays the equivalent number of hours, minutes and seconds using.  If the seconds entered is less than 60, your program should only display the seconds; if the seconds is a least 60 and less than 3600, your program should display minutes and seconds; if the second is at least 3600, your program should display hours, minutes and seconds.  Use the following data to test your program:

 

            47 seconds:  47 seconds (don’t show 0 hour and 0 minute)

645 seconds: 10 minutes, 45 seconds (don’t show 0 hour)

            7565 seconds: 2 hours, 6 minutes, 5 seconds

 

Requirements:

1.     Input validation: The number of seconds cannot exceed 86400. 

2.     Use the if  …. elif ……else statement to solve this problem.

3.     Test your program with 47 seconds, 645 seconds, 7565 seconds, and 90000 seconds.

 

Copy the source code and paste to a Word document, and copy the output and  paste it to the same Word document.  Submit the Word document by email attachment.

 

Sample output:

Enter number of seconds: 47

47.0 seconds

>>>

Enter number of seconds: 47

47 seconds

>>>

Enter number of seconds: 645

10 minutes 45 seconds

>>>

Enter number of seconds: 7565

2 hours 6 minutes 5 seconds.

>>>

Enter number of seconds: 90000

Seconds cannot exceed 86400!