1. True or false (1 point)
Similar to tuples and lists, a collection can also contain multiple elements of different types, but the elements in the collection are unordered, identical elements are not allowed, and the elements must be hashable objects.
- correct
- mistake
Correct answer: correct
2. True or false (1 point)
Default parameters in functions cannot pass actual parameters.
- correct
- mistake
Correct Answer: False
3. Multiple choice questions (1 point)
Given that s="Python language programming", the output of print(s[2:4]) is ().
- A yt
- B th
- Cytho
- D tuna
Correct answer: B
4. True or false (1 point)
Comments participate in the actual running of the program
- correct
- mistake
Correct Answer: False
5. Multiple choice questions (1 point)
Third-party libraries in the Python language can be installed with
- In Conda
- B python
- C pup
- D print
Correct answer: A
6. True or false (1 point)
The random() function in the random module can only generate random integers
- correct
- mistake
Correct Answer: False
7. Multiple choice questions (1 point)
The output of the following program is: s1 = "kangaroo" print("{0} lives in a small group consisting mainly of female {0} and young {0}.".format(s1))
- A TypeError: tuple index out of range
- B {0} lives in a smaller group consisting mainly of mother {0} and younger {0}.
- C IndexError: tuple index out of range
- D Kangaroos live in smaller groups consisting mainly of female kangaroos and wallabies.
Correct answer: D
8. True or false (1 point)
The Python language reflects the logical relationship between each statement through indentation
- correct
- mistake
Correct answer: correct
9. True or False (1 point)
When a function parameter is defined as *args, **kwargs means accepting any parameter.
- correct
- mistake
Correct answer: correct
10. Multiple choice questions (1 point)
import time def first_test(func): def wrapper(*args,**kwargs): print('start') func(*args,**kwargs) print('end') return wrapper _____________ def exe(): print( 'Hello!') exe() Define the first_test decorator, and add a decorator to the exe function, the correct one on the horizontal line is ( ).
- A first_test()
- B first_test
- C @first_test
- D @first_test()
Correct answer: C
11. Fill in the blanks (2 points)
a=1 def add(b): global aa=10 print(a+b) add(10) print(a), the output is
——,——。
correct answer:
- Fill in the blank 1 : 20
- Fill in the blank 2 : 10
12. True or false (1 point)
Positional parameters in functions have strict positional relationships.
- correct
- mistake
Correct answer: correct
13. Multiple choice questions (1 point)
# Recursive method def sum_recu(n): if n>0: return n +sum_recu(n-1) else: return 0 sum = sum_recu(100) print(sum)
- A 5000
- B 5050
- C 4500
- D 10000
Correct answer: B
14. True or false (1 point)
A variable is a quantity that can change in value while the program is running.
- correct
- mistake
Correct answer: correct
15. True or false (1 point)
The _init_.py file in the package structure cannot be empty
- correct
- mistake
Correct Answer: False
16. Fill in the blanks (2 points)
Execute the following program, input la, the output result is: ______ la = 'python' try: s = eval(input('Please enter an integer:')) ls = s*2 print(ls) except: print('Please enter an integer ')
correct answer:
- Fill in the blank 1: pythonpython
17. Multiple choice questions (1 point)
Options that are not part of Python's strengths
- A cross-platform
- B object-oriented
- C rich library
- D force indentation
Correct answer: D
18. Multiple choice questions (1 point)
Which of the following is not a computer language
- A natural language
- B machine language
- C assembly language
- D high-level language
Correct answer: A
19. Multiple choice questions (1 point)
After executing the Python statement "name, age='Zhang San', 20", the following statement is correct ().
- The value of A name is "Zhang San", the value of age is 20, and the types of the two variables are uncertain.
- Program B reports an error because the two variables are not defined and cannot be assigned directly.
- C defines two variables, name is a string type, the value is "Zhang San", age is an integer type, and the value is 20.
- D cannot assign values to two variables at the same time, and the program reports an error.
Correct answer: C
20. True or false (1 point)
Given that x,y=4,5, the result of x^y is 4.
- correct
- mistake
Correct Answer: False
21. True or false (1 point)
The time tuple struct_time contains multiple elements, where tm_year represents the year.
- correct
- mistake
Correct answer: correct
22. True or false (1 point)
str = "runoob.com" , the expression str.isalpha() evaluates to True.
- correct
- mistake
Correct Answer: False
23. Fill in the blanks (2 points)
Programming language includes ____ type language and ____ type language
Correct Answer: Can answer in random order
- Fill in the blank 1: compile
- Fill in the blank 2: explain
24. Multiple choice questions (1 point)
The output of the following program is: chs = "|'-'|" for ch in chs: print(ch,end='')
- A made an error
- B |-|
- C "|'-'|"
- D |'-'|
Correct answer: D
25. Multiple choice questions (1 point)
Which of the following statements about packages is wrong ( ).
- A package can be imported using the import statement
- The B package must contain the _init_.py file
- C modules with similar functions can be placed in the same package
- D packages cannot be imported using the from...import... method.
Correct answer: D
26. True or false (1 point)
1<<6 has a value of 32.
- correct
- mistake
Correct Answer: False
27. True or false (1 point)
Use "@" for single-line comments in Python language
- correct
- mistake
Correct Answer: False
28. True or false (1 point)
In the Python language, for codes at the same level, the same indentation method must be used
- correct
- mistake
Correct answer: correct
29. Multiple choice questions (1 point)
After the following statement is executed, the values of a, b, and c are: a = “watermelon” b = “strawberry” c = “cherry” if a > b: c = aa = bb = c
- A watermelon strawberry cherry
- B watermelon cherry strawberry
- C strawberry cherry watermelon
- D strawberry watermelon watermelon
Correct answer: D
30. Fill in the blanks (2 points)
Execute the following program, input qp, the output result is: 2 k = 0 while True: s = input('Please enter q to exit:') if s == 'q': k += 1 continue else: k += 2 break print(k)
Score for this question: 2 points
correct answer:
- Fill in the blank 1 : 2
31. True or false (1 point)
The count() method is used to count the number of occurrences of a character in a string.
Correct answer: correct
32. True or false (1 point)
The Python language is an interpreted language
Correct answer: correct
33. Multiple choice questions (1 point)
print( "python",3.7,sep=',') the output is
- A python 3.7
- B python3.7
- Python C, 3.7
- D python ; 3.7
Correct answer: C
34. Multiple choice questions (1 point)
Which of the following statements is wrong
- A monkey patch is mainly used to dynamically replace existing code without modifying existing code.
- B Using the decorator, it is not possible to inject code into the existing function to make it have new functions.
- C functions are also objects in python.
- D functions can be passed as arguments to other functions.
Correct answer: B
35. Multiple choice questions (1 point)
What symbol is used in a Python statement to display a statement in multiple lines?
- A *
- B ¥
- C /
- D &
Correct answer: C
36. Multiple choice questions (1 point)
The extension of the Python file
- At .py
- B .c
- C .txt
- D.java
Correct answer: A
37. Multiple choice questions (1 point)
What is the return value of the input() function?
- A int
- B string
- C float
- D not sure
Correct answer: B
38. Multiple choice questions (1 point)
The output of the following code is () a = [5,1,3,4]; print(sorted(a,reverse = True))
- A [5, 1, 3, 4]
- B [5, 4, 3, 1]
- C [4, 3, 1, 5]
- D [1, 3, 4, 5]
Correct answer: B
39. True or false (1 point)
The expression 'apple.peach,banana,pear'.find('p') evaluates to 1.
Correct answer: correct
40. Fill in the blanks (2 points)
Read the following code, a = "alex" b = a.capitalize() print(a, b) Write out the execution result: alex Alex
correct answer:
- Fill in the blank 1 : alex Alex
41. True or false (1 point)
The find() method detects whether the string contains a substring str. If it contains a substring, it returns the starting index value, otherwise an exception will be reported.
Correct Answer: False
42. Multiple choice questions (1 point)
The function that removes the spaces on the left and right of the string at the same time is ( )
- A center()
- B count()
- C fomat()
- D strip()
Correct answer: D
43. True or false (1 point)
The input function receives screen input data and returns an integer type
Correct Answer: False
44. Multiple choice questions (1 point)
str1, str2 = 'abc', 'abc ; a, b=(1,2,3), (1,2,3), then the values of str1 is str2 and a is b are ().
- A True True
- B False True
- C False False
- D True False
Correct answer: D
45. Multiple choice questions (1 point)
If the "unexpected indent" error occurs when the Python program is executed, the reason is ().
- There is an indentation mismatch problem in the A code
- Missing ":" symbol in B code
- There are too many nested levels of statements in the C code
- Incorrect keyword used in D code
Correct answer: A