Introduction to Programming Using Python, Y. Daniel Liang

This quiz is for students to practice. A large number of additional quiz is available for instructors from the Instructor's Resource Website.

Chapter 1 Introduction to Computers, Programs, and Python

Section 1.2 What is a Computer?
1.1  ________ is the physical aspect of the computer that can be seen.
A. Hardware
B. Software
C. Operating system
D. Application program

1.2  __________ is the brain of a computer.
A. Hardware
C. Memory
D. Disk

1.3  The speed of the CPU may be measured in __________.
A. megabytes
B. gigabytes
C. megahertz
D. gigahertz

1.4  Why do computers use zeros and ones?
A. because combinations of zeros and ones can represent any numbers and characters.
B. because digital devices have two stable states and it is natural to use one state for 0 and the other for 1.
C. because binary numbers are simplest.
D. because binary numbers are the bases upon which all other number systems are built.

1.5  One byte has ________ bits.
A. 4
B. 8
C. 12
D. 16

1.6  One gigabyte is approximately ________ bytes.
A. 1 million
B. 10 million
C. 1 billion
D. 1 trillion

1.7  A computer?s _______ is volatile; that is, any information stored in it is lost when the system?s power is turned off.
A. floppy disk
B. hard disk
C. flash stick
E. memory

1.8  Which of the following are storage devices?
A. floppy disk
B. hard disk
C. flash stick

1.9  ____________ is a device to connect a computer to a local area network (LAN).
A. Regular modem
C. Cable modem

Section 1.3 Programs
1.10  ____________ are instructions to the computer.
A. Hardware
B. Software
C. Programs
D. Keyboards

1.11  Computer can execute the code in ____________.
A. machine language
B. assembly language
C. high-level language
D. none of the above

1.12  ___________ translates high-level language program into machine language program.
A. An assembler
B. A compiler
D. The operating system

Section 1.4 Operating Systems
1.13  ____________ is an operating system.
A. Java
B. C++
C. Windows XP
D. Visual Basic
E. Python

1.14  _____________ is a program that runs on a computer to manage and control a computer's activities.
A. Operating system
B. Python
C. Modem
D. Interpreter
E. Compiler

Section 1.5 History of Python
1.15  Python was created by ____________.
A. James Gosling
B. Bill Gates
C. Steve Jobs
D. Guido van Rossum
E. Google

1.16  Which of the following statements is true?
A. Python 3 is a newer version, but it is backward compatible with Python 2.
B. Python 3 is a newer version, but it is not backward compatible with Python 2.
C. A Python 2 program can always run on a Python 3 interpreter.
D. A Python 3 program can always run on a Python 2 interpreter.

1.17  ________ is an object-oriented programming language.
A. Java
B. C++
C. C
D. C#
E. Python

1.18  ________ is interpreted.
A. Python
B. C++
C. C
D. Ada
E. Pascal

Section 1.6 Getting Started with Python
1.19  To start Python from the command prompt, use the command ________.
A. execute python
B. run python
C. python
D. go python

1.20  To run python script file named, use the command ________.
A. execute python
B. run python
C. python
D. go python

1.21  Python syntax is case-sensitive.
A. True
B. False

1.22  Which of the following code is correct?

 print("Programming is fun")
   print("Python is fun")
 print("Programming is fun")
 print("Python is fun")

 print("Programming is fun)
 print("Python is fun")

   print("Programming is fun)
 print("Python is fun")
A. A
B. B
C. C
D. D

Section 1.7 Programming Style and Documentation
1.23  A Python line comment begins with ________.
A. //
B. /*
C. #
D. $$

1.24  A Python paragraph comment uses the style ________.
A. // comments //
B. /* comments */
C. ''' comments '''
D. /# comments #/

Section 1.8 Programming Errors
1.25  A ___________ error does not cause the program to abort, but produces incorrect results.
A. syntax
B. runtime
C. logic

1.26  In Python, a syntax error is detected by the ________ at _________.
A. compiler/at compile time
B. interpreter/at runtime
C. compiler/at runtime
D. interpreter/at compile time

1.27  Which of the following code is correct?

print("Programming is fun")
print("Computer Science")

print("Programming is fun")
     print("Computer Science")

  print("Programming is fun")
print("Computer Science")

print("Programming is fun")
print("Computer Science")
A. I

Section 1.9 Getting Started with Graphics Programming
1.28  To show the current location and direction of the turtle object, use ___________.
B. turtle.showLocation()
C. turtle.showDirection()
D. turtle.showturtle()
E. turtle.showTurtle()

1.29  To move the turtle to a point at (4, 5), use ___________.
A. turtle.move(4, 5)
B. turtle.moveTo(4, 5)
C. turtle.moveto(4, 5)
D. turtle.go(4, 5)
E. turtle.goto(4, 5)

1.30  To draw a circle with radius 50, use ___________.
C. turtle.drawcircle(50)
D. turtle.drawCircle(50)

1.31  To lift the pen, use ___________.
A. turtle.penUp()
B. turtle.penup()
C. turtle.lift()
D. turtle.up()

1.32  To put the pen down, use ___________.
A. turtle.penDown()
B. turtle.pendown()
C. turtle.putDown()
D. turtle.down()