二手产品经理

二手产品经理

THIS IS RENO

Learn Python Online in 100 Days - Week 2, Day 2

Today's learning content is about number types, int and float. In addition, we learned about parentheses and error checking experience.

Learning Notes

  1. The conditions for if statements are not only double equal signs, but also !=, >, <, >=, <=.
  2. A number in quotes is not equal to a number. For example, "178" != 178. The number "178" is considered as text, a string type, in computers. The number 178 without quotes is considered as a number, a number type.
  3. There are two types of number types, int and float. Int is an integer type without a decimal part. Float is a floating-point type with a decimal part.
  4. In statements with multiple parentheses, you will often encounter errors indicating 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 complete, it is not an error, but the next line is an error because the previous line was not completed correctly.
  5. When writing code and encountering errors, if the current line does not show the problem, you should check the previous line. It may be because the previous line did not end correctly.

CODE

print("Generation Identifier")
varyear = int(input("Which year were you born? "))
if varyear < 2000 and varyear >= 1990:
    print("You are a 90s kid")
elif varyear < 1990 and varyear >= 1980:
    print("You are an 80s kid")
elif varyear < 1980 and varyear >= 1970:
    print("You are a 70s 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.