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¶

1. A precise list of instructions we want a computer to follow is called a _____
2. Computers are very smart
• True
• False
3. Computer programs are written in some programming ______.
4. A computer follows a precise list of ___________.
5. Python is interpreted, while C++ is compiled, what is the difference?
• Interpreted is faster
• Compiled is faster
6. The rules that define how programs are actually written are called ________.
7. A properly written statement in a programming language has meaning. This is also called ________.

Control Structures¶

1. A structure is a programming construct with a single input and a single

output

• True
• False
2. All of these are basic structured forms except:

• Sequence
• Decision
• Assignment
• Loop
3. The while loop processes the loop body at least once

• True
• False
4. We can write a decision structure which omits the False process

• True
• False

Binary Numbers¶

1. The characters we use for our normal numbers are called
• Numbers
• Symbols
• Digits
2. The number system that uses ten symbols is called the _______ system
• base ten
• normal
• decimal
3. The number system used by computers that has only two symbols is called the ______ system
• base two
• binary
• discrete
4. The first electronic computer was named:
• HAL
• IBM
• ENIAC
• MAC
5. What is the next number in the binary number system after 11?
• 12
• 100
• 110
6. What is the decimal number equivalent of the binary number 101?
• 11
• 3
• 5
• 6
7. A transistor is just a fancy electronic _______
8. 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¶

1. We store programs and data in the computer’s ________
2. The electronic device that was invented in the early 1950’s that let computers get very small is a _______
3. The computer processes instructions as the system _________ ticks
4. Can you name the sequence of actions taken by the processor as it runs each instruction in your program?
• true
• false
5. In the Pentium computer eight bits is called a _______
6. A large series of bytes each numbered from zero to some large value is called the _________
7. The two basic kinds of memory we find in a computer are read/write and read only
• true
• false
8. 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¶

1. When we start working on a problem, we need a good ________________ statement
2. The first thing we do in solving the problem is to _______________ the problem
3. The fancy term for the series of steps we want a computer to follow to solve a problem is an ________________
4. 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
5. The use of proper indentation in a program is called good program ______________
6. Since modern programming languages can have blanks just about anywhere, we do not need to worry about program style.
• true
• false
7. The rules for writing a program are different for different programming _______________
8. 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¶

1. A function is a fancy name for a box of code we can use over and over.
• true
• false
2. Functions must return a value to the caller.
• true
• false
3. 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
1. We call the program construct “sqrt(x)” a _____________

Data, variables and simple expressions¶

1. 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.

1. The “+” symbol is called a mathematical _______________
2. The “*” symbol identifies the mathematical ________________ operation
3. A number with no fractional part is called an ________________
4. 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
5. When Python evaluates “*” * 50, what gets produced?

Flow charts and pseudo code¶

1. Can you draw diagrams of the three basic structures of programming?
• True - good
• False - study more!
1. Can you write pseudo code for each of the three basic structures?
• True
• False
2. In IPO, the P refers to ________________.

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?
• 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 Python sqrt 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.)