python-Job-2

Source: Internet
Author: User

Summary

1. Determine if something is in something, in or not, and the result is a Boolean value (False or True)

Name = "Electromagnetic radiation"
v = "Inside" in name
Print (v)

2. Operators

+ - * / ** % //

The percent is the remainder, example 9%2=1, and/or the quotient, such as 9//2=4

3. The difference between break and continue

i = 0 while I <    := i + 1    print(i)    continue#  orbreak    print('test')Print ('end')

Continue continues to loop the condition in the while and does not perform the following content

Break above and below the content are not executed, jump out of the loop directly

4. While and if can be used as conditional judgment and else, but while can loop if but does not have this function.

i = 0 while I <:    print(i)    = i + 1else:     Print ('else')print('end  ')

5. Note that the print order is different and the output is different

i =0 whileI < 10:    ifi = = 7: I= i + 1Continue    Else:        Print(i) I= i + 1#No output 7-----------------------------------------------------------------------------I=0 whileI < 10:    ifi = = 7: I= i + 1Continue # Break    Else: I= i + 1Print. IOPrint('End')#No output 8

--------------------------------------------------------------------------------------

Job: User Login (three chance retry)

i =0 whileI < 3: User_input= Input ("Please enter user name:") User_pwd= Input ("Please enter your password:")    ifUser_input = ="User"  andUser_pwd = ="123456":        Print("Welcome to login! ")        Print(".............")         Break    Else:        Print("incorrect user name or password") I= i + 1

python-Job-2

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.