1/5/2016 Judgment Expression Application
Sample1:
Salary=raw_input ("Please input your salary:")
If salary>=10000:
Print "You can eat twice! ^_^"
Elif 5000<= Salary <10000:
Print "You Can eat once!-_-"
else salary<5000:
Print "You can not eat anything! #_ #!"
The Issue1:salary start assignment is a string type, and the subsequent judgment value is integer, which requires a data type conversion before the expression is evaluated, salary=int (salary).
The Issue2:salary str type always executes the first branch statement before it is converted to an integer, because the string type is always larger than the int type.
Issue3: On the last branch judgment, use the Else statement directly, without adding any conditions, and if you add a condition after else, a syntax error occurs, and in the previous example else: =elif salary<5000:
Lesson1:python Judgment Expression Application