Any2Quiz
CBSE / 7 / Computer Science / Programming

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 free

Sample questions

  1. What does the print() function do in Python?

    1. Displays output to the console
    2. Accepts user input
    3. Ends the program
    4. 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.

  2. What does 'def' keyword do in Python?

    1. Defines a function
    2. Declares a variable
    3. Starts a loop
    4. Creates a class
    Show answer

    Answer: A. Defines a function

    The 'def' keyword is used to define a function in Python.

  3. What is the correct syntax to create a function in Python?

    1. function myFunction():
    2. def myFunction():
    3. create myFunction():
    4. 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.

  4. Which of the following keywords is used to handle exceptions in Python?

    1. try
    2. catch
    3. throw
    4. finally
    Show answer

    Answer: A. try

    The 'try' keyword is used to start a block of code to be tested for errors.

  5. What is the purpose of the 'return' statement in a function?

    1. To stop function execution
    2. To provide output to the calling code
    3. To create a variable
    4. 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.

Take the full quiz

More quizzes

Browse all Programming quizzes