Exam | Questions and Answers Rated A+ |
Latest 2025/2026 Guide
What are the characteristics of a set?
- Correct Answer - Unordered, mutable collection of unique elements.
{1,2,3}
what is a dictionary mapping type?
- Correct Answer - an unordered collection of key-value pairs.
my_dict = {'key':'value', 'name':'John'}
What happens when an operation is performed that involves both an int
and a float in Python?
- Correct Answer - the result is automatically promoted to a 'float'
What does the 'round(x, n) function do in Python?
- Correct Answer - it rounds 'x' to 'n' decimal places
What are the two main escape characters?
- Correct Answer - \n : new line
\t : for a tab
, What are the 3 components of a string slice?
- Correct Answer - string [start:stop:step]
· Start: the index from which the slicing begins (inclusive)
· Stop: the index at which the slicing ends (exclusive)
· Step (optional): The step or stride between characters.
What does the string slicing operation 'text {::-1] do where text = "Hello,
Python!"? - Correct Answer - It reverses the string.
The 'step' portion of the slice is negative, indicating the stride between
characters is reversed.
What does the 'strip()' method do in Python?
- Correct Answer - It removes leading and trailing whitespaces from a
string
what does the += operator do in Python string manipulation?
- Correct Answer - It is used as a shorthand for concatenation and
assignment
What are truthy and falsy values in Python?
- Correct Answer - Truthy values are non-zero numbers and non-empty
strings.