Search code examples
pythontimerdelay

delay in python


I Created a quiz game on python, where basically the user answers some questions i randomly made up and after that they press enter, it will say " calculating you smartness " and will show a random number on your screen. problem is,everytime the user press enter it will say "calculating your smartness" and shows the number at the same time. im wondering how to add a delay before starting the next code/line/script.?

here is my code so far

import os
import time
a = raw_input("how old is I?:")
w = raw_input("How many ants are in the world?:")
e = raw_input("why am i asking so many questions:")
s = raw_input("Are mcdonalds food healthier than pizza huts?:")
o = raw_input("Are you fat:")
m = raw_input("show me examples of random:")
e = raw_input("how to eat a chicken without a chicken?:")
e = raw_input("Can you park in reverse while driving forwards while flying?:")
os.system('cls')
print "----------------------"
print "here are your answers!"
print a
print w
print e
print s
print o
print m
print e
print e
print "----------------------------------------------------------"
print 'now calculating smartness:'
print "Your smart level is:"
import random
print random.randint(1,100)
print "----------------------------------------------------------"
print "aw c'mon you can do better than that!!!!"
print "----------------------------------------------------------"
raw_input("Press enter to quit the game")

please and thank you. :)


Solution

  • time module's sleep()

    Also, you already have it imported for some reason.