Lesson1:python Judgment Expression Application

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.