Advertisement
sawczakl

dc_base

May 27th, 2023
1,123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. lifespan = 80
  2. age = int(input('Enter your age: '))
  3.  
  4. # Ask if they smoke. Notice that this is not int(input()) because we're not asking for a number.
  5. smokes = input('Do you smoke? (Y/N): ').strip().upper()
  6.  
  7. # If they answered Y, they lose 10 years. Otherwise they lose 0 years.
  8. if smokes == 'Y':
  9.   smoking_factor = 10
  10. else:
  11.   smoking_factor = 0
  12.  
  13. remaining = lifespan - age - smoking_factor
  14. print(f'You have {remaining} years left to live.')
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement