Python process processing

Source: Internet
Author: User

Python process processing


1. Process processing If...else

#!/bin/bash/env python#_*_ coding:utf-8 _*_#python version:p ython3.6import GETPASSN1 = "abc" p1 = "123" name = input ("Input Your name: ") passwd = Getpass.getpass (" Input your passwd: ") if name = = N1 and passwd = = P1:print (" Welecome login! ") Else:print ("User or pass is incorrect")

2. Process processing If...elif...elif...else

#!/bin/bash/env python#_*_ coding:utf-8 _*_#python version:3.6n1 = 21name = Int (input ("Please input ' the number which you w Ant to: ")) if name = = N1:print (" You Are too smart! ") Elif Name < 21:print ("is too small!") Else:print ("It is too big!")

3.for Cycle

Example 1:# Loop 10 Number i = 1for i in range: print (i) Example 2: #猜年龄优化for ... break# can enter 10 opportunities, enter the correct exit. N1 = 21for i in range: name = Int (input ("Please input the number which your want to:")) if name = = N1:pri        NT ("You are too smart!")    Break    Elif Name < 21:print ("is too small!") Else:print ("It is too big!")

4.while Cycle

#!/bin/bash/env python#_*_ coding:utf-8 _*_#python version:3.6 Example # loop number, when loop 10 exits count  = 0# Set counter While true:    print ("Print:"  ,count)      count +=1    if count == 10:         print ("loop completed")         break;          #跳出循环例2 # Guess age game, you can enter 10 times, but the wrong 3 times to exit. N1 = 21count = 0while true:    if count < 3:         name = int (Input ("please input the  Number which you want to: "))         if name  == n1:            print ("You are  too smart! ")         &nbsP;&NBSP;&NBSP;&NBSP;BREAK;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;ELIF&NBSP;NAME&NBSP;&LT;&NBSP;21:             print ("is too small!")         else:             print ("it is too big!")     else:        print ("You are too  failed! ")         break;    count += 1


This article is from the "506554897" blog, please be sure to keep this source http://506554897.blog.51cto.com/2823970/1906437

Python process processing

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.