Python Programming Module 1: Quiz!

Approved & Edited by ProProfs Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Rajeev Dave
R
Rajeev Dave
Community Contributor
Quizzes Created: 1 | Total Attempts: 620
Questions: 10 | Attempts: 620

SettingsSettingsSettings
Python Programming Module 1: Quiz! - Quiz

Python Programming Module 1: Quiz evaluates foundational Python skills. It covers syntax, operations, error handling, and array manipulations, assessing learners' ability to apply Python in programming contexts effectively.


Questions and Answers
  • 1. 

    The following Python code – >>> 2.0 + 2

    • A.

      0.4

    • B.

      2.2

    • C.

      4.0

    • D.

      An error: You need to make a conversion between a float and an integer

    • E.

      None of the above

    Correct Answer
    C. 4.0
    Explanation
    The given Python code is performing addition between a float (2.0) and an integer (2). In Python, when performing arithmetic operations between different numeric types, the result will be of the more precise type. In this case, since 2.0 is a float and 2 is an integer, the result will be a float. Therefore, the correct answer is 4.0.

    Rate this question:

  • 2. 

    Which of the following is true of Python but not of C or Java?

    • A.

      Indentation is used for block statements.

    • B.

      Line breaks are used to end a statement.

    • C.

      Only two forms of looping are used.

    • D.

      All of the above

    • E.

      None of the above  

    Correct Answer
    A. Indentation is used for block statements.
    Explanation
    In Python, indentation is used to define block statements, which means that the code within a block is indented at the same level. This is not the case in C or Java, where block statements are defined using braces {}. In C and Java, line breaks are used to end a statement, while in Python, line breaks are not required to end a statement. Additionally, Python has more than two forms of looping, unlike the statement that says "Only two forms of looping are used." Therefore, the correct answer is "Indentation is used for block statements."

    Rate this question:

  • 3. 

    What is the order of operation is Python?

    • A.

      PEMDAS rule

    • B.

      BODMAS rule

    • C.

      Both a&b

    • D.

      None of the above

    Correct Answer
    A. PEMDAS rule
    Explanation
    The order of operations in Python follows the PEMDAS rule, which stands for Parentheses, Exponents, Multiplication and Division (from left to right), and Addition and Subtraction (from left to right). This rule determines the sequence in which mathematical operations are performed in an expression.

    Rate this question:

  • 4. 

    What is the output of >>> 5.5=5?

    • A.

      5

    • B.

      Syntax Error: can't assign to literal

    • C.

      2.5

    • D.

      4

    Correct Answer
    B. Syntax Error: can't assign to literal
    Explanation
    The correct answer is "Syntax Error: can't assign to literal". In Python, the "=" symbol is used for variable assignment, not for comparing values. Therefore, trying to assign a value to a literal like 5.5 will result in a syntax error.

    Rate this question:

  • 5. 

    What is the output of the following program? >>> word = 'abcdefghij' >>> print (word[:3] + word[3:])

    • A.

      Abcdefg

    • B.

      Abcabc

    • C.

      Abchij

    • D.

      Abcdefghij

    Correct Answer
    D. Abcdefghij
    Explanation
    The program takes a string "word" with the value "abcdefghij". It then uses slicing to concatenate the substring from index 0 to index 3 (exclusive) with the substring from index 3 to the end of the string. This essentially combines the entire string, resulting in the output "abcdefghij".

    Rate this question:

  • 6. 

    What is the output of the below program? >>> a = [4,7,3,2,5,9] >>> a[-2]  

    • A.

      7

    • B.

      5

    • C.

      Error

    • D.

      2

    Correct Answer
    B. 5
    Explanation
    The program creates a list called 'a' with the elements [4,7,3,2,5,9]. The expression 'a[-2]' accesses the second element from the end of the list, which is 5. Therefore, the output of the program is 5.

    Rate this question:

  • 7. 

    What is the output of the below program? >>> 'abc' * 3

    • A.

      Abc * 3

    • B.

      Abcabcabc

    • C.

      Error

    • D.

      None of the above

    Correct Answer
    B. Abcabcabc
    Explanation
    The output of the program is "abcabcabc". This is because the string 'abc' is multiplied by 3 using the * operator, which concatenates the string with itself three times.

    Rate this question:

  • 8. 

    What is the output of the below program? >>> S = "NCR Gurgaon" >>>  S[1:5]

    • A.

      NCR

    • B.

      CR G

    • C.

      CR

    • D.

      None of the above

    Correct Answer
    B. CR G
    Explanation
    The output of the program is "CR G". This is because the slice notation [1:5] extracts the characters from index 1 to index 4 (excluding index 5) from the string "NCR Gurgaon". Therefore, the characters "CR G" are returned as the output.

    Rate this question:

  • 9. 

    Which of the following statements is true?

    • A.

      Python is a high level programming language.

    • B.

      Python is an interpreted language.

    • C.

      Python is an object-oriented language.

    • D.

      All of the above.

    Correct Answer
    D. All of the above.
    Explanation
    The statement "All of the above" is the correct answer because all three statements are true. Python is a high-level programming language, meaning it is designed to be easily readable and understandable by humans. Python is also an interpreted language, which means that it does not need to be compiled before running, allowing for faster development and testing. Additionally, Python is an object-oriented language, which means it supports the creation and manipulation of objects to solve problems. Therefore, all three statements are true.

    Rate this question:

  • 10. 

    What is used to define a block of code (body of loop, function etc.) in Python?

    • A.

      Curly braces

    • B.

      Parenthesis

    • C.

      Indentation

    • D.

      Quotation

    Correct Answer
    C. Indentation
    Explanation
    In Python, a block of code is defined using indentation. This means that instead of using curly braces or parentheses like in other programming languages, Python uses the indentation level to determine which lines of code belong to a particular block. This helps in improving code readability and ensures that the code is properly structured.

    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 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 15, 2019
    Quiz Created by
    Rajeev Dave

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.