0% found this document useful (0 votes)
28 views4 pages

Final Exam 2023, V2

The document outlines the final examination for Programming Principles II at the School of Information Technology and Engineering for Fall Semester 2023, consisting of multiple-choice questions covering Python programming, regex patterns, and Pygame functionalities. It includes questions about arithmetic operators, Python functions, and specific Pygame modules and methods. The document also lists the instructors and meeting minutes related to the examination.

Uploaded by

nuriaalfa2003
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)
28 views4 pages

Final Exam 2023, V2

The document outlines the final examination for Programming Principles II at the School of Information Technology and Engineering for Fall Semester 2023, consisting of multiple-choice questions covering Python programming, regex patterns, and Pygame functionalities. It includes questions about arithmetic operators, Python functions, and specific Pygame modules and methods. The document also lists the instructors and meeting minutes related to the examination.

Uploaded by

nuriaalfa2003
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/ 4

School of Information Technology and Engineering

Fall Semester 2023: Final Examination


Duration: 60 minutes (1 hour)
Discipline: Programming Principles II
Examination card № 2
1. What arithmetic operators cannot be used with strings ?
a) +
b) *
c) –
d) All of the mentioned
2. What will be the output of the following Python code snippet ?
d = {"john":40, "peter":45}
"john" in d
a) True
b) False
c) None
d) Error
3. What will be the output of the following Python code ?
import random
random.choice([10.4, 56.99, 76])
a) Error
b) Either 10.4, 56.99 or 76
c) Any number other than 10.4, 56.99 and 76
d) 56.99 only
4. What does the function re.search do?
a) matches a pattern at the start of the string
b) matches a pattern at any position in the string
c) such a function does not exist
d) none of the mentioned
5. What will be the output of the following Python code snippet ?
d = {"john":40, "peter":45}
print(list(d.keys()))
a) ["john", "peter"]
b) ["john": 40, "peter": 45]
c) {"john", "peter"}
d) ("john": 40, "peter": 45)
6. What does the ‘return’ keyword do in a function ?
a) Terminates the function
b) Returns a value from the function
c) Skips the function
d) Declares a variable
7. What will be the output of the following code snippet ?
def multiply(a, b=2):
return a * b
result = multiply(5)
print(result)
a) 5
b) 10
c) 2
d) 7

8. What is a lambda function in Python?


a) A function that returns multiple values
b) A function that can accept a variable number of arguments
c) An anonymous function defined using the keyword ‘lambda’
d) A function that can call itself

9. What does the filter() function do with a lambda function as its first argument?
a) Filters out elements from an iterable based on the lambda function’s result
b) Adds elements to an iterable based on the lambda function's result
c) Sorts elements in an iterable based on the lambda function's result
d) Reverses elements in an iterable based on the lambda function’s result

10. What is the output of the following code snippet ?


my_function = lambda x: "even" if x % 2 == 0 else "odd"
print(my_function(7))
a) «even»
b) «odd»
c) True
d) False

11. What does the character '^' represent in a regex pattern in Python ?
a) Matches the end of a string
b) Matches the start of a string
c) Matches any character except newline
d) Matches zero or one occurrence of the preceding element

12. Which of the following regex patterns will match either "cat" or "dog" in Python ?
a) (cat|dog)
b) [catdog]
c) cat*dog
d) cat&dog

13. In Python regex, what does the character '.' represent?


a) Matches any character except newline
b) Matches zero or one occurrence of the preceding element
c) Matches the start of a string
d) Matches a literal period character

14. What does the regex pattern \w+ match in Python?


a) Matches a literal 'w' character followed by a plus sign
b) Matches one or more word characters
c) Matches whitespace characters
d) Matches any character except word characters

15. In Python regex, what does the expression \s represent?


a) Match any character except whitespace
b) Match a literal 's' character
c) Match any whitespace character
d) Start of a string

16. What does the character '|' represent in a regex pattern in Python?
a) Matches the start of a string
b) Logical OR, matches either the pattern on the left or the one on the right
c) Matches any digit character
d) Matches one or more occurrences of the preceding element

17. What does the '?' symbol indicate in a regex pattern in Python?
a) Matches zero or more occurrences of the preceding element
b) Matches one or zero occurrences of the preceding element
c) Matches exactly one occurrence of the preceding element
d) Matches one or more occurrences of the preceding element

18. Which of the following regex patterns will match a phone number with an optional country code in Python?
a) \d{10}
b) \d{1,3}-\d{3}-\d{4}
c) \+?\d{1,3}-\d{3}-\d{4}
d) (\d{3}-){2}\d{4}

19. Which module in Pygame is used for handling keyboard input?


a) pygame.draw
b) pygame.event
c) pygame.image
d) pygame.sound

20. In Pygame, what does pygame.display.set_mode() do?


a) Sets the screen resolution
b) Creates a game window
c) Initializes the game loop
d) Loads an image

21. What is the purpose of the pygame.time.Clock object?


a) Handling user input
b) Managing game objects
c) Controlling the frame rate
d) Loading images

22. What function is used to draw a rectangle in Pygame?


a) pygame.rect()
b) pygame.draw.rect()
c) pygame.draw.rectangle()
d) pygame.draw_square()

23. Which event is triggered when the close button of the window is clicked?
a) pygame.QUIT
b) pygame.CLOSE
c) pygame.EXIT
d) pygame.CLOSE_WINDOW

24. How do you play a sound file in Pygame?


a) pygame.play_sound()
b) pygame.sound.play()
c) pygame.mixer.play()
d) pygame.audio.play()

25. How do you rotate an image in Pygame?


a) pygame.rotate()
b) pygame.image.rotate()
c) pygame.transform.rotate()
d) pygame.rotate_image()
Instructor Kelgenbayev Arnur

Dean of School of IT and Engineering Azamat Z. Imanbayev

Deputy Dean of School of IT and Engineering Rashida T. Nizamdianova

Minutes #29 of School of Information Technology and Engineering meeting December 01, 2023

You might also like