python homework study notes two

# 1、判断下列逻辑语句的True, False.
# 1, 1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
# 1>1 or 3<4 or F or 7<6
# F or T or F or F
# T
# 2, not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
# F and 3<4 or F or 7<6
# F or F or F
# F
# 3, 1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8 and 4 > 6 or 3 < 2
# F or F or F or 3<2
# F
#
# 2、求出下列逻辑语句的值
# 1,8 or 3 and 4 or 2 and 0 or 9 and 7
# 8 or 4 or 0 or 7
# 8
#
# 2, 0 or 2 and 3 and 4 or 6 and 0 or 3
# 0 or 4 or 0 or 3
# 4
# 3, 5 and 9 or 10 and 2 or 3 and 5 or 4 or 5
# 9 or 2 or 5 or 4 or 5
# 9
#
# 3、下列结果是什么?
# 1,6 or 2 > 1
# 6 or T
# 6
# 2, 3 or 2 > 1
# 3 or T
# 3
# 3, 0 or 5 < 4
# 0 or F
# F
# 4, 5 < 4 or 3
# F or 3
# 3
# 5, 2 > 1 or 6
# T or 6
# T
# 6, 3 and 2 > 1
# 3 and T
# T
# 7, 0 and 3 > 1
# 0 and T
# T
# 8, 2 > 1 and 3
# T and 3
# 3
# 9, 3 > 1 and 0
# T and 0
# 0
# 10,3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2)
# T and 2 or T and 3 and 4 or T
# 2 or 4 or T
# 2
#
# 4, briefly variable naming
# numbers, letters, lines fell freely combined, can not begin with a number,
# having descriptive
# Python is not a keyword
# is not Chinese
#
#. 5, INPUT name = ( " >>> ")
# variable name is what type of data?
# Type string str
#
# 6, the basic structure if conditional statement
"" "
if conditions:
results
elif condition:
the results of
...
the else condition:
results
" ""
#
# 7, the basic structure of the while loop?
"" "
The while condition:
the results
or
the while condition:
the results of
the else

" ""
#
# 8, write code: Calculation # 1 - 2 + ... + 3 Total 99 88 In addition to the number of all?
count = 0
i = 0
while count < 99:
    count += 1
    if count == 88:
        continue
    if count % 2 == 0:
        i -= count
    else:
        i += count
    print(count)
print(i)
# 9, user login (unsuccessful attempts to enter the opportunity) and each output error is displayed when the remaining number of errors 
# (Hint: Use string formatting)
name = 'admin'
pd = 12345
count = 0
i = 3

while count < 3:
    msg = "" " You have mistyped% d times, there are chances% d " "" % (COUNT + 1, i-1 )
    USER_NAME = INPUT ( ' Enter Username ' )
    user_pd = the INPUT ( ' Please enter your password ' )
     IF user_name == name and int (user_pd) == pd:
         Print ( ' Login successful ' )
         BREAK 
    the else : Print (msg)
    count += 1
    i -= 1
# 10, briefly ascii, uniconde, utf - 8 encoding relationship 
# ascii is the first encoding can only represent 256 possible, only letters, special characters, numbers only 8-bit bytes, there was a bit reserved, are 0
# Unicode later founded the Unicode can be up to 32 represents a byte
# utf-8 unicode upgrade UTF-8 UTF-16 UTF-32
# a character at least by 8 bits, English 8-bit, Europe with 16 He said the Chinese represented 24
# gbk China's own invention, a Chinese use two bytes to represent 16



Guess you like

Origin www.cnblogs.com/xiuyou/p/11095870.html