Road million annual salary of python - day02 jobs

1. determine the following logical statement, we must first analyze their own

1)1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6

1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
False or True or False and True and True orFalse
False or True or False or False
True

2)not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6

not True and True or False and True and True or False
False and True or False and True and True or False
False or False and True or False
False or False or False
False

2. The following logic statements obtained values, we must analyze their own

1)8 or 3 and 4 or 2 and 0 or 9 and 7

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 2 and 3 and 4 or 6 and 0 or 3
0 or 4 or 0 or 3
4

3)1 and 0 or 8 and 9 and 5 or 2

1 and 0 or 8 and 9 and 5 or 2
0 or 5 or 2
5

4)4 or 8 and not False and 8 or 9

4 or 8 and not False and 8 or 9
4 or 8 and True and 8 or 9
4 or 8 or 9
4

3. The following is the result of what? (2> 1 This is one)

  1. 6 or 2 > 1

    6 or True
    6
  2. 3 or 2 > 1

    3 or True
    3
  3. 0 or 5 < 4

    0 or False
    False
  4. 5 < 4 or 3

    False or 3
    3
  5. 2 > 1 or 6

    True or 6
    True
  6. 3 and 2 > 1

    3 and True
    True
  7. 0 and 3 > 1

    0 and True
    0
  8. 2 > 1 and 3

    True and 3
    3
  9. 3 > 1 and 0

    True and 0
    0
  10. 3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2

    True and 2 or True and 3 and 4 or True
    2 or 4 or True
    2

4. Description of ASCII, Unicode, utf-8 encoded

ASCII编码:不支持中文
Unicode:万国码,英文16位,中文32位
UTF-8:可变长编码,英文8位,欧洲文16位,亚洲文24位

5. Description of the relationship between bits and bytes?

1 bytes = 8 bit

6.while loop basic structure?

while 空格 循环条件 冒号
缩进 循环体
else 空格 冒号
缩进 循环体

7. Use the while statement to write guess the size of the game:

An ideal setting numbers such as: 66, allowing users to enter a number, if larger than 66, the results show a big guess; if less than 66, the results show a small speculation; only equal to 66, show the correct guesses, then exit the loop.

num = 66
while 1:
    num_input = int(input("请输入数字:"))
    if num_input > num :
        print("猜大了!")
    elif num_input < num :
        print("猜小了!")
    else :
        print("猜对了!")
        break

8. 7 upgrade questions on the basis of:

Three guesses to the user, if within three guesses right, the guess is displayed correctly, exit the loop, if not three times within the correct guess, automatically exit the loop and show 'dumb you ....'.

num = 66
count = 3
while count:
    num_input = int(input("请输入数字:"))
    count -= 1
    if num_input > num :
        print("猜大了!")
    elif num_input < num :
        print("猜小了!")
    else :
        print("猜对了!")
        break
else :
    print("太笨了你....")

9. The while loop output 1234568910

count = 0
while count < 10:
    count += 1
    if count == 7:
        continue
    else:
        print(count)

10. All the numbers 1-100 and seek

count = 1
num = 0
while count<= 100:
    num +=count
    count+= 1
print(num)

11. The output of all the odd 1-100

count = 1
while count <= 100:
    if count % 2 == 1:
        print(count)
    count += 1

12. The outputs of all even 1-100

count = 1
while count <= 100:
    if count % 2 == 0:
        print(count)
    count += 1

13. The number of all requirements + 1-2 + 3-4 and 5 ... 99

count = 1
num = 0
while count <= 99:
    if count % 2 == 1:
        num += count
    else:
        num -= count
    count += 1
print(num)

14. Using the user login (unsuccessful attempts to enter the opportunity) and each output error is displayed when the remaining number of errors (Hint: Use string formatting)

count = 3
user = "zcy"
pwd = "122"
while count:
    user_input = input("请输入用户名:")
    pwd_input = input("请输入密码:")
    if user_input == str(user) and pwd_input == str(pwd):
        print("登陆成功")
        break
    else:
        count -= 1
        print("密码还剩%s次"%(count))

Guess you like

Origin www.cnblogs.com/zhangchaoyin/p/11140411.html