Advertisement
KaySawbridge

ChatBot Session 1 Gap Task

Jul 27th, 2020
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. '''
  2. Kay Sawbridge
  3. Session 1
  4. Python Programming Constructs
  5. '''
  6. #Ask questions and assign the answers to variables
  7. name = input("What is your name? ")
  8. age = int(input("How old are you please? "))
  9. holiday = input("Where is your favourite place to go on holiday? ")
  10. colour = input("What colour do you like best? ")
  11. pension = (66-age) #Work out how many years they have until retirement
  12. print ("\n") #new line
  13. 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?")
  14.  
  15. print ("\n") #new line
  16.  
  17.  
  18. game = input("Would you like to play a game? Yes or No? ")
  19. #ask user to guess the number if they want to play
  20. if game=="Yes":
  21.     target_number = 8 #set target number value to 8
  22.    
  23.     number = int(input("I'm thinking of a number between 1 and 10, can you guess the number? "))
  24.     #loop until the correct number is input
  25.     while number !=target_number:
  26.             #if number!=target_number:    
  27.         print ("Oops, incorrect")
  28.         number=int(input("I'm feeling generous, have another go "))
  29.     else:
  30.         print ("You're getting good, correct well done! See you another time")
  31. #end the program with a message if thr user does not want to play
  32. else:
  33.     print("Okay, maybe another time, bye for now")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement