Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Computers measure time in a number of seconds since a particular date ( 1 January 1 9 7 0 ) , which is often called

Computers measure time in a number of seconds since a particular date (1 January 1970), which is often called the "epoch". Below, two lines of code are given that report this number to you. (We will talk more about importing modules later on.)
import time
seconds_since_epoch = time.time()
print("The current number of seconds since the epoch is", seconds_since_epoch)
The current number of seconds since the epoch is 1706113461.442004
Try running this code a few times. Notice the result is different every time you run it, since time is always passing!
Write two lines of code in the cell below.
The first line should use this variable seconds_since_epoch and convert it into the number of whole days since the epoch. Your line of code should also save the resulting value to a variable with a descriptive name.
The second line should print the value of your new variable. Make sure your result is a whole number! If it's not, think about using a different arithmetic operation.
Hint: How many seconds are in a day?
total_days = seconds_since_epoch /86400
print(total_days)
19746.683581504676
(b) Seconds today
Write two lines of code in the cell below.
The first line should use the value seconds_since_epoch to determine how many seconds have passed in the current day and save it to a variable. Hint: Use the modulus operator.
The second line should print the value of your new variable.
(c) Current time
Write code in the cell below that uses the values found in the previous parts to compute the current time of the day (hours, minutes, and seconds), then prints it.
Suggestions:
To find the current hour, you will want to use the variable for the number of seconds today that you found in part (b).
To find how many minutes have passed in the current hour, it may help first to compute how many seconds have passed in the current hour.
To find how many seconds have passed in the current minute, it will again help to start with the number of seconds in the current hour.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions