NEW
Font size
WorksheetsComputer Science Webxam
Total questions: 74
Worksheet time: 15hrs 8mins
Which of the following is NOT an input device?
mouse
printer
scanner
microphone
Which of the following is true about main and secondary memory?
Secondary memory is lost when the device's power is turned off.
Main memory is short term memory used by the CPU in processing commands, secondary memory is more permanent and used for storage.
Main memory is more permanent and used for storage, secondary memory is short term memory is used by the CPU in processing commands
Main memory is used for storage
Which of the following controls computer memory?
applications
compiler
operating system
Python
What is the correct order for the steps the compiler uses in translating code?
Translate commands to machine language, Check for mistakes, Run the commands
Run the commands, Translate commands to machine language, Check for mistakes
Check for mistakes, Translate commands to machine language, Run the commands
Run the commands, Check for mistakes, Translate commands to machine language
What is input?
Displaying information on the screen.
Storing data in main memory.
Putting information into the computer
Converting code to machine language.
Which of the following is a legal variable name?
1test
52
#data
temperatureAM
What command is used to change a string into a number?
dec
chr
int
str
What is output by the following?
print("Twinkle, \ttwinkle, \tlittle star")
Twinkle,
twinkle,
little star
Twinkle, \ttwinkle, \tlittle star
Twinkle, twinkle, little star
What is output by the following? Assume the user enters 5 and 4
x = input("Enter a number: ")
y = input("Enter a number: ")
print("Values: " + x + y)
Values: 9
9
Values: 54
54
Consider the following code:
x = "apple"
y = x
z = "banana"
print(x + " " + y + "\n" + z)
What is output?
apple banana
apple apple banana
apple apple
banana
Which of the following correctly inputs two numbers and print the sum?
n1 = input("Enter a number: ")
n2 = input("Enter a number: ")
print("The answer is: " + int(n1+n2))
n1 = input("Enter a number: ")
n2 = input("Enter a number: ")
print("The answer is: " + str(n1+n2))
n1 = int(input("Enter a number: "))
n2 = int(input("Enter a number: "))
print("The answer is: " + int(n1+n2))
n1 = int(input("Enter a number: "))
n2 = int(input("Enter a number: "))
print("The answer is: " + str(n1+n2))
Consider the following code:
x = input("What year is it?")
print(x)
The value stored in x is:
a String
a number
stored in secondary memory
a comment
Consider the following code:
print("computer" + "science")
What is output?
computer
science
computer science
computerscience
Nothing, there is an error - you cannot add words.
What is one downside of converting analog information to a digital format?
When the power is turned off the information is lost
Limits the technology available
Some information may be lost when it is converted
It takes up too much space in memory
The symbol used to create a comment is:
=
#
+
%
Which of the following will correctly output:
I know there's a proverb which that says
"To err is human,"
but
a human error is nothing to what a computer
can do if it tries.
― Agatha Christie
Note: This is a direct quote from Agatha Christie's novel, Hallowe'en Party. The grammar shown here is as it is written in the novel.
quote = "\"To err is human,\""
print("I know there's a proverb which that says \t"+ quote + "\tbut")
print("a human error is nothing to what a computer")
print("can do if it tries.\t\t― Agatha Christie")
quote = "To err is human,"
print("I know there's a proverb which that says \n"+ quote + "\nbut")
print("a human error is nothing to what a computer")
print("can do if it tries.\n\n- Agatha Christie")
quote = "\"To err is human,\""
print("I know there's a proverb which that says \n"+ quote + "\nbut")
print("a human error is nothing to what a computer")
print("can do if it tries.\n\n- Agatha Christie")
quote = "\"To err is human,\""
print("I know there's a proverb which that says \n + quote + \nbut")
print("a human error is nothing to what a computer")
print("can do if it tries.\n\n- Agatha Christie")
When do we use numbers instead of strings?
To input large amounts of data
To store data like phone numbers and street addresses
When you need to do calculations
To hold both words and integers
Which of the following about computers is NOT true?
Computing devices are electronic
The CPU processes commands.
The memory uses binary numbers
Computing devices translate digital to analog information in order to process the information.
Which line of code outputs the decimal portion of a float stored in the variable x?
print (x / 1000)
print (x - int(x))
print (x)
print (x % 1000)
Which of the following is NOT a data type in Python?
float
string
decimal
integer
Three of the following values could be stored as strings. When would you NOT use a string command?
To store a list of colors
To store decimal values
To store a word
To store values NOT used for calculations,
Which of the following numbers might this code generate: random.randint(1,9)?
10
1
11
0
What is NOT a built-in function in python?
sqrt()
string()
fabs()
print()
To generate numbers between and including -10 to 10 you would use:
random.random()*20 + -10
randint(-10, 10)
random.random(-10, 10)
random.randint(-10, 10)
Consider the following code:
a = 3 b = 2
print (a ** b)
What is output?
1
6
8
9
What is output?
print (12 % 5)
0
1
2
5
Consider the following code:
x = 9
y = -2
z = 2
print (x + y * z)
5
9
12
14
You need to find the square root of a value. Which of the following functions would you use?
int
sqrt
fabs
pow
You need to make sure a number the user types in is non-negative. Which of the following functions would you use?
abs
fabs
pos
int
Consider the following code:
x = 5
x = x * 3
print (x)
What is output?
5
15
27
75
The following code is intended to find the average of three numbers entered from the keyboard. What is wrong with the code?
print ("Enter 3 numbers: ")
n1 = float(input ("Enter a number: "))
n2 = float(input ("Enter a number: "))
n3 = float(input ("Enter a number: "))
print (n1 + n2 + n3 /3)
n1, n2, and n3 should use the str command
The code is missing parentheses around n1 + n2 + n3 in the last line
Nothing, it correctly finds the average of the numbers
Nothing, it correctly finds the sum of the numbers.
What is the output for the following?
x = 7
print ("The number is: " + x * 2)
14
The number is: 14
The number is: x
None, there is an error
Which of the following calculates to 10?
3 * 6 + 2 /2
(3 * 6) + 2 /2
(3 * 6 + 2) /2
3 * (6 + 2 /2)
Which of the following would be the best variable name to store the value of your English letter grade?
g
LG
1grade
letter_Grade
Why can it be helpful to perform mathematical calculations using programming? Choose the best answer.
Because is an important skill.
Because computers can quickly do calculations much larger and complex than humans.
Because the values stored in variables cannot change
Because computers are used to store digital data, not analog
Consider the following code:
x = 19 y = 5
print (x % y)
What is output?
2
3
4
3.8
Consider the following code:
print (min("whom", "carton", "landform", "composite", "apron", "deposit", "become"))
What is output?
apron
become
carton
whom
5%2
3
5
2
1
42%6
7
1
0
2
81%2
0
3
1
9
55%10
0
5
50
5.5
18%4
2
0
1
3
What is output by the following?
print ("she sells \nseashells")
print ("by the seashore")
she sells seashells by the seashore
she sells
seashells by the seashore
she sells
seashells
by the seashore
she sells seashells
by the seashore
What is output by the following?
print ("/\\")
print ("\\/")
/\
\/
/\\
\\/
/\\/
/\\\\/
What is output by the following? Assume the user enters Sally and John.
x = input ("What is your name? ")
y = input ("What is your friend's name? ")
print ("Hi " + x + " and " + y)
Hi x and y
Hi Sally and John
Hi + x + and + y
Hi + Sally + and + John
The print command in Python can be written as PRINT or print
True
False
What is wrong with the following line of code?
print(Hello World)
print should be PRINT
It cannot print words
It needs " around Hello World
It needs # around Hello World
What is the Python command that can be used to display text and numbers on the screen?
hello
+
python
What is output by the following line of code?
print ("I\tLove Python")
I Love Python
I Love Python
I Love Python
I\tLove Python
What is output by the following line of code?
print (5 + 9*2)
23
592
518
28
What would be output by the following code?
print("Hello", end="")
print(" Jackson")
Hello, end="" Jackson
Hello Jackson
HelloJackson
Hello
Jackson
What is output by the following lines of code if we input the name "Sally"?
n = input("What is your name?")
print("Hello there " + n)
There is an error since the input command needs a str
Hello there Sally
Hello there 0
Hello there n
This code accepts a word as input, and then prints that word to the screen.
w = input("Enter a word: ")
print(w)
The number is printed.
Nothing is printed.
Nothing, there is an error.
Assume the user types in 7 and 10. What is output by the following?
num1 = input ("Enter a number: ")
num2 = input ("Enter a number: ")
print (num1 + num2)
17
71
No output, there is an error.
710
What is wrong with the following code?
num1 = int (input("Enter a number: "))
num2 = int (input("Enter a number: "))
num3 = int (input("Enter a number: "))
print ("The average is: " + (num1 + num2 + num3)/3)
The variables should be 1num, 2num, 3num
It needs a int() command
The last line should be print ("The average is: (num1 + num2 + num/3 ))
It needs a str() command
What is output?
a = 10
b = 23
print (a + b * a)
150
235
33
240
What does the % find?
The product
The mean
The remainder
The quotient
Short term memory; temporary; power off = all information is lost.
main memory
secondary memory
compiler
software
CPU
Tells Python to handle the value in the ( ) as a String, not as a number.
str
Str
int
integer
String
The process of storing a value in a variable.
Assignment
Function
Max
Module
Command that pulls in code to add functions to your code
Operator
Module
Function
Import
A symbol that defines a math operation.
Function
Operator
Assignment
Import
The process of using technology to solve human problems.
Computer Science
Computer
CPU
Program
A command that displays text and numbers on the screen.
print( )
str( )
input()
int( )
A program that translates written code into machine language.
String
Operating System
Compiler
Program
An electronic device consisting of hardware and software.
Escape Characters
String
Computer
Integrated Development Environment (IDE)
