Advertisement
KaySawbridge

Else and ELif

Jul 31st, 2020
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. your_age = int(input("How old are you?: "))
  2. if your_age <= 6:
  3.   print("Perfect I want to find out about picture books that children like.")
  4.   your_book_choice=input("What is your favourite picture book?: ")
  5.   print ("Good choice, I love",your_book_choice,"too! Lots of lovely colourful pictures to look at.")
  6. elif your_age <=10:
  7.     print("Perfect I want to find out about story books that children like.")
  8.     your_book_choice=input("What is your favourite story book?: ")
  9.     print ("Good choice, I love",your_book_choice,"too! A lovely story book.")
  10. elif your_age <=16:
  11.     print("Perfect I want to find out about novels you like.")
  12.     your_book_choice=input("What is your favourite novel?: ")
  13.     print ("Good choice, I love",your_book_choice,"too! A lovely novel.")
  14.  
  15. else:
  16.   print("Thanks for helping - but only children can answer this survey.")
  17.  
  18. #Use elif statements to modify the code so that different age ranges of children get different questions.
  19. #For 6 and under it asks about their favourite picture books
  20. #For 6-10 it asks their favourite story book
  21. #For 10-16 it asks for their favourite novel
  22. #Hint if you are using <= operators then start with the youngest group (6) and work your way up. THe catch all "else" for adults should stay the same.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement