China Electronics Society May 2023 Youth Software Programming Python Level Examination Paper Level 1 Real Questions (Including Answers)

2023-05 Python Level 1 Real Exam Questions

Score: 100

Number of questions: 37

Test duration: 60min

1. Multiple-choice questions (25 questions in total, 50 points in total)

1. How can I comment multiple lines of Python code? (C)

A.#

B." "

C.''' '''

D.' '

2. Which of the following can be used as Python variable names? (D)

A.and

B. and d

C.1_and

D.and1

3. Which of the following options does not comply with the naming rules of Python language variables? (B)

A.s

B.2_5

C._AI

D.CountNum

4. Use the variable age to represent Xiao Ming’s age, and use the variable sage to represent the age of Xiao Ming’s brother. Assume that when Xiao Ming is 4 years old, his brother’s age is twice that of Xiao Ming. Which of the following pieces of code can correctly calculate the number of Xiao Ming and his brother in 6 years? age? (A)

A.

>>> age=4

>>> sage=4*2

>>> print(age+6,sage+6)

B.

>>> age=4

>>> sage=4*2

>>> print(age,sage+6)

C.

>>> age=4

>>> sage=4*2

>>> print(age+6,sage)

D.

>>> age=4

>>> sage=4*2

>>> print(age,sage)

5. You can use setup() in turtle to set the size and starting position of the canvas. It is known that the setting parameter of the canvas is turtle.setup(120,120,20,20). If you only want to change the height of the canvas to 150, which of the following instructions is correct? (B)

A.turtle.setup(150,120,20,20)

B.turtle.setup(120,150,20,20)

C.turtle.setup(120,120,150,20)

D.turtle.setup(120,120,20,150)

6. Among the following options, what is the extension of the Python program? (D)

A.scratch

B.doc

C. python

D.py

7. Which statement is correct about the statement turtle.color('red','green')? (C)

A. Set the brush color to green.

B. This statement will cause the turtle to move and draw a red line.

C. Set the fill color to green and the brush color to red.

D. The effect is exactly the same as the statement turtle.color('red')

8. There are 45 people in the class. They are divided into study groups in groups of four. Use a program to calculate how many groups are divided into and the number of people remaining in one group is less than one. Which of the following program options can complete this task? (A)

A.

