Python Code and Output Quiz
42 Questions
16 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which of the following is an example of a procedural programming language?

  • C (correct)
  • Python
  • Pascal
  • Java
  • Which of the following is an example of an object-oriented programming language?

  • C# (correct)
  • C
  • Pascal
  • C++
  • Which of the following is an example of an interpreted programming language?

  • C++
  • Python (correct)
  • Pascal
  • Java
  • Which of the following is an example of a compiled programming language?

    <p>C++</p> Signup and view all the answers

    Which of the following is the correct definition of hardware?

    <p>The physical aspect of the computer that can be seen</p> Signup and view all the answers

    Which of the following is considered an input device?

    <p>Keyboard</p> Signup and view all the answers

    What is the purpose of high-level programming languages?

    <p>Make programming less error-prone and less tedious</p> Signup and view all the answers

    Which of the following statements about Python 3 is true?

    <p>Python 3 is a newer version, but it is not backward compatible with Python 2.</p> Signup and view all the answers

    Which of the following programming languages is an object-oriented programming language?

    <p>Java</p> Signup and view all the answers

    Which of the following programming languages is interpreted?

    <p>Python</p> Signup and view all the answers

    Is Python syntax case-sensitive?

    <p>True</p> Signup and view all the answers

    Which of the following functions returns the current time in milliseconds since midnight, January 1, 1970?

    <p>time.time()</p> Signup and view all the answers

    Which of the following functions causes an error?

    <p>int(&quot;034&quot;)</p> Signup and view all the answers

    What will be displayed by the following code? print("A", end = ' ') print("B", end = ' ') print("C", end = ' ') print("D", end = ' ')

    <p>A B C D</p> Signup and view all the answers

    In Python, a string literal is enclosed in __________.

    <p>single-quotes</p> Signup and view all the answers

    Which of the following is the result of the code x=1; x=2*x+1; print(x)?

    <p>3</p> Signup and view all the answers

    What will be displayed by the following code? x=1; x = x + 2.5; print(x)

    <p>3.5</p> Signup and view all the answers

    What will be displayed by the following code? x, y = 1, 2; x, y = y, x; print(x, y)

    <p>2 1</p> Signup and view all the answers

    Which of the following is the correct input for the code? x, y = eval(input("Enter two numbers: "))

    <p>1, 2</p> Signup and view all the answers

    Which of the following code displays the area of a circle if the radius is positive?

    <p>if radius &gt; 0: print(radius * radius * 3.14159)</p> Signup and view all the answers

    The following code displays ___________. temperature = 50 if temperature >= 100: print('too hot') elif temperature < 100: print('just right') else: print('too cold')

    <p>'just right'</p> Signup and view all the answers

    What is the output of the following code snippet? i = 1 while i < 10: print(i, end=' ') i = i + 2 if i == 5: i = 9

    <p>1 3 5 7 9</p> Signup and view all the answers

    What is the output of the following code snippet? i = 1 while i .= 9: print(i, end=' ') i = i + 1 if i == 9: print('End')

    <p>1 End (infinite loop)</p> Signup and view all the answers

    Which of the following is the physical aspect of the computer that can be seen?

    <p>Hardware</p> Signup and view all the answers

    Which parts of the computer store program code?

    <p>Secondary storage</p> Signup and view all the answers

    Which of the following hardware devices is NOT considered an input device?

    <p>Monitor</p> Signup and view all the answers

    Which of the following is true about the Python language?

    <p>Python is an interpreted programming language.</p> Signup and view all the answers

    What is the difference between an editor and an interpreter?

    <p>An editor converts program files into an executable program; an interpreter reads and executes program files.</p> Signup and view all the answers

    Which of the following is an example of a high-level programming language?

    <p>C++</p> Signup and view all the answers

    What is the purpose of a compiler?

    <p>To convert high-level language program into machine language program.</p> Signup and view all the answers

    Which of the following is an example of a high-level programming language?

    <p>Python</p> Signup and view all the answers

    Which of the following statements about Python 3 is true?

    <p>Python 3 is a newer version, but it is not backward compatible with Python 2.</p> Signup and view all the answers

    What is the result of the code x=1; x = x + 2.5; print(x)?

    <p>4.5</p> Signup and view all the answers

    Which of the following is a valid identifier in Python?

    <p>mile</p> Signup and view all the answers

    Which of the following is the correct comparison operator in Python?

    <p>==</p> Signup and view all the answers

    Which of the following code snippets will display the area of a circle if the radius is positive?

    <p>if radius &gt; 0: print(radius * radius * 3.14159)</p> Signup and view all the answers

    What is the output of the following code snippet?

    <p>135</p> Signup and view all the answers

    What is the output of the following code snippet?

    <p>1 End (infinite loop)</p> Signup and view all the answers

    Which of the following functions returns the current time in milliseconds since midnight, January 1, 1970?

    <p>round(3.9)</p> Signup and view all the answers

    Which of the following functions cause an error?

    <p>int(&quot;034&quot;)</p> Signup and view all the answers

    What will be displayed by the following code?

    print("A", end = ' ')
    print("B", end = ' ')
    print("C", end = ' ')
    print("D", end = ' ')
    

    <p>A B C D</p> Signup and view all the answers

    Which of the following statements is correct?

    <p>s = &quot;Chapter &quot; + str(1)</p> Signup and view all the answers

    Study Notes

    Programming Languages

    • Procedural programming language: Example is C
    • Object-oriented programming language: Example is Java
    • Interpreted programming language: Example is Python
    • Compiled programming language: Example is C++

    Hardware

    • Hardware refers to the physical components of a computer
    • Input device: Example is a keyboard
    • Correct definition of hardware: Physical components of a computer that can be seen

    Programming Concepts

    • High-level programming languages: Purpose is to make programming easier and more efficient
    • Example of high-level programming language: Python
    • Compiler: Purpose is to translate high-level language into machine code
    • Object-oriented programming language: Example is Python
    • Interpreted programming language: Example is Python
    • Python syntax is case-sensitive
    • int(round(time.time() * 1000)) returns the current time in milliseconds since midnight, January 1, 1970

    Python Code

    • x=1; x=2*x+1; print(x) returns 3
    • x=1; x = x + 2.5; print(x) returns 3.5
    • x, y = 1, 2; x, y = y, x; print(x, y) returns 2 1
    • Correct input for x, y = eval(input("Enter two numbers: ")) is a string of two numbers separated by a comma
    • import math; r = float(input("Enter radius: ")); if r &gt; 0: print(math.pi * r ** 2) displays the area of a circle if the radius is positive
    • temperature = 50; if temperature &gt;= 100: print('too hot'); elif temperature &lt; 100: print('just right'); else: print('too cold') returns 'just right'
    • i = 1; while i &lt; 10: print(i, end=' '); i = i + 2; if i == 5: i = 9 returns 1 3 9
    • i = 1; while i &lt;= 9: print(i, end=' '); i = i + 1; if i == 9: print('End') returns 1 2 3 4 5 6 7 8 9 End
    • String literal is enclosed in quotes
    • Valid identifier in Python: Example is myVariable
    • Correct comparison operator in Python: Example is ==
    • print("A", end = ' '); print("B", end = ' '); print("C", end = ' '); print("D", end = ' ') returns A B C D

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Quiz Answers PDF

    Description

    This quiz tests your knowledge of Python code and output. Answer questions about the displayed code and predict the output.

    More Like This

    Types of Programming Languages Quiz
    5 questions

    Types of Programming Languages Quiz

    InnovativeRainbowObsidian avatar
    InnovativeRainbowObsidian
    Evolution of Programming Languages
    14 questions

    Evolution of Programming Languages

    IntegratedWilliamsite913 avatar
    IntegratedWilliamsite913
    Computer Programming Instructions
    10 questions
    Use Quizgecko on...
    Browser
    Browser