Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Kay Sawbridge
- Session 1
- Python Programming Constructs
- '''
- #Ask questions and assign the answers to variables
- name = input("What is your name? ")
- age = int(input("How old are you please? "))
- holiday = input("Where is your favourite place to go on holiday? ")
- colour = input("What colour do you like best? ")
- pension = (66-age) #Work out how many years they have until retirement
- print ("\n") #new line
- print("Hi ",name,", I see you only have",pension,"years until you can retire.\nPerhaps you could then go and live in",holiday,"and buy a beautiful",colour,"house to live in?")
- print ("\n") #new line
- game = input("Would you like to play a game? Yes or No? ")
- #ask user to guess the number if they want to play
- if game=="Yes":
- target_number = 8 #set target number value to 8
- number = int(input("I'm thinking of a number between 1 and 10, can you guess the number? "))
- #loop until the correct number is input
- while number !=target_number:
- #if number!=target_number:
- print ("Oops, incorrect")
- number=int(input("I'm feeling generous, have another go "))
- else:
- print ("You're getting good, correct well done! See you another time")
- #end the program with a message if thr user does not want to play
- else:
- print("Okay, maybe another time, bye for now")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement