day4 notes + jobs

Variables: that amount may change, the amount refers to the state of affairs
Why have variable? In order for the computer to record the state of things, like people (execution of the program is essentially a series of changes in the state)
using the principle: first definition refers to

 

Memory management (garbage collection): Spam refers to the amount of the reference count is zero
reference count increased: the number of variables pointing to the same space increases the
reference count reduction: the number of variables pointing to the same space is reduced

Variable name: The name of the variable used in the call sign
assignment symbol: memory address used to bind variable values to the variable name of the symbol
variable value: record the state of things
naming variable names: letters + numbers + _ can not begin with a number can not be built with python keyword repetition
nomenclature: see the name to know the meaning of
naming style: pure lowercase + _
hump body

Important characteristics of three variables:
id: address memory address reflects the value of a tag id different
type: the type of value, different types of records used to indicate the status of different
value: the value itself

is: id number to compare the left and right (memory address) whether the two values are equal
==: about whether the substance is used to compare two values are equal itself
two different memory space can hold the same value, the same two values the variable address may be different
small integer pool: python interpreter will be to open up a dedicated user memory space in memory used to store frequently used characters and numbers, user-friendly call for
constant: the same amount, python is not the concept of constant only convention, when all the letters are a amount of capital, we will use it as a constant

Basic data types:
shaping: the integer part of
the floating point type: + decimal integer
effect: This indicates the number of attributes associated
string: str
effect: the state of the recording descriptive
Definition: "" a string of characters contained in the
string embedded is set to be noted that only strings and string to operate the
list: the index value corresponding to
the role: recording a plurality of values, and can be taken out of the position specified by index
Definition: within [], a plurality of spaced apart any type element
dictionary: corresponding key value (typically a string type), according to the value of key values to develop taken
effect: recording a plurality of values, and may be taken according to the value of the position specified by the key
definition: used in the {}, min a plurality of spaced apart elements of any type, key type is str
dictionary disordered
Boolean: recording the two states true and false, for determining

# Job of the first question 
'' ' 
1.str 2.list 3.str 4.dic 5.int 6.str 
' '' 
# job of the second title 
'' ' 
1.students_info [0] [2] 
2.info [ "company_info"] [ "name"] 
3.students [1] [ "hobbies"] [1] 
'' ' 
# work Optional problem 
' ''  
    list of users, with user name as a key, password is the password, 
    State is 1 0 = normal user state on behalf of the locking 
    time representative of attempts 
' '' 
user_list = {
     " jianghaonan " : { " password " : 123456, " state " : 1, "time":3},
    "alex": { " Password " : 666666, " State " :. 1, " Time " :. 3 },
     " Egon " : { " password " : 57575, " State " :. 1, " Time " :. 3 } 
} 
'' ' 
    cycle login when landing successfully detected or detected loop will end when the user has been locked 
'' ' 
the while True: 
    user_name = the iNPUT ( " Please enter your user name: " ) 
    user_password = the iNPUT ( "Please enter your password: " )
    if user_name in user_list:
        if user_list[user_name]["state"] == 0:
            print("您的用户已经被锁定")
            break
        elif user_list[user_name]["password"] == int(user_password):
            print("欢迎登陆!")
            break
        else:
            user_list[user_name]["time"]=user_list[user_name]["time"] -1
             Print ( " user name you entered is incorrect, your chances remaining% d " % (user_list [user_name] [ " Time " ]))
             IF user_list [user_name] [ " Time " ] == 0: 
                user_list [ USER_NAME] [ " State " ] = 0

 

Guess you like

Origin www.cnblogs.com/Jicc-J/p/12412031.html