In Python, how can you convert a string variable num_str to an integer?
int(num_str)convertToInt(num_str)toInteger(num_str)num_str.toInt()
What is the purpose of the input() function in Python?
- Prints a message to the console
- Pauses the program execution
- Accepts user input from the console
- Converts a variable to an integer
What does the len() function in Python do when applied to a string?
- Returns the number of words in the string
- Returns the length of the string
- Converts the string to lowercase
- Checks if the string contains a specific substring
What is a parameter in the context of a Python function?
- A variable used for counting loops
- A keyword used to end a function
- A value passed into the function
- A reserved word indicating the start of a function
Which of the following statements is an example of a selection structure?
for i in range(5):if x > 0:while True:print("Hello, World!")
What is the primary purpose of the while loop in programming?
- To define a subprogram
- To create a block of code that always executes
- To perform a specific action for each item in a collection
- To repeat a block of code as long as a condition is true
What is a list in Python?
- A mathematical operation
- A collection of related data
- A reserved keyword
- A data type
Which data type is used to store a sequence of characters in Python?
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 result of the expression print("5 + 3") in Python?