Python Code and Output Quiz

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++ (D)</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 (A)</p> Signup and view all the answers

Which of the following is considered an input device?

<p>Keyboard (A)</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 (B)</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. (A)</p> Signup and view all the answers

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

<p>Java (C)</p> Signup and view all the answers

Which of the following programming languages is interpreted?

<p>Python (A)</p> Signup and view all the answers

Is Python syntax case-sensitive?

<p>True (B)</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() (C)</p> Signup and view all the answers

Which of the following functions causes an error?

<p>int(&quot;034&quot;) (D)</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 (B)</p> Signup and view all the answers

In Python, a string literal is enclosed in __________.

<p>single-quotes (C)</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 (A)</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 (C)</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 (C)</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 (C)</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) (D)</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' (A)</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 (C)</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) (C)</p> Signup and view all the answers

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

<p>Hardware (C)</p> Signup and view all the answers

Which parts of the computer store program code?

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

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

<p>Monitor (C)</p> Signup and view all the answers

Which of the following is true about the Python language?

<p>Python is an interpreted programming language. (B)</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. (D)</p> Signup and view all the answers

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

<p>C++ (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. (D)</p> Signup and view all the answers

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

<p>Python (A)</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. (B)</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 (C)</p> Signup and view all the answers

Which of the following is a valid identifier in Python?

<p>mile (C)</p> Signup and view all the answers

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

<p>== (D)</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) (B)</p> Signup and view all the answers

What is the output of the following code snippet?

<p>135 (B)</p> Signup and view all the answers

What is the output of the following code snippet?

<p>1 End (infinite loop) (A)</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) (C)</p> Signup and view all the answers

Which of the following functions cause an error?

<p>int(&quot;034&quot;) (D)</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 (C)</p> Signup and view all the answers

Which of the following statements is correct?

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

Flashcards are hidden until you start studying

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

More Like This

Types of Programming Languages Quiz
5 questions

Types of Programming Languages Quiz

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