Exam 1 Review¶
The first exam will consist of a written part and a lab part. The written part is closed book, and consists of short-answer questions covering the concepts we are studying.
I will post an open-book lab problem for the exam on Tuesday evening. You will have until midnight on Thursday, Oct 11 to post your lab problem on GitHub.
Review materials¶
These notes contain some sample questions for you to try out before you take the first exam. Note that most of these are in the form of multiple choice/True-False, and the actual exam will not be that kind. I will ask questions on the important concepts we have been studying, and you get to explain them to me. I am hoping that working through these questions will get you ready to explain those concepts.
Here are the sample questions:
Introduction¶
A precise list of instructions we want a computer to follow is called a _____
- Computers are very smart
True
False
Computer programs are written in some programming ______.
A computer follows a precise list of ___________.
- Python is interpreted, while C++ is compiled, what is the difference?
Interpreted is faster
Compiled is faster
The rules that define how programs are actually written are called ________.
A properly written statement in a programming language has meaning. This is also called ________.
Control Structures¶
- A
structure
is a programming construct with a single input and a single output
True
False
- A
All of these are basic structured forms except:
Sequence
Decision
Assignment
Loop
The
while loop
processes the loop body at least onceTrue
False
We can write a decision structure which omits the
False
processTrue
False
Binary Numbers¶
The characters we use for our normal numbers are called
Numbers
Symbols
Digits
The number system that uses ten symbols is called the _______ system
base ten
normal
decimal
The number system used by computers that has only two symbols is called the ______ system
base two
binary
discrete
The first electronic computer was named:
HAL
IBM
ENIAC
MAC
What is the next number in the binary number system after 11?
12
100
110
What is the decimal number equivalent of the binary number 101?
11
3
5
6
A transistor is just a fancy electronic _______
Computers can manipulate any kind of data we can
encode as binary numbers
invent a device to attach to the computer to read the data
convert into decimal symbols
Hardware Overview¶
We store programs and data in the computer’s ________
The electronic device that was invented in the early 1950’s that let computers get very small is a _______
The computer processes instructions as the system _________ ticks
Can you name the sequence of actions taken by the processor as it runs each instruction in your program?
true
false
In the Pentium computer eight bits is called a _______
A large series of bytes each numbered from zero to some large value is called the _________
The two basic kinds of memory we find in a computer are read/write and read only
true
false
When we turn off the power to a computer, the program remains in memory.
true
false
28. The memory we use to store programs while the computer is turned off is called flash memory
true false
Problem Solving¶
When we start working on a problem, we need a good ________________ statement
The first thing we do in solving the problem is to _______________ the problem
The fancy term for the series of steps we want a computer to follow to solve a problem is an ________________
At any point in time while a computer is working through your program, we say that the program is in some specific ____________
state
country
computer
The use of proper indentation in a program is called good program ______________
Since modern programming languages can have blanks just about anywhere, we do not need to worry about program style.
true
false
The rules for writing a program are different for different programming _______________
You should understand your programming language well enough to be able to manually walk your program through its steps.
true
false
37. Before you can be sure your program works properly, you should ____________ your program.
Simple Python functions¶
A function is a fancy name for a box of code we can use over and over.
true
false
Functions must return a value to the caller.
true
false
The items between parentheses in a function definition are called ________
variables
numbers
parameters
41. Can you explain how we made a box on the graphics screen using our graphics functions?
true
false
We call the program construct “sqrt(x)” a _____________
Data, variables and simple expressions¶
Can you explain why do we use names for data in our programs?
true
false
44. When we create a new variable, we need to _________________ it so it has a know value.
The “+” symbol is called a mathematical _______________
The “*” symbol identifies the mathematical ________________ operation
A number with no fractional part is called an ________________
When the computer sees a variable name in an assignment statement
It uses the value stored in that variable
It asks the user what value to use
It halts since it does not know what to do
When Python evaluates “*” * 50, what gets produced?
Flow charts and pseudo code¶
Can you draw diagrams of the three basic structures of programming?
True - good
False - study more!
Can you write pseudo code for each of the three basic structures?
True
False
In IPO, the P refers to ________________.
Additional Review Material¶
Here are more sample problems you should study before you take the first exam. There might be a few problems we discussed in class that are not included in the notes. You should look them up, either in the text, or by doing a bit of research.
Problem Solving Basics¶
Computers need precise instructions. Why is it so hard for humans to provide these instructions?
To solve a problem you need two basic things: tools and instructions. Why is it important to understand your tools?
What is a problem statement?
What should you do with a problem statement?
What does “decomposition” mean?
What do we mean when we say a computer is in some “state” at some moment?
Why is it important to be able to manually walk through your instructions to the computer?
Programming Languages¶
You have a “syntax” error. What does this mean?
You have a “semantic” error. What does this mean?
What is a “machine language”?
What is “assembly language”
What is the difference between a “compiler” and an “interpreter”?
Number SYstems¶
In our decimal number system, each column means something specific. What does it represent?
What is the decimal equivalent of 1101 (which is a binary number)?
What do we mean by the “base” of a number system?
What is the biggest decimal number you can store in an eight bit container?
We encode our data so we can work with it in the machine. Can the computer tell what kind of data is in some memory location? If not, how to we figure that out?
Suppose you tell the machine to multiply a string by a number. Does that make any sense?
Basic Python Structures¶
How does Python process your code file?
Show an example of a Python program that prints out your name.
What will Python do with this line of code: “x = 5 + 10 * 43 - 6”
- What must you add to your program to use a module provided with Python
(like
sqrt
)?What are the three most important types of statements used in programming?
We used an “iteration” scheme to find the square root of some number. Explain basically how it works?
Designing a Program¶
We can use design tools like “flow charts” and “pseudo code” in designing a program. How are these used?
Draw a diagram showing how each of the three basic structures of programming work.
What is an “IPO” chart?
How can “baby stepping” help you in building a program?
Why is it important to end a work session with a program that runs?
Why do programmers us a “source code control system” like Git?
Python Expressions¶
Show an example of Python code that prints out “bigger”, “equal”, or “smaller” if a variable named “testnum” is greater, equal, or less that “testval”.
What is the difference between a “logical expression” and an “arithmetic expression”
What are the basic arithmetic operators in Python?
What are the Python logical operators?
What part of a decision statement is optional?
Show a “truth table” for the logical conjunctions “AND” and “OR”.
How do you use “short circuit” logical expression evaluation to stop Python from dividing by zero by accident.
What values for “test” will make the following expression evaluate to “True”?
test >= 5 or test <= 10
Show how we ask the user for an input value we can store in the variable “age” as an integer number.
What does the term “operator precedence” mean?
How do we cause Python3 to do integer division?
What does the “%” operator do?
Python Loops¶
Show an example loop that prints out “Hello” 10 times.
How does the “range” function work? (Just explain how it is used in a loop.)
Show code that adds up a series of numbers provided by the user. Stop when the user enters a negative nummber.
What line of code would you add to this loop to escape when the value of “count” is 1000?
count = 0
while True:
count = count + 1
print(count)
*
Python Functions¶
WHat is a function, and why are they important in programming
Show a simple Python function called
mysqrt
that returns a floating point value (cheat and use the standard Pythonsqrt
function to figure out the value).Show code that draws a “bulls eye” with four rings alternating between red and yellow. (You do not need to provide a complete program, just the calls you would use to draw this thing.)