Matuiss2

Age survey

Sep 18th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. # Entry
  2. age = ''
  3. count = 0
  4. total = 0
  5. # Process
  6. while age != -1:
  7.     age = int(input("Type the age of the citizen or type -1 to close the program:"))
  8.     if age != -1:
  9.         total += 1
  10.         sex = int(input("Type 1 if the citizen is female\nType 2 if the citizen is male:"))
  11.         if sex == 1 and age <= 35 and age >= 18:
  12.             count += 1
  13. # Output
  14. if count == 0:
  15.     print("The percentage of women between 18 and 35 in the city is 0%")
  16. else:
  17.     percentage = count / total * 100
  18.     print("The percentage of women between 18 and 35 in the city is", percentage, "%")
Advertisement
Add Comment
Please, Sign In to add comment