Python Program to Find Seconds Per Day

There are 60 seconds in a minute, 3600 seconds in an hour, and 86400 seconds in a day. We can easily find the number of seconds in each day, hour, week or even a month as these are just simple math calculations. If you are a newbie to Python, you should try writing a program to find the number of seconds per day. So in this article, I will take you through how to write a python program to find the number of seconds per day.

Python Program to Find Seconds Per Day

To find the number of seconds in a particular number of days, I’ll create a function that accepts one parameter as the number of days, then, I will convert the number of days to hours, then hours to minutes and finally minutes to seconds. So here is how we can write a Python program to find the number of seconds per day:

172800

In the code above, I first created a Python function as seconds_per_day() with a single parameter as days. Then I introduced a variable as hours inside the function where I have stored the output of days multiplied by 24. In simple terms, I have stored the number of hours in the number of days inside the variable hours. Then in the next line, I introduced another variable as minutes to convert hours to minutes. Then in the next line, I have converted the number of minutes to seconds.

Summary

So this is how we can write a Python program to print the number of seconds per day. To find the number of seconds in a particular number of days, I have created a function that accepts one parameter as the number of days, then I have converted the number of days to hours, then hours to minutes and finally minutes to seconds. I hope you liked this article on how to write a Python program to print seconds per day. Feel free to ask your valuable questions in the comments section below.

Aman Kharwal
Aman Kharwal

I'm a writer and data scientist on a mission to educate others about the incredible power of data📈.

Articles: 1433

Leave a Reply