26 Questions
Which data type is used to store a string of characters in Python?
str
What is the result of $5 ext{ // }2$ in Python?
2
What will be the output of the code 'print('let's test Printing')' in Python?
SyntaxError
Which operator is used for exponentiation in Python?
**
What is the result of $5 ext{ % }2$ in Python?
1
Which data type is used to store an ordered sequence of items in Python?
list
What will be the type of the variable 'age' if it is assigned the value of 'input()' without any conversion in Python?
'str'
What is the type of value returned by the 'input()' function in Python?
'str'
Which data type is used to store a list of key/value pairs in Python?
'dict'
What will be the output of the code 'print('The sum=', 5 + 2)' in Python?
'The sum=', 7
What is the output of the code 'print('Hello'[-1])' in Python?
o
What is the result of the code 'print('abcde'.index('cd'))' in Python?
2
What will be the output of the code 'print('Python'[1:4])' in Python?
yth
How many times does the letter 'e' appear in the string 'experience'?
3
What will be the output of the code 'print('hello'.replace('l', 'L'))' in Python?
heLLo
What is the result of the code 'print('Python'.endswith('on'))' in Python?
True
What will be the output of the following code?
my_list = [1, 2, 3, 4, 5]
print(my_list[1:3])```
[2, 3]
Which of the following best describes the 'append' method for lists in Python?
It adds an item to the end of the list.
What will be the output of the following code?
my_dict = {'a': 1, 'b': 2}
print(my_dict['c'])```
KeyError: 'c'
Which of the following operations can be performed on sets in Python?
Membership testing
What will be the output of the following code?
s1 = {1, 2, 3}
s2 = {3, 4, 5}
print(s1.intersection(s2))```
{3}
What will be the result of applying the 'remove' method on set s1 with an element that does not exist in the set?
ValueError
What will be the output of the following code?
degrees = {'Ahmed': 67, 'Wael': 90, 'Omar': 99, 'Anas': 80}
print(degrees.values())```
[67, 90, 99, 80]
What will be the output of the following code?
degrees = {'Ahmed': 67, 'Wael': 90, 'Omar': 99, 'Anas': 80}
degrees.pop('Wael')
print(degrees)
What will be the result of applying len() function to an empty set?
0
What is the value of my_string if my_string = 'Hello World'[-1:]?
'd'
Test your understanding of Python language fundamentals, OOP characteristics, inheritance, polymorphism, encapsulation, GUI applications, and common Python frameworks. Topics also include variables, data types, and example usage.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free