CS-Python Fundamentals Mid-Term Exam (December)
Not equal to
!=
Consider the following code: x = 12 y = 2 print( x % y) What is output?
0
Consider the following code: x = 8 x = x * 2 print(x) What is output?
16
What is output? print(8 % 3)
2
What is output? What is output? x = 10 y = -4 z = 2 print(x + y * z)
2
What is output? x = 10 x = x * 3 print(x)
30
What is output? x = -2 y = 3 print(x + y * 2)
4
Which of the following numbers might this code generate?
8 and 11
Less than.
<
Less than or equal
<=
To test if x is less than or equal to y: if (x _____ Y): print("Great!")
<=
Equal
==
Why do we use loops?
Because of efficiency.
What does the following loop do? x = 1 while (x < 11): x = x + 1 print(x)
Print the numbers from 2 to 11, including 2 and 11.
Consider the following code: for x in (7, 10): print(x) What is wrong with the program?
The first line should be for x in range(7, 10):
What is wrong with: x = 1 while (x < 20): print(x)
The loop will not stop since x never changes
Which of the following is NOT true about "while" loops?
Used to create functions
fitMedia() is an example of what?
a function
What best defines an algorithm?
a set of precise steps used to perform a task, typically on a computer
Both conditions must be true.
and
What does an effect allow you to do in EarSketch?
change the qualities of sound within a project
Within a loop, sum = sum + x is used to _______________.
count how many times a value is entered.
Which of the following lines shows the correct way to use the fitMedia() function?
fitMedia(RD_UK_HOUSE_ACOUSTICGUITAR_1, 1, 1, 5)
To input a decimal you need the ________________ function.
float
Consider the following code: if(90 <= x <= 100) How should it be rewritten?
if (90 <= x and x <= 100):
Write the code to test if value1 and value2 are NOT the same.
if (value1 != value2)
Write the code to test if x is greater than or equal to 2.
if (x >= 2):
active/main memory
if the computer loses power, all information here is lost
"While" loops should always be:
indented
output
information the computer sends to the user
programs
instructions that tell the computer what to do; they are written in code
What data type should the following be: A telephone number?
integer
What data type should the following be: Today's high temperature?
integer
What data type should the following be: Your history class's number grade?
integer
One or both conditions must be true.
or
Information sent to a function is a ________________.
parameter
secondary memory
permanent computer memory
Which of the following is NOT used to describe rhythm?
pitch
_______ is a quality of sound that determines how high or low it sounds.
pitch
software
programs that run on the computer
Which range function will print all even numbers between 12 and 85?
range(12, 84, 2)
What does setTempo() allow you to do in EarSketch?
specify the tempo of a song
A(n) __________ is a group of characters such as letters, numbers, and special digits.
string
What data type should the following be: Your English class's letter grade?
string
CPU
the brains of the computer
hardware
the physical computer
complier
translates user commands to the computer's language
Which of the following is NOT true about algorithms?
use natural language
Consider the following code: num = int(input("Enter a number: ")) x = 9 sum = 0 while (x < 19): x = x + 1 num = int(input("Enter a number: ")) sum = sum + num print(str(x) + ": " + str(sun) + " Total: " + str(sum)) Which of the following is a loop-control variable?
x
Which of the following correctly stores 45 squared in the variable x?
x = 45 ** 2