WorksheetsPython Programming Quiz
Total questions: 31
Worksheet time: 18mins
What symbol can be used in a variable name in Python?
_
&
$
#
Which of the following is a valid integer in Python?
10
3.14
'True'
1.5
What function is used to determine the data type of a variable?
check_type()
type()
data_type()
var_type()
How do you convert a value to a string in Python?
str(value)
to_str(value)
string(value)
convert_to_str(value)
Which operator is used for floor division in Python?
//
**
%
/
What does the len() function do?
Returns the length of a variable
Converts to a list
Counts elements
Finds the maximum value
How do you access the first element of a string in Python?
string.get(0)
string.first()
string[0]
string[1]
What does the str.upper() method do?
Removes spaces
Counts characters
Converts string to lowercase
Converts string to uppercase
Which method checks if a string starts with a specific substring?
str.startsWith()
str.first()
str.begin()
str.startswith()
What does the list.append() method do?
Adds an element at the middle of the list
Sorts the list
Adds an element at the start of the list
Adds an element at the end of the list
Which of the following is a valid way to create a list in Python?
list = (1, 2, 3)
list = <1, 2, 3>
list = [1, 2, 3]
list = {1, 2, 3}
What does the set.add() method do?
Counts elements in the set
Adds an element to the set
Clears the set
Removes an element from the set
Which of the following is true about sets in Python?
They allow duplicate values
They can be indexed
They are unordered
They can be sliced
What is the purpose of the break statement in loops?
To continue to the next iteration
To skip the current iteration
To stop the loop
To restart the loop
Which operator is used to check if one condition is true and another is also true?
Or
And
Xor
Not
What does the list.sort() method do?
Clears the list
Sorts the list in ascending order
Reverses the list
Counts elements in the list
How do you remove an element from a list by its value?
list.remove(value)
list.delete(value)
list.pop(value)
list.clear(value)
What does the str.split() method do?
Counts characters
Splits a string into a list
Joins strings
Replaces substrings
Which of the following is a valid way to create a set in Python?
set = <1, 2, 3>
set = (1, 2, 3)
set = {1, 2, 3}
set = [1, 2, 3]
What does the intersection() method in sets do?
Removes elements from the set
Adds elements to the set
Gets common values between two sets
Counts elements in the set
Which of the following is a valid way to take user input in Python?
input('Enter your name: ')
get_input('Enter your name: ')
read_input('Enter your name: ')
user_input('Enter your name: ')
What does the list.extend() method do?
Adds multiple elements from another list
Removes all elements
Sorts the list
Adds a single element
Which of the following is NOT a valid data type in Python?
Integer
Float
Character
Boolean
What does the str.replace() method do?
Counts occurrences of a substring
Replaces all occurrences of a substring
Removes spaces
Converts to uppercase
What is the output of the expression 5 % 2?
3
2
1
2.5
Which of the following is used to create a loop that iterates a specific number of times?
while loop
repeat loop
for loop
do-while loop
What does the str.strip() method do?
Converts to lowercase
Removes leading and trailing spaces
Removes all characters
Counts characters
Which of the following is a valid way to define a variable in Python?
var = 10
var == '10'
10 = var
var: int = 10
What does the list.pop() method do?
Removes an element by value
Clears the list
Removes an element by index
Removes the last element
Which of the following is a valid way to create a float in Python?
float = 5,0
float = '5.0'
float = 5.0
float = 5
At the end Draw something within 3 minutes

