Convert Days To Hours In Python
Last updated January 31, 2024 by Jarvis Silva
Looking for a way to convert days to hours in python programming then you are at the right place, today in this article I will show you how to convert day to hours using python.
Want to know how to convert minutes to hours then follow this tutorial converting minutes to hours and minutes format.
Before I show you how to convert days into hours in python, let’s see some example on how this will work
# Example 1
INPUT: 10 Days
OUTPUT: 240 hours
# Example 2
INPUT: 2 Days
OUTPUT: 48 hours
As you can see from the above examples we give it an input of 10 days then it gives us an output in 240 hours which is 10 days now let’s see this in code.
Python code to convert days to hours
days = int(input("Enter amount of days: "))
hours = days * 24
print(f"{hours} hours")
As you can see we just multiply the days with 24 as 1 day is 24 hours, copy the above python code and paste it in your python file and run it on your computer or use an online python compiler.
Enter amount of day: 10
240 hours
If you don’t have python installed you can install it from the python website, if you want a complete guide you can refer to this: Install and setup python.
So this was the tutorial on python converting days to hours. I hope you ran the program successfully and you got what you were looking for, share this guide if anyone wants and join our Telegram channel for future updates.
Thanks for reading, have a nice day 🙂