Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Asking the user for minutes then telling them what it is in hours

Ask the user for a number of minutes. Tell them how long that is in hours. I am kinda new to python and still trying to figure out some of the basics but no matter what I try nothing works so please help.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The basic steps:

# prompt for input and convert from str to int
minutes = int(input("minutes:" ))
# minutes: 135

# do the math
hours, minutes = divmod(minutes, 60)

# produce output of some kind
print(f"{hours}:{minutes}h")
# 2:15h

Docs on some utils:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading