Python Quiz - Control Structure

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Priyasadhale
P
Priyasadhale
Community Contributor
Quizzes Created: 1 | Total Attempts: 709
Questions: 7 | Attempts: 709

SettingsSettingsSettings
Programming Quizzes & Trivia

Take the challenge to quickly check your understanding about basic concepts in Python including control structure


Questions and Answers
  • 1. 

    Print() in Python is used for

    • A.

      Print result of operation

    • B.

      Debug the program

    • C.

      To display message to input the data

    • D.

      None of the above

    Correct Answer(s)
    A. Print result of operation
    B. Debug the program
    C. To display message to input the data
    Explanation
    The correct answer is that the print() function in Python is used for printing the result of an operation, debugging the program, and displaying a message to input the data. This function allows us to output text or variables to the console or terminal. It is commonly used for displaying information during the execution of a program, making it easier to understand and debug the code. Additionally, it can be used to prompt the user to input data by displaying a message.

    Rate this question:

  • 2. 

    Python executes program line by line

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Python executes a program line by line, meaning that it executes each line of code in the order it is written. This sequential execution allows for step-by-step processing of the program's instructions, ensuring that each line is executed before moving on to the next. This is a fundamental characteristic of Python and many other programming languages, allowing for control flow and the ability to perform tasks in a specific order.

    Rate this question:

  • 3. 

    "if" is decision making control structure in Python.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The statement is true because "if" is indeed a decision-making control structure in Python. It allows the program to execute a certain block of code only if a specified condition is true. This control structure is essential for implementing conditional logic and making the program more flexible and responsive to different scenarios.

    Rate this question:

  • 4. 

    What is the output of below line print("I want to read the books written by 'Sudha Murthy'")

    • A.

      Syntax error

    • B.

      I want to read the books written by Sudha Murthy

    • C.

      I want to read the books written by 'Sudha Murthy'

    • D.

      No idea

    Correct Answer
    C. I want to read the books written by 'Sudha Murthy'
    Explanation
    The output of the given line will be "I want to read the books written by 'Sudha Murthy'". This is because the print statement will display the text within the double quotes exactly as it is, including the single quotes around 'Sudha Murthy'.

    Rate this question:

  • 5. 

    Guess the output marks = 78 if marks < 0 and marks > 100: print("You can enter marks between 0 to 100")

    • A.

      No output

    • B.

      It will print You can enter marks between 0 to 100

    • C.

      Error: if can not have multiple conditions

    • D.

      TypeError

    Correct Answer
    A. No output
    Explanation
    The correct answer is "no output". This is because the condition in the if statement is not satisfied. The variable "marks" is assigned a value of 78, which is neither less than 0 nor greater than 100. Therefore, the code inside the if statement will not be executed and no output will be printed.

    Rate this question:

  • 6. 

    Convert "Today is SPecial day" in all capital letters

    • A.

      Data = "Today is SPecial day" print(data)  

    • B.

      "Today is SPecial day".lower()

    • C.

      Upper("Today is SPecial day")

    • D.

      "Today is SPecial day".upper()

    Correct Answer
    D. "Today is SPecial day".upper()
    Explanation
    The correct answer is ""Today is SPecial day".upper()". This is because the .upper() method is used to convert a string to all capital letters. In this case, the given string "Today is SPecial day" will be converted to "TODAY IS SPECIAL DAY" when the .upper() method is applied to it.

    Rate this question:

  • 7. 

    ________ is used to accept input from user

    Correct Answer
    print(), input(), both
    Explanation
    Both the print() and input() functions are used to accept input from the user. The print() function is used to display output on the console, while the input() function is used to prompt the user to enter data. Therefore, both functions can be used to interact with the user and accept input in a Python program.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Apr 22, 2020
    Quiz Created by
    Priyasadhale
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.