Answers for "hwo to make a stopwatch in python"

3

hwo to creat a stopwatch using python

# Create a stopwatch

# Import a module called as time

import time

# create all the variables

day = 0
hour = 0
min = 0
sec = 0

# Display the headings

print("D - H - M - S")
print()

# Create an infinite loop

while True:

    # Create the main part of the stopwatch

    time.sleep(1)

    if sec == 59:
       sec = -1
       min = min + 1

    sec = sec + 1
    if min == 60:
        min = 0
        hour = hour + 1

    if hour == 24:
        hour = 0
        day = day + 1
    print(day, "-", hour, "-", min, "-", sec)
Posted by: Guest on August-25-2020
0

how to make a stopwatch in pythoon

import time

now = time.time()
future = now + 10
while time.time() < future:
    # do stuff
    pass
Posted by: Guest on July-16-2020

Code answers related to "hwo to make a stopwatch in python"

Python Answers by Framework

Browse Popular Code Answers by Language