二手产品经理

二手产品经理

THIS IS RENO

Learn Python Online in 100 Days - Week 2 Day 2

Study Notes

  1. The judgment conditions for if not only include double equal signs, but also !=, >, <, >=, <=.
  2. Numbers with quotes are not equal to numbers. For example, "178" != 178. The number "178" with quotes is considered as text, string type in the computer. The number 178 without quotes is considered as a number, number type.
  3. There are two types of number, int type and float type. int is an integer type without decimal parts. float is a floating-point type that can have decimal parts.
  4. In statements with multiple parentheses, you may encounter errors due to missing parentheses. Parentheses appear in pairs, if there is a left parenthesis, there must be a right parenthesis. The error in the tutorial is on the second line of the parentheses, because that line is not completed, it's not an error, but the next line reports an error because the previous line was not correctly completed.
  5. When errors occur while writing code and the issue is not apparent in the current line, check the previous line, as it may be due to the previous line not being correctly completed.

CODE

print("Generation Identifier")
varyear = int(input("Which year were you born? "))
if varyear < 2000 and varyear >= 1990:
    print("You are a 90's kid")
elif varyear < 1990 and varyear >= 1980:
    print("You are an 80's kid")
elif varyear < 1980 and varyear >= 1970:
    print("You are a 70's kid")
else:
    print("Are you an oldie or a young one?")
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.