CIS 221 Test #1
(suppose no1=1, no2=2, and no3=3) print("The average is,", (numberAverage))
"The average is, 1.667
A Python line comment begins with ________. A. // B. /* C. # D. $$
#
A Python paragraph comment uses the style ________. A. // comments // B. /* comments */ C. ''' comments ''' D. /# comments #/
''' comments '''
(suppose no1=1, no2=2, and no3=3) numberProduct = no1 * no2 * no3 print("The product is", numberProduct)
The product is 6
If you enter 1 2 3 in one line, when you run this program, what will happen? print("Enter three numbers: ") number1 = eval(input()) number2 = eval(input()) number3 = eval(input()) # Compute average average = (number1 + number2 + number3) / 3 # Display result print(average) A. The program runs correctly and displays 1.0 B. The program runs correctly and displays 2.0 C. The program runs correctly and displays 3.0 D. The program runs correctly and displays 4.0 E. The program will have a runtime error on the input.
The program will have a runtime error on the input.
(suppose no1=1, no2=2, and no3=3) print("The sum is", (no1 + no2 + no3)
The sum is 6
________ is interpreted. A. Python B. C++ C. C D. Ada E. Pascal
Python
____________ is an operating system. A. Java B. C++ C. Windows XP D. Visual Basic E. Python
Windows XP
(suppose no1=1, no2=2, and no3=3) print("Your grade is", no3, no1)
Your grade is 3 1
You can place the line continuation symbol __ at the end of a line to tell the interpreter that the statement is continued on the next line. A. / B. \ C. # D. * E. &
\
Which of the following is NOT a logic error when calculating the average of No1 & No2 a. (No1 + No2)/2 b. they are all logic errors c. No1 + No2/2 d. 2/(No1 + No2)
a. (No1 + No2)/2
In this statement a = b = c = 9, what is the value of b? a. 9 b. unknown c. 3 d. 0
a. 9
What is used to break a long statement into multiple lines? a. \ b. + c. and d. more
a. \
Which of the following is the same as this: a *= b a. b = a * b b. a = a * b c. a * b = b d. b * a = a
b. a = a * b
Python's print statement will print to the a. printer b. screen c. USB or thumb drive
b. screen
Python has a graphics module called a. command b. turtle c. drawing d. graphics
b. turtle
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
b.print("Programming is fun") print("Python is fun")
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.
because digital devices have two stable states and it is natural to use one state for 0 and the other for 1.
What is the result of 25 % 4? a. 4 b. 2 c. 1 d. 24 e. 6
c. 1
What is the result of print (int ("5.9"))? a. 5 b. 0 c. 6 d. causes an error e. 9
d. causes an error
Python is a ____ language. a. compiled b. neither c. both d. interpreted
d. interpreted
(suppose no1=1, no2=2, and no3=3) numberDiv = no3 / no2 print("no3 divided by no2", numberdiv)
error
Print('Go Dukes')
error
Which of the following are storage devices? A. floppy disk B. hard disk C. flash stick D. CD-ROM
floppy disk, hard disk, flash stick, CD ROM
________ is the physical aspect of the computer that can be seen. A. Hardware B. Software C. Operating system D. Application program
hardware
(suppose no1=8, no2=3, no3 = no1 / no2) print("int(no3): ", int(no3))
int(no3): 2
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
interpreter/at runtime
A ___________ error does not cause the program to abort, but produces incorrect results. A. syntax B. runtime C. logic
logic
(suppose no1=1, no2=2, and no3=3) numberAverage = (no1 + no2 + no2) / 3
logic error
Computer can execute the code in ____________. A. machine language B. assembly language C. high-level language D. none of the above
machine language
The speed of the CPU may be measured in __________.
megahertz and gigahertz
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
memory
Which of the following is a valid identifier? A. $343 B. mile C. 9X D. 8+9 E. max_radius
mile max_radius
Which of the following is a valid identifier? A. import B. mile1 C. MILE D. (red) E. "red"
mile1 MILE
(suppose no1=1, no2=2, and no3=3) numberDiv = no3 / no2 print("no3 divided by no2", numberDiv)
no3 divided by no2 1.5
(suppose no1=8, no2=3, no3 = no1 / no2) print("no3 w/2 dec: "), int(no3*100) / 100)
no3 w/2 dec: 2.66
(suppose no1=8, no2=3, no3 = no1 / no2) print("no3: ", no3)
no3: 2.6666667
no1 = eval(input(number 1?"))
number 1?
no2 = eval(input(number 2?"))
number 2?
no3 = eval(input(number 3?"))
number 3?
In the expression 45 / 4, the values on the left and right of the / symbol are called ____. A. operators B. operands C. parameters D. arguments
operands
To start Python from the command prompt, use the command ________. A. execute python B. run python C. python D. go python
python
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
python t.py
(suppose no1=8, no2=3, no3 = no1 / no2) print("round(no3): ", round(no3))
round(no3): 3
____________ are instructions to the computer. A. Hardware B. Software C. Programs D. Keyboards
software and programs
what is the function of .split()?
tells the program to separate the words
An identifier can contain digits, but cannot start with a digit? A. true B. false
true
An identifier cannot be a keyword? A. true B. false
true
To draw a circle with radius 50, use ___________. A. turtle.circle(50) B. turtle.circle(100) C. turtle.drawcircle(50) D. turtle.drawCircle(50)
turtle.circle(50)
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)
turtle.goto(4, 5)
To put the pen down, use ___________. A. turtle.penDown() B. turtle.pendown() C. turtle.putDown() D. turtle.down()
turtle.pendown()
To lift the pen, use ___________. A. turtle.penUp() B. turtle.penup() C. turtle.lift() D. turtle.up()
turtle.penup()
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()
turtle.showturtle()
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.
Python 3 is a newer version, but it is not backward compatible with Python 2.
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
IV: print("Programming is fun") print("Python") print("Computer Science")
____________ is a device to connect a computer to a local area network (LAN). A. Regular modem B. DSL C. Cable modem D. NIC
NIC
(suppose no1=1, no2=2, and no3=3) print("No1 + No2 - No3 is", (no1 + no2 - no3))
No1 + No2 - No3 is 0
One gigabyte is approximately ________ bytes. A. 1 million B. 10 million C. 1 billion D. 1 trillion
1 billion
To following code reads two number. Which of the following is the correct input for the code? x, y = eval(input("Enter two numbers: ")) A. 1 2 B. "1 2" C. 1, 2 D. 1, 2,
1, 2
(suppose no1=8, no2=3) print(no1 + no2)
11
print(5 + 6)
11
(suppose no1=8, no2=3) print(no1 % no2)
2
(suppose no1=8, no2=3) print(no1 // no2)
2
If you enter 1, 2, 3, in one line, when you run this program, what will be displayed? number1, number2, number3 = eval(input("Enter three numbers: ")) # Compute average average = (number1 + number2 + number3) / 3 # Display result print(average) A. 1.0 B. 2.0 C. 3.0 D. 4.0
2.0
(suppose no1=8, no2=3) no3 = no1 / no2
2.6666667
(suppose no1=8, no2=3) print(no1 / no2)
2.6666667
(suppose no1=8, no2=3) print(no1 * no2)
24
(suppose no1=8, no2=3) print(no2)
3
(suppose no1=8, no2=3, no3 = no1 / no2) print(no2)
3
(suppose no1=8, no2=3) print(no1 - no2)
5
(suppose no1=8, no2=3) print(no1 ** no2)
512
(suppose no1=8, no2=3) print(no1)
8
(suppose no1=8, no2=3, no3 = no1 / no2) print(no1)
8
(suppose no1=8, no2=3, no3 = no1 / no2) print(no1) print(no2) no1 += no2 print(no1) no1 -= no2 print(no1) no1 *= no2 print(no1) no1 /= no2 print(no1) no1 //= no2 print(no1) no1 **= no2 print(no1) no1 %= no2
8 3 11 8 24 8 2 8
One byte has ________ bits. A. 4 B. 8 C. 12 D. 16
8 bits
(suppose no1=8, no2=3) no1, no2=eval(input("Enter 2 numbers separated by a comma: "))
8,3
___________ translates high-level language program into machine language program. A. An assembler B. A compiler C. CPU D. The operating system
A compiler
What function do you use to read a string? A. input("Enter a string") B. eval(input("Enter a string")) C. enter("Enter a string") D. eval(enter("Enter a string"))
A. input("Enter a string")
What is the result of 45 // 4? A. 10 B. 11 C. 11.25 D. 12
B. 11
If you enter 1 2 3 in three separate lines, when you run this program, what will be displayed? print("Enter three numbers: ") number1 = eval(input()) number2 = eval(input()) number3 = eval(input()) # Compute average average = (number1 + number2 + number3) / 3 # Display result print(average) A. 1.0 B. 2.0 C. 3.0 D. 4.0
B. 2.0
What is the result of eval("1 + 3 * 2")? A. "1 + 3 * 2" B. 7 C. 8 D. "1 + 6"
B. 7
What is the result of 45 / 4? A. 10 B. 11 C. 11.25 D. 12
C. 11.25
_______ is the code in natural language mixed with some program code. A. Python program B. A Python statement C. Pseudocode D. A flowchart diagram
C. Pseudocode
__________ is the brain of a computer.
CPU
What will be displayed by the following code? x, y = 1, 2 x, y = y, x print(x, y) A. 1 1 B. 2 2 C. 1 2 D. 2 1
D. 2 1
What will be displayed by the following code? x = 1 x = 2 * x + 1 print(x) A. 0 B. 1 C. 2 D. 3 E. 4
D. 3
What will be displayed by the following code? x = 1 x = x + 2.5 print(x) A. 1 B. 2 C. 3 D. 3.5 E. The statements are illegal
D. 3.5
print(ln)
DiGilio
print(ln + "," fn)
DiGilio, Maria
print("Go Dukes")
Go Dukes
Python was created by ____________. A. James Gosling B. Bill Gates C. Steve Jobs D. Guido van Rossum E. Google
Guido van Rossum
print("Hello" + name)
Hello Maria
_____________ 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
Operating system
________ is an object-oriented programming language. A. Java B. C++ C. C D. C# E. Python
Java C++ .C# Python
print(fn)
Maria
fn, ln = input("Enter first and last name (no comma): ").split()
Maria DiGilio
Python syntax is case-sensitive. A. True B. False
True
True or False Python is case sensitive.
True
name=input("What is your name?")
What is your name?