How do you access an element in a Python list by its index?
element(index)list.get(index)list[index]get.element(index)
What is the primary purpose of the elif statement in Python?
- To handle exceptions
- To create a loop
- To check multiple conditions in sequence
- To end the program
Step through this pseudocode. What will be output?
What is the result of the expression print("5" + "3") in Python?
What does the modulus operator % do in Python?
- Returns the quotient of a division
- Multiplies two numbers
- Returns the remainder of a division
- Raises a number to a power
Which of the following best describes the purpose of iteration in programming?
- To execute a block of code only if a condition is true
- To execute instructions in a specific order
- To repeat a set of instructions a certain number of times or until a condition is met
- To create reusable code
Which of the following methods is used to add an element to the end of a Python list?
add()insert()append()extend()
What is the difference between = and == in Python?
- Both are used for assignment
- = is a comparison operator, and == is used for assignment
- = is used for assignment, and == is a comparison operator
- There is no difference; they are interchangeable
Which data type is used to store whole numbers in Python?
What does the len() function do in Python?
- Returns the logarithm of a number
- Converts a value to lowercase
- Returns the length of a string or list
- Checks if a variable is defined