tags.
[code]
#!/usr/bin/python
import time #Importing the Time module.
import random #Importing the Random module.
x = random.randint(1, 5) #Defines the "x" variable as a random integer between 1 and 5, including 1 and 5.
print "Hello and Welcome to the Random Number Game"
print "Made by Killoy at HackForums.net"
print " "
time.sleep(2) #Telling the program to pause for a few seconds for the user to read the displayed text.
y = int(raw_input("Enter a Number between 1 and 5: ")) #Lets the user define the "y" variable by using a raw input function.
time.sleep(1) #Pausing again.
while True: #Starts a simple loop.
if x == y: #Checks to see if the random variable "x" is equal to the user defined variable "y".
print "Congratulations, You Win!" #Tells the user that because variable "x" is equal to variable "y" then they win.
time.sleep(3) #Pauses to let the user see that they won.
break #Stoping the loop and jumping to after the loop.
else: #If variable "x" does not equal variable "y".
print "Try Again " #Tells the user to try again.
time.sleep(3) #Pauses to let the user see that they have lost.
break #Stoping the loop and jumping to after the loop.
print "Thanks for playing!" #Tells the user thanks for playing.
time.sleep(3) #Pauses to let the user see that the game is over.
#!/usr/bin/python
import time #Importing the Time module.
import random #Importing the Random module.
x = random.randint(1, 5) #Defines the "x" variable as a random integer between 1 and 5, including 1 and 5.
print "Hello and Welcome to the Random Number Game"
print "Made by Killoy at HackForums.net"
print " "
y = int(raw_input("Enter a Number between 1 and 5: ")) #Lets the user define the "y" variable by using a raw input function.
while True: #Starts a simple loop.
if x == y: #Checks to see if the random variable "x" is equal to the user defined variable "y".
print "Congratulations, You Win!" #Tells the user that because variable "x" is equal to variable "y" then they win.
break #Stoping the loop and jumping to after the loop.
else: #If variable "x" does not equal variable "y".
y = int(raw_input("Try again!: ")) #Let's the user try again.
print "Thanks for playing!" #Tells the user thanks for playing.
time.sleep(3) #Pauses to let the user see that the game is over.
Copyright © 2024, NextGenUpdate.
All Rights Reserved.