Programming in Python Quiz - CBSE Class 7 Computer Science
Free practice quiz: Programming in Python (CBSE Class 7 Computer Science). 20 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 20 questions freeSample questions
What does the print() function do in Python?
- Displays output to the console
- Accepts user input
- Ends the program
- Creates a new variable
Show answer
Answer: A. Displays output to the console
The print() function is used to display output on the console in Python.
What does 'def' keyword do in Python?
- Defines a function
- Declares a variable
- Starts a loop
- Creates a class
Show answer
Answer: A. Defines a function
The 'def' keyword is used to define a function in Python.
What is the correct syntax to create a function in Python?
- function myFunction():
- def myFunction():
- create myFunction():
- myFunction().def:
Show answer
Answer: B. def myFunction():
The correct syntax to define a function in Python starts with the keyword 'def' followed by the function name and parentheses.
Which of the following keywords is used to handle exceptions in Python?
- try
- catch
- throw
- finally
Show answer
Answer: A. try
The 'try' keyword is used to start a block of code to be tested for errors.
What is the purpose of the 'return' statement in a function?
- To stop function execution
- To provide output to the calling code
- To create a variable
- To define a function
Show answer
Answer: B. To provide output to the calling code
The 'return' statement is used to send a result back to the caller of the function.