WorksheetsLS72212 Reviewer
Total questions: 60
Worksheet time: 3600secs
What is the only thing that computers understand?
Machine Code
Low-Level Language
High-Level Language
Algorithms
Which of the following is not a high-level programming language?
Assembly
C++
Java
Python
What is the name for the software used to convert an assembly language program into machine code?
Assembler
Interpreter
Compiler
Translator
Software that translates and executes a high-level language program one line at a time is known as a?
Compiler
Interpreter
Assembler
Executor
Which generation of languages started in the 1950s
First
Second
Third
Fourth
Which generation of computer languages includes SQL (Database Search)?
First
Second
Third
Fourth
Programming languages give computers instructions
True
False
Java, Python, PHP, and C++ are examples of
Low-level languages
Medium-level languages
Graphic arts languages
High-level languages
How many bits makeup one letter in binary code?
4
6
8
10
To focus on the logic and make a refinement to a program before translating it into a programming language, a programmer often creates an outline of the program's algorithm. What is the term for this type of outline?
Pseudocode
Sketch
Compiler
Interpreter
Finding and fixing errors in programs
Tech support
Decompose
Debugging
Fixing
An error in a program that prevents the program from running as expected
Error report
Bug
Mistake
Algorithm
What is the smallest unit of measurement used to quantify computer data?
a bridle
a bit
marble
a tablespoon
What is a high-level programming language that was developed in the mid-1970s? It is now used to write applications for nearly every available platform.
Scratch
Bark-Bark
tynker
C++
Which is the correct definition of Flowcharts
Uses Symbols to show the logical steps to solve the problem
English-like statements of the logic of the program
Which is the correct definition of a Graphical User interface
Part of your computer screen where you type computer instructions
Allows to interact using a graphical environment
Which is not true about the Importance of Programming
To automate the different tasks
To provide intelligent and powerful machines
To provide slower communication
To automate, collect, manage, calculate, and analyze the process data accurately
To create software and applications that help computer and mobile users in daily life.
Select the correct definitions of Sequential Operation
Sequential is a very simple design.
The step where a decision must be made.
It does not involve conditional or iterative processing.
Design in this type is normally from top to bottom or left to right.
Which is true about Conditional Operation
Does not involve conditional or iterative processing.
A more convenient way to handle multiple selections or multiple alternatives.
A step where a decision must be made.
The looping mechanism causes repetition.
The correct definition of Function Call Operation
Loop mechanism
A convenient way to handle multiple selections
Ask questions and choose an action based on the available options
Depicts a sub-process or sub-routine
What is the best way to think about a "Syntax Error" while programming?
The computer has used to find your location and hates everyone from your town
The computer is overheating and just wants you to stop to let it cool down
The computer needs to have its software upgraded
The computer did not understand the statement that you entered
What will the following program print out:
>>> x = 15
>>> x = x + 5
>>> print (x)
"print x"
15
5
20
x + 5
Python scripts (files) have means that end with:
.png
.doc
.exe
.py
Which of these words are reserved words in Python?
machine
if
break
todo
while
What is the proper way to say "Goodbye" to Python?
//stop
quit()
Which of the parts of a computer actually executes the program instructions?
Input/Output Devices
Secondary Memory
Main Memory
Central Processing Unit (CPU)
A USB memory stick is an example of one of the following components of computer architecture.
Output Device
Main Memory
Central Processing Unit
Secondary Memory
In the following code,
>>> print (98.6)
What is 98.6?
A conditional statement
An interation/loop statement
A constant
A variable
Which of the following is a comment in Python?
/* This is a test */
This is a test
#This is a test
//This is a test
What does the following code print out?
>>> print("123" + "abc")
123+abc
123abc
This is a syntax error because you cannot add strings.
hello world
In the following code,
>>> x = 42
What is "x"?
A constant
A function
A variable
A constant Processing Unit
Which of the following is not a python reserved word?
for
if
else
speed
Assume the variable x has been initialized to an integer value (e.g., x = 3). What does the following statement do?
>>> x = x + 2
Produce the value "false" because "x" can never equal "x+2"
Retrieve the current value for x, add two to it and put the sum back into x
This would fail as it is a syntax error
Create a function called "x" and put the value 2 in the function
What is the value of the following expression
>>> 42 % 10
Hint - the "%" is the remainder operator
2
10
420
1042
What will be the value of x after the following statement executes:
>>> x = 1 + 2 * 3 - 8 / 4
3.0
4
5.0
15
What will be the value of x when the following statement is executed:
>>> x = int (98.6)
99
100
98
6
What do we do to a Python statement that is immediately after an if statement to indicate that the statement is to be executed only when the if statement is true?
Underline all of the conditional code
Start the statement with a "#" character
Indent the line below the if statement
Begin the statement with a curly brace {
Which of these operators is not a comparison / logical operator?
>=
>
!=
==
=
What is true about the following code segment:
>>> if x == 5 :
>>> print('Is 5')
>>> print('Is Still 5')
>>> print('Third 5')
Only two of the three print statements will print out if the value of x is less than zero.
The string 'Is 5' will never print out regardless of the value for x.
Depending on the value of x, either all three of the print statements will execute or none of the statements will execute
The string 'Is 5' will always print out regardless of the value for x.
When you have multiple lines in an if block, how do you indicate the end of the if block?
You use a curly brace { after the last line of the if block
You capitalize the first letter of the line following the end of the if block
You de-indent the next line past the if block to the same level of indent as the original if statement
You omit the semicolon ; on the last line of the if block
What is the Python reserved word that we use in two-way if tests to indicate the block of code that is to be executed if the logical test is false?
else
iterate
otherwise
A closing curly brace followed by an open curly brace like this }{
What will the following code print out?
>>> x = 0
>>> if x < 2 :
>>> print('Small')
>>> elif x < 10 :
>>> print('Medium')
>>> else :
>>> print('LARGE')
>>> print('All done')
Small
Medium All done
Small All done
Small Medium LARGE All done
For the following code,
>>> if x < 2 :
>>> print('Below 2')
>>> elif x >= 2 :
>>> print('Two or more')
>>> else :
>>> print('Something else')
What value of 'x' will cause 'Something else' to print out?
x = -2
x = 2.0
This code will never print 'Something else' regardless of the value for 'x'
x = 2
In the following code (numbers added) - which will be the last line to execute successfully?
(1) astr = 'Hello Bob'
(2) istr = int(astr)
(3) print('First', istr)
(4) astr = '123'
(5) istr = int(astr)
(6) print('Second', istr)
2
6
1
3
For the following code:
>>> astr = 'Hello Bob'
>>> istr = 0
>>> try:
>>> istr = int(astr)
>>> except:
>>> istr = -1
What will the value be for istr after this code executes?
It will be the 'Not a number' value (i.e. NaN)
0
-1
The istr variable will not have a value
Which Python keyword indicates the start of a function definition?
help
sweet
def
break
In Python, how do you indicate the end of the block of code that makes up the function?
You put a
You add the matching curly brace that was used to start the function
You de-indent a line of code to the same indent level as the def keyword
You put the "END" keyword in column 7 of the line which is to be the last line of the function
In Python what is the input() feature best described as?
A user-defined function
A built-in function
A conditional statement
The central processing unit
What does the following code print out?
>>> def thing():
>>> print('Hello')
>>> print('There')
There
defthing
thingHelloThere
Hello
In the following Python code, which of the following is an "argument" to a function?
>>> x = 'banana'
>>> y = max(x)
>>>print(y)
'banana'
max
x
What will the following Python code print out?
>>> def func(x) :
>>> print(x)
>>> func(10)
>>> func(20)
x20
funcfunc
10
20
x10
x20
What is the most important benefit of writing your own functions?
To avoid having more than 10 lines of sequential code without an indent or de-indent
Following the rule that whenever a program is more than 10 lines you must use a function
Avoiding writing the same non-trivial code more than once in your program
Following the rule that no function can have more than 10 statements in it
What is wrong with this Python loop:
>>> n = 5
>>> while n > 0 :
>>> print(n)
>>> print('All done')
There should be no colon on the while statement
while is not a Python reserved word
The print('All done') statement should be indented four spaces
This loop will run forever
What does the break statement do?
Jumps to the "top" of the loop and starts the next iteration
Exits the currently executing loop
Exits the program
Resets the iteration variable to its initial value
What does the continue statement do?
Exits the program
Resets the iteration variable to its initial value
Exits the currently executing loop
Jumps to the "top" of the loop and starts the next iteration
What does the following Python program print out?
>>> tot = 0
>>> for i in [5, 4, 3, 2, 1] :
>>> tot = tot + 1
>>> print(tot)
15
10
0
5
What is the iteration variable in the following Python code:
>>> friends = ['Joseph', 'Glenn', 'Sally']
>>> for friend in friends :
>>> print('Happy New Year:', friend)
>>>print('Done!')
Glenn
Joseph
Sally
friend
What is a good description of the following bit of Python code?
>>> zork = 0
>>> for thing in [9, 41, 12, 3, 74, 15] :
>>> zork = zork + thing
>>> print('After', zork)
Compute the average of the elements in a list
Find the smallest item in a list
Count all of the elements in a list
Sum all the elements of a list
What will the following code print out?
>>> smallest_so_far = -1
>>> for the_num in [9, 41, 12, 3, 74, 15] :
>>> if the_num < smallest_so_far :
>>> smallest_so_far = the_num
>>> print(smallest_so_far)
Hint: This is a trick question and most would say this code has a bug - so read carefully
42
3
74
-1
Which reserved word indicates the start of an "indefinite" loop in Python?
while
break
for
def
indef
