Programming: Python Quiz

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 Sherd030
S
Sherd030
Community Contributor
Quizzes Created: 1 | Total Attempts: 4,766
Questions: 17 | Attempts: 4,889

SettingsSettingsSettings
Programming: Python Quiz - Quiz


Questions and Answers
  • 1. 

    Python writes data on screen using which function?

    • A.

      Cout

    • B.

      (display )

    • C.

      Print()

    • D.

      Echo

    • E.

      Console.log()

    • F.

      System.out.println()

    Correct Answer
    C. Print()
    Explanation
    The correct answer is print(). In Python, the print() function is used to write data on the screen. It is a built-in function that allows us to display output to the console. By passing the desired data or variables as arguments to the print() function, we can easily output them to the screen.

    Rate this question:

  • 2. 

    Python can recognise this data: "hello"

    • A.

      Yes

    • B.

      No

    • C.

      Sometimes

    Correct Answer
    A. Yes
    Explanation
    Python can recognize the data "hello" because it is a string literal enclosed in quotation marks. In Python, strings are a built-in data type and can be defined using single quotes ('hello') or double quotes ("hello"). The given data is enclosed in double quotes, which is a valid way to define a string in Python. Therefore, Python can recognize and interpret the given data as a string.

    Rate this question:

  • 3. 

    Python can recognise this data: 56.97

    • A.

      Yes

    • B.

      No

    • C.

      Sometimes

    Correct Answer
    A. Yes
    Explanation
    Python can recognize the data "56.97" because it is a valid floating-point number. In Python, floating-point numbers are represented with a decimal point, allowing for both whole numbers and fractions. The given data follows this format, making it recognizable by Python.

    Rate this question:

  • 4. 

    Python can recognise this data: computer

    • A.

      Yes

    • B.

      No

    • C.

      Sometimes

    Correct Answer
    C. Sometimes
    Explanation
    Python can sometimes recognize the data "computer" depending on the context and how it is used. Python is a versatile programming language that can handle various types of data, including strings like "computer". However, the recognition of this data may depend on the specific program or code being written in Python. In some cases, Python may not be able to recognize the data if it is not properly formatted or if it is used in a way that is not supported by the language. Therefore, the answer is "Sometimes".

    Rate this question:

  • 5. 

    Python can recognise this code: 3 + 6 * 8

    • A.

      Yes

    • B.

      No

    • C.

      Sometimes

    Correct Answer
    A. Yes
    Explanation
    Python can recognize and evaluate mathematical expressions using the correct order of operations. In the given code, 3 + 6 * 8, Python will first multiply 6 by 8, resulting in 48, and then add 3 to it, resulting in 51. Therefore, Python can recognize and evaluate this code correctly.

    Rate this question:

  • 6. 

    What does Python use to store values?

    Correct Answer
    Variable
    A Variable
    Variables
    =
    = Sign
    Equals
    Equals Sign
    Assignment
    Assignment Operator
    Explanation
    Python uses variables to store values. Variables are used to represent and store data in memory. In Python, we can assign values to variables using the assignment operator, which is represented by the equals sign (=). Therefore, the correct answer options are "Variable", "A Variable", "Variables", "=", "Equals", "Equals Sign", "= Sign", "Assignment", and "Assignment Operator".

    Rate this question:

  • 7. 

    Python will run this program without errors: print("hello")

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The given program consists of a single line of code that uses the print() function to display the string "hello". This is a valid Python syntax and will run without any errors. Therefore, the correct answer is True.

    Rate this question:

  • 8. 

    Python will run this program without errors: print(765.9908) print("that was a number")

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The given program consists of two print statements. The first print statement prints a floating-point number, 765.9908. Since there are no syntax errors or any other issues in this statement, Python will execute it without any errors. The second print statement prints a string, "that was a number". Again, there are no errors in this statement. Therefore, Python will run this program without any errors, resulting in the correct answer being True.

    Rate this question:

  • 9. 

    The output of this program will be? print("5+7+2")

    • A.

      14

    • B.

      12

    • C.

      5+7+2

    • D.

      Nothing. It will return an error.

    Correct Answer
    C. 5+7+2
    Explanation
    The output of this program will be "5+7+2". This is because the print statement is printing the exact string "5+7+2" as it is, without evaluating the expression. Therefore, the output will be the string itself, not the result of the addition.

    Rate this question:

  • 10. 

    What will the output of this program be?   print("Hello") text = "This is a number" print("Hi, " + text) number = 4 print(box + 2) print(box * 2) print(box * box - box)

    • A.

      Hello Hi, This is a number 

    • B.

      HelloHi, This is a number6812

    • C.

      Nothing, it will return an error

    • D.

      Hello Hi, text box2 boxbox box

    • E.

      Hello This is a number Hi, 4 box2 boxbox boxbox-box

    Correct Answer
    A. Hello Hi, This is a number 
    Explanation
    The program will output "Hello" and "Hi, This is a number" successfully. However, it will encounter an error at print(box + 2) because the variable box is not defined anywhere in the program. This will stop the program's execution before it can reach the subsequent print statements involving box. Thus, the output will include the first two print statements, followed by an error due to the undefined variable box.

    Rate this question:

  • 11. 

    This program will run without errors: print(x) x = 3 print(x+3)

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The program will not run without errors because the variable x is being printed before it is assigned a value. When the print(x) statement is encountered, x has not been defined yet, resulting in an error.

    Rate this question:

  • 12. 

    What structure do you use to let the computer make decisions in Python?

    • A.

      Because structure

    • B.

      If statement

    • C.

      Decision structure

    • D.

      Decide statement

    Correct Answer
    B. If statement
    Explanation
    In Python, the if statement is used to let the computer make decisions. It allows the program to execute a certain block of code only if a specific condition is true. The if statement evaluates the condition and if it is true, the code inside the if block is executed. Otherwise, it is skipped. This decision structure is fundamental in programming as it allows for different actions to be taken based on different conditions.

    Rate this question:

  • 13. 

    What optional part can you add to an if statement?

    • A.

      Who

    • B.

      Else

    • C.

      Then

    • D.

      Nothing

    Correct Answer
    B. Else
    Explanation
    An optional part that can be added to an if statement is the "else" clause. This allows for an alternative block of code to be executed if the condition in the if statement evaluates to false. The code within the else block will be executed when the condition is not met, providing an alternative path of execution.

    Rate this question:

  • 14. 

    Which of these could python run without errors?

    • A.

      X = 5 if x < 10 print("hi")

    • B.

      X = 5 if x < 10: print("hi")

    • C.

      Both

    • D.

      Neither

    Correct Answer
    D. Neither
    Explanation
    The correct syntax in Python for using an "if" statement with a one-liner is to include a colon after the condition. Therefore, the correct way to write this statement is: 
    x = 5 if x < 10: print("hi")

    Therefore, the correct answer is neither. 

    Rate this question:

  • 15. 

    This program is full of errors. What do you need to change to make it correct?cat_weight = 45 if cat_wieght = 50; print your cat is healthy else: print unhealthy

    • A.

      The variable name has been spelled wrong

    • B.

      Variable names should start with $

    • C.

      If statements end in a colon, not semicolon

    • D.

      Instructions underneath an if and an else should be indented by 4 spaces

    • E.

      Every line ends in a semicolon

    • F.

      Words that python should understand should be "surrounded by quotes".

    • G.

      You have to say what type of data something is when you declare a variable.

    • H.

      Else statements end in a semicolon, not a colon

    • I.

      Print() should always be written with brackets

    • J.

      You should use ==, not = to check if two things are equal

    • K.

      You should always include units when working with numbers in Python

    Correct Answer(s)
    A. The variable name has been spelled wrong
    C. If statements end in a colon, not semicolon
    D. Instructions underneath an if and an else should be indented by 4 spaces
    F. Words that python should understand should be "surrounded by quotes".
    I. Print() should always be written with brackets
    J. You should use ==, not = to check if two things are equal
    Explanation
    The correct answer is: The variable name has been spelled wrong. You should use ==, not = to check if two things are equal. If statements end in a colon, not semicolon. print() should always be written with brackets. Words that python should understand should be "surrounded by quotes". Instructions underneath an if and an else should be indented by 4 spaces.

    The given program contains multiple errors. First, the variable name "cat_wieght" has been spelled wrong, it should be "cat_weight". Second, the equality check in the if statement should use == instead of =. Third, if statements in Python end with a colon, not a semicolon. Fourth, the print() function should always be written with brackets. Fifth, words that Python should understand, like "healthy" and "unhealthy", should be surrounded by quotes. Lastly, the instructions underneath the if and else statements should be indented by 4 spaces to indicate that they are part of the respective blocks.

    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
  • Apr 03, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Oct 07, 2014
    Quiz Created by
    Sherd030

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.