Knowee
Questions
Features
Study Tools

Write a program to print 1 after 1 sec, 2 after 2 sec till 5. Complete the given code to get the desired output as shown in the expected output.

Question

Write a program to print 1 after 1 sec, 2 after 2 sec till 5. Complete the given code to get the desired output as shown in the expected output.

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a Python program that uses the time module to achieve this:

import time

for i in range(1, 6):
    time.sleep(i)
    print(i)

This program works by looping over the numbers 1 through 5. For each number i, it pauses for i seconds (using time.sleep(i)) and then prints i.

Similar Questions

Create a Time class and initialize it with hours and minutes.1. Make a method addTime which should take two time object and add them. E.g.- (2 hour and 50 min)+(1 hr and 20 min) is (4 hr and 10 min)2. Make a method displayTime which should print the time.3. Make a method DisplayMinute which should display the total minutes in the Time. E.g.- (1 hr 2 min) should display 62 minute.

Write a program to print the following output: [3] 5 5 5 5 5 4 4 4 4 3 3 3 2 2 1

Objectivesimproving the ability to use numbers, operators, and arithmetic operations in Python;using the print() function's formatting capabilities;learning to express everyday-life phenomena in terms of programming language.ScenarioYour task is to prepare a simple code able to evaluate the end time of a period of time, given as a number of minutes (it could be arbitrarily large). The start time is given as a pair of hours (0..23) and minutes (0..59). The result has to be printed to the console.For example, if an event starts at 12:17 and lasts 59 minutes, it will end at 13:16.Don't worry about any imperfections in your code - it's okay if it accepts an invalid time - the most important thing is that the code produce valid results for valid input data.Test your code carefully. Hint: using the % operator may be the key to success.

What will be the output of the following program?while i < 20: print(i) i += 1

= 0while i < 5: if i == 2: i += 1 continue else: print(i,end = " ") i += 1Options: Pick one correct answer from below0 1 2 3 40 1 3 4Runtime Error1

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.