0% found this document useful (0 votes)
1 views6 pages

24-25 Êõ Î Ëpython Programming

This document is a Python programming examination paper with a total duration of 100 minutes. It consists of three parts: single-choice questions, true/false questions, and programming questions, totaling 100 points. The paper assesses knowledge on Python syntax, functions, loops, and basic programming concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views6 pages

24-25 Êõ Î Ëpython Programming

This document is a Python programming examination paper with a total duration of 100 minutes. It consists of three parts: single-choice questions, true/false questions, and programming questions, totaling 100 points. The paper assesses knowledge on Python syntax, functions, loops, and basic programming concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Python Programming Examination Paper

Test duration: 100 minutes

Department: Major: Class:


Name: Student ID: Email:
Teacher: Mrs.GAO Email: [email protected]

Question Part I Part II Part III Total Score


Score 60 20 20 100
Score

Part I: Single-choice questions (30 questions, 60 points)


1.Python reflects the logical relationship between statements through ( ).(2.0)
A. {}
B. ()
C. Indentation
D. Automatic recognition

2.String literals in Python must be enclosed in ( ).(2.0)


A. ()
B. ‘ ’
C. “ ”
D. ‘ ’ or “ ”

3.The symbol representing the start of a comment in Python is ( ).(2.0)


A. &
B. *
C. $
D. #

4.The operator for integer division in Python is ( ).(2.0)


A. //
B. %
C. **
D. /

5.Which of the following built-in functions can be used to convert an integer to a float?(2.0)
A. int_to_float()
B. float()
C. convert()
D. int()
6.( ) refers to a numerical name that remains unchanged during program execution.(2.0)
A. Named text
B. Named constant
C. Variable signature
D. Keyword

7. The value of a ( ) expression is either True or False.(2.0)


A. Binary
B. Selection
C. Unconditional
D. Boolean

8.and, or, and not are all ( ) operators.(2.0)


A. Relational
B. Logical
C. Arithmetic
D. Conditional

9.The symbol > is a ( ) operator.(2.0)


A. Relational
B. Logical
C. Arithmetic
D. Conditional

10.( ) structure tests a condition and chooses one execution path when the condition is true and
another when it is false.(2.0)
A. if
B. Single-branch selection
C. Double-branch selection
D. Sequential

11.A double-branch selection structure can be written using a ( ) statement.(2.0)


A. if
B. if-then
C. if-else
D. if-call

12.A compound Boolean expression created with the ( ) operator is true only if both
sub-expressions are true.(2.0)
A. and
B. or
C. not
D. All of the above
13.A compound Boolean expression created with the ( ) operator is true if at least one of the
sub-expressions is true.(2.0)
A. and
B. or
C. not
D. All of the above

14.The ( ) operator takes a Boolean expression as an operand and flips its logical value.(2.0)
A. and
B. or
C. not
D. All of the above

15.Which of the following built-in functions is used to read input typed from the keyboard?(2.0)
A. input()
B. get()
C. print()
D. read()

16.The operator for calculating powers is ( ).(2.0)


A. *
B. %
C. **
D. //

17.A loop controlled by ( ) uses a true/false condition to control the number of repetitions.(2.0)
A. Boolean
B. Conditional
C. Decision
D. Count

18.A loop controlled by ( ) repeats a specified number of times.(2.0)


A. Boolean
B. Conditional
C. Decision
D. Count

19.Each repetition of a loop is called an ( ).(2.0)


A. Cycle
B. Rotation
C. Circle
D. Iteration
20.The while loop is a ( ) type of loop.(2.0)
A. Pre-test
B. No-test
C. Pre-review
D. Post-iteration

21.A ( ) loop cannot stop until the program is interrupted by the system.(2.0)
A. Uncertain
B. Endless
C. Infinite
D. Eternal

22.What is the role of break?(2.0)


A. Jumps out of the current block based on indentation.
B. Jumps out of all blocks except function indentation.
C. Jumps out of the current for/while loop.
D. Jumps out of all for/while loops.

23.The part of a program that uses a function is called the ( ).(2.0)


A. User
B. Caller
C. Callee
D. Statement

24.The beginning of a Python function definition is ( ).(2.0)


A. def
B. define
C. fun
D. function

25.A function can use a ( ) statement to return a value to the caller.(2.0)


A. print
B. return
C. assignment
D. back

26.Which of the following statements about Python functions is correct?(2.0)


A. Reserved words can be used as function names.
B. When calling a function with default parameter values, you cannot pass any value to the
default parameters; you must use the defaults.
C. Variables defined inside a function cannot be accessed by the caller.
D. Each function must have at least one return statement.
27.Which of the following statements about Python functions is incorrect?(2.0)
A. Function definitions do not have to be placed before function calls.
B. When there is a main function in the code, the program will start executing from main.
C. Functions can have no return value.
D. Variables defined inside a function cannot be accessed outside the function.

28. To make the program run normally and output "hi there", which option should be selected?
(2.0)
first = "hi"
second = ( )
total = first + second
print(total)
A. there
B. " there"
C. str(there)
D. 'there'

29.Which option can make the code output 8?(2.0)


x=4
()
print(x)
A. x = x * 2.0
B. x -= x
C. x += x
D. x = x ** 2

30.If you want the statement print('/usr', 'share', 'doc') to output /usr/share/doc, which
parameter should be set in the print function?(2.0)
A. sep = '/'
B. end = '/'
C. file = '/'
D. flush = '/'

Part II: True/false questions(10 questions, 20 points)


31.Variable names allow spaces inside. ( )(2.0) False

32.The first character of a variable name cannot be a number. ( )(2.0) True

33.A selection structure can be nested within another selection structure. ( )(2.0) True
Answer: True

34.Program input refers only to user input from the keyboard. ( )(2.0) False
35.Program output refers only to display on the monitor. ( )(2.0) False

36.A condition-controlled loop always repeats a specified number of times. ( )(2.0) false

37.The while loop is a pre-test loop. ( )(2.0) True

38.In a nested loop, each iteration of the outer loop completes all iterations of the inner loop. ( ) True
(2.0)

39.To calculate the total number of iterations of a nested loop, you can add the number of
False
iterations of each layer of the loop. ( )(2.0)

40.Calling a function is the same as defining a function. ( )(2.0) False

Part III: Programming questions (2 questions, 20 points)


41.Given list a = [1,3,4,7,8,10] and list b = [0,2,3,4,5,8,9], insert elements from list a into list b
and keep list b sorted.(10.0)
a = [1, 3, 4, 7, 8, 10]
b = [0, 2, 3, 4, 5, 8, 9]

b.extend(a) # Add all elements from a to b


b.sort() # Sort b

print(b)

42.Write a number guessing game where your program randomly generates an integer between 1
and 50. Let the user input their guess, provide hints ("too big", "too small", or "correct"), and
continue guessing until the user guesses correctly.(10.0)
Hint: The following code can generate a random integer between 1 and 50:
import random import random

num = random.randint(1,50) def guessing_game():


num = randomiser.randint(1, 50) # Random number between 1 and 50
guess = None

print("Guess the number between 1 and 50.")

while guess != num:


try:
guess = int(input("Enter your guess: "))

if guess < 1 or guess > 50:


print("Please enter a number within the range 1 to 50.")
continue

if guess > num:


print("Too big!")
elif guess < num:
print("Too small!")
else:
print("Correct! You guessed the number.")
except ValueError:
print("Invalid input. Please enter an integer.")

if __name__ == "__main__":
guessing_game()

You might also like