315,696 views
32 votes
32 votes
Write a program named HoursAndMinutes that declares a minutes variable to represent minutes worked on a job, and assign a value to it. Display the value in hours and minutes. For example, 197 minutes becomes 3 hours and 17 minutes.'

User JeCh
by
2.5k points

1 Answer

13 votes
13 votes

Answer:

Step-by-step explanation:

The following code is written in Python, it asks the user for the number of minutes worked. Divides that into hours and minutes, saves the values into separate variables, and then prints the correct statement using those values. Output can be seen in the attached image below.

import math

class HoursAndMinutes:

min = input("Enter number of minutes worked: ")

hours = math.floor(int(min) / 60)

minutes = (int(min) % 60)

print(str(hours) + " hours and " + str(minutes) + " minutes")

Write a program named HoursAndMinutes that declares a minutes variable to represent-example-1
User Rodamn
by
2.4k points