Wherein the variable flow control -python

Three characteristic variables:

-type: see the type of data

-id: represents the variable address in memory, is a string of numbers

-value: value of the variable


)) # Tank handsome str2 = 'faith with me, I will destroy all strong! ' 
Print (' confidence to develop note 1:% s'% (str2 ,))







price1 = input ( 'Enter the user month monthly fee deduction:') 
All = INPUT ( 'Enter the user's current balance:') 

Print ( 'Dear mobile user, is your monthly month [% s] element, account balance [% s] element '% (price1, All))! 

# - arithmetic operators 
Print (. 1 +. 1) # 2 
N1 =. 1 
# N1 = N1 +. 1 # N1 + =. 1 
# Print (N1) # 2 
N1 +. 1 = 

# assignment operator: - = 
Print (10 -. 1). 9 # 

# * = 
Print (* 12 is 12 is) # 144 
Print (. 11 /. 3) # 3.666 ... 
Print (//. 3. 11) # . 3 
Print (. 11%. 3) # 2 

# comparison operators 
Print (== 2. 1) # False 
Print (. 1> 2) # False 
Print (. 1 <2) # True 
Print (. 1> = 2) # False 
Print (. 1 <= 2) True # 

# iS: comparing whether the two variables are equal id 
X = 10 
Print (id (X) == id (X)) # True
Print (X X IS) #True 

# logical operators 
X # Y = 20 is
# And: the left and right conditions are True it is True, otherwise False 
Print (X == == X. 1 and 10) False # 
Print (X 10 and X == == 10) True # 

# or: Analyzing sides the condition is established, it was established 1 True 
Print (the X-10 or the X-== == 1) True # 

# not: contrary 
Print (the X-== 10) # True 
Print (not the X-== 10) False # 

# NO -> and -> or 
# True or False 
Print (Not X X == ==. 1 or 10 and 20 is X ==) True # 

# assignment chain 
n-10 = 
Y = n- 
Z = Y 
Print (n-, Y , Z) 

n-Z = = y = 10 
Print (n-, y, Z) 

# intersecting assignment 
X = 10 
y = 20 is 
# X and the value of y is interchanged 
# y = 10 X = 20 is 
Z = X # 10 
X = 10 
Y = 20 is
Y = Z # 10 

# 10, 20 is = Y = 10, X = 20 is 
X, Y = Y, X 
Print (X, Y) # 20 is 10 

# decompression assigned 
# 0. 1 2 
List1 = [. 1, 2,. 3] 
X = List1 [0] 
Y = List1 [. 1] 
Z = List1 [2] 
Print (X, Y, Z) #. 1 2. 3 
X, Y, Z = List1 
Print (X, Y, Z) #. 1 2. 3 




' '' if the branch 
'' ' 
# guessing game characters; the characters entered by the user to guess whether 9527. 

Number the = 9527 

gUESS the iNPUT = (' Please enter guessing numbers: ') 

Print (gUESS) 
Print (of the type (gUESS)) # str 

# the string into an integer type 
gUESS = int (gUESS) 
Print (of the type (gUESS)) # int 

IF == Number the gUESS: 
    Print ( 'guessed it!') 

elif gUESS <Number the: 
    Print ( 'guess small' ) 

the else:
    print ( 'big guess!') 

 
''' While loop:
        syntax: 
             the while judging criteria: 
             
                  # If the conditions are met the "loop" execute the following code 
                   printt ( '111') 
    
'' ' 
#import Time 
# True: 
# Print (1111) 
# the time.sleep (1) 
# Berak 

# guess character game: guess whether the character entered by the user is 9527, restrictions can only guess three times. 
= 9527 Number 
init = 2. 1. 1 # 3. 4 
the while True: 
    # 3 if the end of the cycle is greater than init 
    IF init> 3: 
        Print ( 'wrong 3 times, gun bar') 
        BREAK 

    GUESS = INPUT ( 'Enter number to guess: ') 
    gUESS = int (gUESS) 

    IF gUESS == Number: 
        Print ('! guessed ') 
        BREAK 

    elif gUESS <Number:

    the else: 
        Print ( '! big guess') 

        the init + =. 1

 

Process Control

Control of the process, control the occurrence of certain events.

-if Branch decision:

grammar:

       if the judge Stripe:

            # If the conditions are set up to perform

           print ( 'condition is satisfied!')

       # If the if condition is not satisfied, the execution here

         elif Analyzing conditions: print ( 'another condition is satisfied')

       # If the if condition is not satisfied, the execution here

         elif Analyzing conditions: print ( 'another condition is satisfied')

       # If the if and elif conditions are not satisfied, the execution here

         else:

                # If the condition is not satisfied is executed

                print ( 'condition is not satisfied!')

           

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/wangxiao1720/p/11579049.html