print("A group of 4 people, divided into ",45//4,"group")

print("The number of people remaining in less than one group is: ",45%4)

B.

print("A group of 4 people, divided into ",45%4,"group")

print("The number of people remaining in less than one group is:",45//4)

C.

print("A group of 4 people, divided into ",45/4,"group")

print("The number of people remaining in less than one group is: ",45%4)

D.

print("A group of 4 people, divided into ",45//4,"group")

print("The number of people remaining in less than one group is: ",45/4)

9. Which of the following Python statements can be output correctly? (A)

A.print("Happy every day!")

B.print"(Happy every day!")

C.print "Happy every day!"

D.print("Happy every day!')

10. Which of the following options is incorrect about Python? (B)

A. Python programs can run on both Windows and Linux systems.

B. Programs written in Python can be run in Scratch.

C.Python is an object-oriented programming language

D. The Python language has two versions, Python2 and Python3, which are incompatible with each other.

11. In Python, what does the <= symbol mean? (C)

A. The value on the left is smaller than the value on the right

B. The value on the left is less than and equal to the value on the right

C. The value on the left is less than or equal to the value on the right

D. The value on the left is greater than or equal to the value on the right

12. What is the result of sorting the following operators in order of precedence from high to low? (A)

①**

②/and//

③+ and -

A.①②③

B.③②①

C.②③①

D.①③②

13. Which symbol is used for multiplication in Python? (B)

A.×

B.*

C.**

D.+=

14. How to calculate the remainder of 8 divided by 3 in Python? (A)

A.8%3

B.8//3

C.8?3

D.8\3

15. In Python, which of the following assignment statements is correct? (C)

A.x+y=10

B.x-2=2y

C.x=30

D.3y=x+1

16. In Python, what is the result of running the following program segment? (A)

a=2

b=3

print(a!=b)

A.True

B.False

C.0

D.a!=b

17. Assume a=True, b=False, what is the result of a and b? (B)

A.True

B.False

C.1

D.a=True, b=False

18. Assume a=2, b=3, then what is the result of b * b - 2 * a? (B)

A.3

B.5

C.-3

D.6

19. How many baby turtles can be summoned by the following code? (C)


import turtle

a=turtle.Turtle()

b=turtle.Turtle()

c=turtle.Turtle()



a.forward(100)

b.goto(100,100)

c.goto(100,100)

A.1

B.2

C.3

D.4

20. Regarding the turtle library, which of the following statements is incorrect? (B)

A.turtle.speed() can set the movement speed of the brush

B.turtle.fillcolor() can be used to set the background color of the canvas

C. In turtle drawing, the baby turtle faces the right side of the screen by default.

D.turtle.pencolor() is used to set the color of the brush

21. What kind of shape does turtle.circle(100,360) draw? (B)

A. A circle with a radius of 50

B. A circle with a radius of 100

C. A circle with a radius of 360

D. A circle with a radius of 180

22. After executing the following command, what are the latest coordinates of the turtle? (C)

import turtle

turtle.goto(-200,-200)

turtle.forward(200)

turtle.left(90)

turtle.forward(200)

A.(-200,200)

B.(200,-200)

C.(0,0)

D.(0,200)

23. Which of the following commands rotates 90 degrees counterclockwise? (B)

A.turtle.right(90)

B.turtle.left(90)

C.turtle.goto(0,90)

D.turtle.goto(90,0)

24. In Python programming, you can use the type() function to check the data type and run print(type("a")). What is the output result? (B)

A.<class 'type'>

B.<class'str'>

C.<class 'int'>

D. Grammatical error

25. Among the two different development modes of Python's IDLE, which of the following statements is correct? (D)

A. The results of scripted programming environment are more accurate

B. The interactive programming environment results are more accurate

C. The relevant code programs must be saved before running the interactive programming environment.

D. The relevant code program must be saved before running in the script programming environment.

2. True or False Questions (10 questions in total, 20 points in total)

26. When writing long Python programs, all codes do not need to be indented, Python will automatically recognize the relationship between codes. (wrong)

27. In the Turtle library, turtle.forward(10) refers to the distance the turtle moves forward by 10 pixels in a random direction. (wrong)

28. IDLE and Scratch are both programming tools in the Python language. ( wrong)

29. In Python, if a=2, b=3, then the output result of print(a and b) is False. ( wrong)

30. When using the Turtle library, the fillcolor() function is used to set the fill color. (right)

31. In Python, print() will wrap the line by default after outputting relevant content. ( right)

32. The result of str(10) is '10'. ( right)

33. The running result of 5*'A' is 5A. (wrong)

34. The input() statement is used to enter an instruction. (wrong)

35. For the indentation of Python code, in the same program and at the same level of indentation, two spaces and four spaces cannot be mixed. (right)

3. Programming questions (2 questions in total, 30 points in total)

36. Write a program to draw a Z-shaped figure as shown in Figure 1. The brush width is 20, the starting position is (-50,100), and other size instructions are as shown in Figure 2.

Reference procedure:

import turtle

turtle.penup()

turtle.goto(-50,100)

turtle.pendown()

turtle.pensize(20)

turtle.color('red')

turtle.fd(200)

turtle.right(135)

turtle.color('green')

turtle.fd(280)

turtle.left(135)

turtle.color('blue')

turtle.fd(200)

Grading:

(1) The three line segments have the correct color, 1 point each; (3 points in total)

(2) The rotation angle is correct, 2 points for each angle; (6 points in total)

(3) The length of the line segments is correct, 1 point for each line segment; (3 points in total)

(4) The thickness of the line is correct, 1 point for each line segment; (3 points in total)

(5) The starting position is correct; (1 point in total)

(6) There is an order to raise the pen and put it down. (2 points each, 4 points in total)

37. Calculation of square area and perimeter

Require:

(1) After the program starts running, enter the side length of a square (integer);

(2) The program will output the perimeter and area values ​​corresponding to the square based on the input side length values, and indicate which is the perimeter and which is the area.

Reference procedure:

l=input("请输入正方形的边长:")

l=int(l)

c=4*l

s=l*l

print("正方形周长的值为:",c)

print("正方形面积的值为:",s)

Grading:

(1) There are input sentences; (2 points)

(2) There are data type conversion statements; (2 points)

(3) There are output statements; (2 points)

(4) There are calculation statements; (2 points)

(5) The results of program operation meet the requirements of the question. (2 minutes)

 

Guess you like

Origin blog.csdn.net/m0_46227121/article/details/131135788