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
B. CPU
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
D. CD-ROM
E. memory

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

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

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
C. CPU
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 t.py, use the command ________.
A. execute python t.py
B. run python t.py
C. python t.py
D. go python t.py

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

1.22  Which of the following code is correct?

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

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

 D.
   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?

I: 
print("Programming is fun")
  print("Python")
print("Computer Science")

II:
print("Programming is fun")
  print("Python")
     print("Computer Science")

III:
  print("Programming is fun")
print("Python")
print("Computer Science")

IV:
print("Programming is fun")
print("Python")
print("Computer Science")
A. I
B. II
C. III
D. IV

Section 1.9 Getting Started with Graphics Programming
1.28  To show the current location and direction of the turtle object, use ___________.
A. turtle.show()
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 ___________.
A. turtle.circle(50)
B. turtle.circle(100)
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()