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 in Python by Shri

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")


answered Jul 10 by Rasheed

Related Questions In Python

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
0 votes
1 answer
0 votes
1 answer

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

def add(a,b):      return a + b #when i call ...READ MORE

answered May 20 in Python by Mohammad
• 3,060 points
0 votes
0 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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 348 views
+4 votes
6 answers
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 in Python by Mohammad
• 3,060 points
0 votes
1 answer