WorksheetsPython Basics Quiz
Total questions: 25
Worksheet time: 13mins
What is the correct way to assign a value to a variable in Python?
5 = x
assign x to 5
x -> 5
x = 5
Which of the following is true about Python syntax?
Python does not support comments
Python ignores indentation
Python variables must start with a number
Python is case-sensitive
What is the purpose of comments in Python?
To execute code faster
To create variables
To describe code behavior
To store data
Which of the following is a valid Python list?
[1, 2, 3]
{1, 2, 3}
1, 2, 3
(1, 2, 3)
What is the index of the first element in a Python list?
1
None
0
-1
Which method adds a new element to the end of a list?
pop()
insert()
remove()
append()
What does the remove() method do in Python lists?
Removes the last element
Removes a specific value
Removes all elements
Removes elements by index
Which of the following is a string method in Python?
title()
append()
index()
remove()
What does the lower() method do to a string?
Converts all characters to lowercase
Converts all characters to uppercase
Removes spaces
Reverses the string
What is the purpose of a function in Python?
To reuse and organize code
To store data
To create variables
To execute loops
How do you define a function in Python?
Using def
Using func
Using function
Using create
What is the correct way to call a function in Python?
run function_name
function_name()
execute function_name
call function_name
Which of the following is true about Python lists?
Lists can store multiple values
Lists are unordered
Lists cannot contain strings
Lists have fixed length
What is the output of title() method applied to 'hello world'?
World Hello
hello world
HELLO WORLD
Hello World
Which of the following is NOT a valid data type in Python?
float
string
integer
character
What happens when you use the append() method on a list?
A new element is added to the end
The first element is removed
The list is cleared
The list is reversed
What is the correct way to access the last element of a list?
list[len(list)]
list[last]
list[0]
list[-1]
What does the len() function return when applied to a list?
The first element of the list
The last element of the list
The index of the last element
The number of elements in the list
Which of the following is true about Python functions?
They cannot use parameters
They cannot use variables
They must always return a value
They may or may not return a value
What is the correct way to modify an element in a list?
list.change(index, new_value)
list.modify(index, new_value)
list[index] = new_value
list.update(index, new_value)
Which of the following is true about Python lists?
Lists are indexed starting at 0
Lists are indexed starting at 1
Lists are indexed starting at -1
Lists cannot be indexed
What is the output of lower() method applied to 'HELLO'?
hello
HELLO
hELLO
Hello
What is the correct way to retrieve the length of a list?
len(list)
length(list)
list.length()
list.size()
What is the correct way to access the first element of a list?
list[0]
list[-1]
list[1]
list[first]
Which of the following is true about Python syntax?
Indentation is important
Indentation is optional
Python ignores indentation
Python uses braces for indentation
