NEW
Font size
WorksheetsPython L1 Knowledge Check
Total questions: 16
Worksheet time: 8mins
What is the purpose of the print() function in Python?
To save data to a file
To read input from the user
To display output on the console
To perform mathematical calculations
What is the purpose of the 'input' function in the code?
To display a message to the user
To store a value in a variable
To get user input from the console
To print the user's name and favorite color
What is the purpose of the 'int()' function in the code?
To convert the input into a string
To convert the input into an integer
To perform an addition operation
To print a message to the user
What is the purpose of a while loop?
To iterate over a sequence such as range
To exit a loop when a condition is met
To convert all the characters in a string to lowercase
To repeat a block of code as long as a specified condition is true
What is commonly used with for loops to iterate a specific number of times?
lower method
while loop
break statement
range
What does the break statement do?
Converts all the characters in a string to lowercase
Repeats a block of code indefinitely
Generates a sequence of numbers
Exits a loop, stopping the loop's execution based on a certain condition being met
What is the lower() method used for?
To generate a sequence of numbers
To convert all the characters in a string to lowercase
To iterate over a sequence such as range
To exit a loop when a condition is met
What is a list in Python?
A function that executes a block of code a specific number of times.
A single variable that is used to store different variable types.
A container where you can put lots of different items in a specific order and change the contents anytime.
A method to perform calculations on multiple variables.
What are the values stored inside a list called?
Elements
Items
Variables
Indices
What does zero-indexed mean in the context of lists?
Lists start counting from 1.
Lists start counting from 0.
Lists can only have zero elements.
Lists cannot have indexes.
Which method is used to add a new item to the end of a list in Python?
.add()
.append()
.insert()
.attach()
Which method is used to remove an item from a list in Python?
delete()
remove()
pop()
discard()
What does the range() function in Python do?
It generates a list of numbers within a specified range.
It finds the maximum number in a list.
It sorts a given list of numbers.
It calculates the sum of numbers in a list.
What is a function in programming?
A command that ends the execution of the code.
A variable used to store data.
A block of reusable code designed to perform a specific task or calculation.
A message displayed to the user.
What keyword is used to define a function in Python?
func
def
define
function
What is the purpose of declaring a variable as 'global' inside a function?
To restrict the variable's access to the function only.
To allow the variable to be accessed and modified from anywhere within the program.
To ensure the variable can only be modified within the function.
To delete the variable after the function's execution is complete.
