3. If condition judgment

Source: Internet
Author: User
1. fixed format

Note: Do not forget to write after if else! Don't forget to write it! Don't forget to write it!

If <condition judgment 1>: <execution 1> Elif <condition Judgment 2>: <execution 2> Elif <condition judgment 3 >:< execution 3> else: <execution 4>

2. input in the input console

You can define a variable to receive the value entered on the console;

1 name = input ("Enter the user name ")

Note: The data type returned by input is str. If you want to compare it with the numeric type, you need to convert it.

1 S = input ('birth: ') 2 birth = int (s)

3. Simple examples of IF and Input

1 name = input ("enter user name") 2 code = input ("Enter Password") 3 if name = "root" and code = "root ": 4 print ("Login successful") 5 Elif name = "root" and code! = "Root": 6 print ("Incorrect password") 7 Elif name! = "Root" and code = "root": 8 print ("Account Error") 9 else: 10 print ("account name and password error ")

 

3. If condition judgment

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.