Run two functions at different times

0 votes
I have two functions in a program. Function 1 should run for every 2 seconds. Function 2 should run for every 10 seconds. How can I implement this in python?
Jul 10, 2019 in Python by Shri
1,667 views

1 answer to this question.

0 votes

Please refer the below code for your problem:

import threading

def printit2():

  threading.Timer(2.0, printit2).start()

  print ("2")


def printit10():

  threading.Timer(10.0, printit10).start()

  print ("10")


printit2()

printit10()
answered Jul 10, 2019 by Rasheed

Related Questions In Python

0 votes
1 answer

how to run test cases of different modules with same marker at a time using pytest

Hey,@Nikitha, Suppose you have multiple files say test_sample1.py, test_sample2.py. To ...READ MORE

answered Apr 28, 2020 in Python by Gitika
• 65,770 points
1,779 views
0 votes
1 answer

Looping over two lists at once

You have to use the zip() function: for ...READ MORE

answered May 15, 2018 in Python by Nietzsche's daemon
• 4,260 points
1,709 views
0 votes
1 answer

How to print rows at different locations of pandas dataframe?

Like you are using row slicing, you ...READ MORE

answered May 13, 2019 in Python by Gani
2,151 views
0 votes
2 answers

How can I write a program to add two numbers using functions in python?

there is sum() function as a built ...READ MORE

answered Oct 25, 2020 in Python by anonymous
23,846 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,440 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,076 views
0 votes
1 answer

Why am I getting a error when I am printing two different data types in python?

different data type is being used. that ...READ MORE

answered Mar 6, 2019 in Python by Mohammad
• 3,230 points
1,043 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP