Random Number Generator

This is a very short and simple piece of code which asks the user if they want a random number between 1 and 1000 to be generated and then outputs that number to the user.

--RANDOM-NUM-GENERATOR--
import random 
user = input("Would you like a random number between 0 and 1000 to be generated? ")
if user == "No" or user == "no":
    print("Okay, have a good day!")
    exit()
else:
    num = random.randint(0,1000)
    print("Your random number is",num)

Here the piece of code uses the python library “random” which is used to output the random number to the user. The user is asked to input whether they would like a random number between 1 and 1000 to be generated. After that the if condition is used to work out the users choice. While the user doesn’t input “No or “no” the number is generated but if the user does, it exits the program.