Module 1_ Basics of Python - 1.1 Basics of Python

Walk into Python quiz

1、单选题:
‎Which of the following expressions is False?‍
选项:
A: (3 is 4) == 0
B: 'abc' < 'ABC'
C: 9 < 1 and 10 < 9 or 2 > 1
D: 8 > 4 > 2
答案: 【 'abc' < 'ABC'

2、单选题:
‏Which of the following statements can NOT print the string “hello world” (the print result must be in the same line)?​
选项:
A: print('''hello 
        world''')
B: print('hello world')
C: print("hello world")
D: print('hello 
        world')
答案: 【 print('''hello 
        world''')

3、单选题:
​Which of the following statements about Python is false?‏
选项:
A: One variable name can be assigned with different types and numerical values at different positions in Python. 
B: In Python, there is no need to explicitly declare the type of variable, yet to be determined by the "value". 
C: Python supports chained assignment and multiple assignment.
D: Upper or lower case is not sensitive in Python assignment.
答案: 【 Upper or lower case is not sensitive in Python assignment.

4、单选题:
‌Which of the following types will the Python function input() return?​
选项:
A: int
B: str
C: list
D: dict
答案: 【 str

5、单选题:
‍Which of the following statements about module is false?‎
选项:
A: A complete Python file forms a module, an extension to enhance Python capability.
B: Functions in a module can be used in the form of "module.function" after the module is imported using the "import" clause.
C: Variables can be used to refer to functions. For example, by assigning "math.sqrt" to "bar", "bar" can used to calculate the square root. An example will be that bar(9) equals to 3.0.
D: Python doesn't support import multiple modules at a time yet.
答案: 【 Python doesn't support import multiple modules at a time yet.

6、多选题:
‌To view the value of "pi" in the library "math", which of the following means can ‎‌be resorted to (suppose that "import math" has been executed)?‎‌‎
选项:
A: help(math)
B: print(pi)
C: dir(math)
D: print(math.pi)
答案: 【 help(math);
print(math.pi)

7、多选题:
‍Which of the followings are not keywords in Python?​
选项:
A: as
B: list
C: from
D: dict
答案: 【 list;
dict

8、多选题:
​Which of the following statements produce 3 or 3.0?‌
选项:
A: 1/2+2.5
B: 9//2-1.5
C: ord('D')-ord('A')
D: 35%10
答案: 【 1/2+2.5;
ord('D')-ord('A')

9、判断题:
‏Please decide whether the following statements are true or false. ‎‏Python can be run and executed in Shell, and can also be saved into a text file whose extension is .py to be executed in the Python interpreter.‎
选项:
A: 正确
B: 错误
答案: 【 正确

10、判断题:
‎To import the function "sqrt" from the module "math", you may use the statement "from sqrt import math".‏‎‏
选项:
A: 正确
B: 错误
答案: 【 错误

Module 1_ Basics of Python - 1.2 Multi-dimensional View of Python

Multi-dimensional View of Python quiz

1、单选题:
‎If k is integer, how many times will the following "while" loop be executed?‎‎k = 50 
while k > 1: 
    print(k) 
    k = k // 2‎
选项:
A: 3
B: 4
C: 5
D: 6
答案: 【 5

2、单选题:
‍Which of the following code snippets can print “rest apples are less than 9”once and only once?‍
选项:
A: apples = 100
while True:
    if apples < 9:
        break
        print("rest apples are less than 9")
    apples -= 9
B: apples = 100
while True:
    if apples < 9:
        continue
        print("rest apples are less than 9")
    apples -= 9
C: apples = 100
while apples >= 1:
    if apples < 9:
        print("rest apples are less than 9")
        break
    apples -= 9
D: apples = 100
for a in reversed(range(apples)):
    if a < 9:
        print("rest apples are less than 9")
        continue
        apples -= 9
答案: 【 apples = 100
while apples >= 1:
    if apples < 9:
        print("rest apples are less than 9")
        break
    apples -= 9

3、单选题:
‍Regarding the function below:‌‍def location(city, province):
    print('%s belongs to %s province' % (city, province))Which of the following statement has a different result comparing with others?‌‍‌
选项:
A: location('Jiangsu', 'Nanjing')
B: location(province = 'Jiangsu', city = 'Nanjing')
C: location(city = 'Nanjing', province = 'Jiangsu')
D: location('Nanjing', 'Jiangsu')
答案: 【 location('Jiangsu', 'Nanjing')

4、单选题:
‏Define a function as below with f as the function parameter,‍‏def test(f, a, b): 
    print(f(a, b))‍‏Which of the following options will be the result of test((lambda x,y: x ** 3 + y), 2, 3)?‍‏‍
选项:
A: 8
B: 9
C: 10
D: 11
答案: 【 11

5、单选题:
‌Define a function as below:  ‍‌def my_power(x, n = 2):
    s = 1
    while n > 0:
        n -= 1
        s = s * x
    return sWhat's the result of passing my_power(-3) and my_power(3, 3) respectively?‍‌‍
选项:
A: 9 and 27
B: -9 and 27
C: 9 and -27
D: -9 and -27
答案: 【 9 and 27

6、单选题:
‍Which of the following is correct about the program below?‌‍def f(x):
     a = 7
     print(a + x)
a = 5
f(3)
print(a)‌
选项:
A: The result of the program is 10 and 5.
B: The result of the program is 10 and 7.
C: The result of the program is 8 and 5. 
D: The program cannot be executed normally.
答案: 【 The result of the program is 10 and 5.

7、单选题:
​What kind of exception will be generated when executing the following code snippet?‏​>>> a = 3
>>> print(a ** b)‏
选项:
A: IndexError
B: ValueError
C: NameError
D: TypeError
答案: 【 NameError

8、单选题:
​If the code snippet always generates a random number in [0, 1.0 ), what's the possible function from library random used here?‎​>>> import random
>>> random.______()‎
选项:
A: randint
B: random
C: uniform
D: shuffle
答案: 【 random

9、多选题:
​Which of the following statements about the flow control of Python functions are correct?‏
选项:
A: Boolean operators have a very interesting short-circuit logic behavior: for an expression "x and y", when "x" is false, it directly returns "False", without calculating the value of "y". 
B: One of the characteristics of an "if" statement is: it makes judgment from top to bottom, and if one judgment is True, the statement corresponding to that judgment will be executed, ignoring the remaining "elif" and "else".
C: In "while" and "for" loops, a "continue" statement serves to stop the current loop and continues to enter the statement(s) below the loop body.
D: In "while" and "for" loops, a "break" statement serves to end the current loop and re-starts the loop.
答案: 【 Boolean operators have a very interesting short-circuit logic behavior: for an expression "x and y", when "x" is false, it directly returns "False", without calculating the value of "y". ;
One of the characteristics of an "if" statement is: it makes judgment from top to bottom, and if one judgment is True, the statement corresponding to that judgment will be executed, ignoring the remaining "elif" and "else".

10、多选题:
‍Which of the following statements about the flow control of Python functions are correct?‏
选项:
A: As Boolean expressions, the values of None, 0, [] and {} would be regarded as "False" by the interpreter.
B: Standard Boolean values are 0 (representing False) and 1 (representing True); in fact, the result of the statement True==1 is True.
C: Comparisons of incompatible types, like integers and strings, is meaningless in mathematics. It is no longer supported in Python 3.x.
D: When "is" is a comparison operator, the meaning of "x is y" is to compare whether "x" is a sub-class of "y".
答案: 【 As Boolean expressions, the values of None, 0, [] and {} would be regarded as "False" by the interpreter.;
Standard Boolean values are 0 (representing False) and 1 (representing True); in fact, the result of the statement True==1 is True.;
Comparisons of incompatible types, like integers and strings, is meaningless in mathematics. It is no longer supported in Python 3.x.

11、判断题:
‍Please decide whether the following statements are true or false​‍An “if” statement  must be indented, by 4 spaces.​‍​
选项:
A: 正确
B: 错误
答案: 【 错误

12、填空题:
‎What’s the result of the following program?​‎s = 0
for i in range(1, 11):
     if i % 2 == 0:
        continue
     if i % 10 == 5:
        break
     s = s + i
print(s)​
答案: 【 4

Module 2_ Data Acquisition and Presentation

Data Acquisition and Presentation quiz

1、单选题:
​Of the following "open" statements, which one can NOT delete or modify the contents in the

剩余75%内容付费后可查看

发表评论

电子邮件地址不会被公开。 必填项已用*标注