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 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, 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, To ...READ MORE

answered Apr 28 in Python by Gitika
• 32,930 points
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

How to print rows at different locations of pandas dataframe?

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

answered May 12, 2019 in Python by Gani
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, 2019 in Python by Mohammad
• 3,210 points
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,170 views
0 votes
0 answers
+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, 2019 in Python by Mohammad
• 3,210 points
0 votes
1 answer