89.8k views
3 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 Kwisatz
by
5.5k points

1 Answer

5 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 Daniel Ehrhardt
by
5.6k points