Chapter 2: Problem 29
The function time in the module time returns the number of seconds since a particular date (called the Epoch, which is January 1 , 1970 on many types of computers). Python programs can therefore use time.time() to mimic a stop watch. Another function, time.sleep(n) causes the program to "sleep" n seconds and is handy to insert a pause. Use this information to explain what the following code does: import time t0 = time.time() while time.time() - t0 < 10: print ’....I like while loops!’ time.sleep(2) print ’Oh, no - the loop is over.’ How many times is the print statement inside the loop executed? Now, copy the code segment and change < with > in the loop condition. Explain what happens now. Name of program: time_while.py.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.