Week 1-5 Flashcards
(196 cards)
What is computer programming?
The process of explaining how to solve a problem in a way that a computer can understand. Which can be referred to as an “algorithm”.
What is an algorithm?
An algorithm is a precise and unambiguous ordered list of instructions that eventually ends with a correct solution.
What is the proper Problem Solving Strategy?
Define (IPO Chart), Design (Pseudo Code & Flow Chart), Test, Implement (Programming Language), Test.
We cannot solve problems we don’t understand. Understanding a problem begins with defining it. How do we define a problem?
To define a problem we need to identify 3 parts: the input, the process to follow, and the output.
Define the Input stage of an IPO.
input: information we know that helps solve the problem.
Define the processing stage of an IPO.
Processing: the algorithm that takes us from input to output.
Define the output stage of an IPO.
output: the result we want to solve for.
What is the purpose of an IPO chart?
An IPO chart helps organize our thinking so we don’t get confused - this stage can be considered brainstorming.
Does the IPO chart use detailed information?
No, the IPO chart helps define a general solution to a problem, you don’t include the specific date from the problem. That way, you can use the same IPO chart regardless how many times the input values change.
What is pseudocode?
Once we know what information is available, and what is required as output we can design an algorithm to solve the problem. We do this in a language which is less open to interpretation than english but is also less formal than a programming language. We call this language pseudocode.
What are some verbs used in the input stage of pseudocode?
Read, Get, Obtain… etc
What are some verbs used in the processing stage of pseudocode?
Compute, Calculate, Set…etc
What are some verbs used in the output stage of pseudocode?
Print, Display, Show….etc
Why do we build flow charts?
It is often helpful to visualize a design with a flow chart.
How is a flow chart designed?
We use circles to identify the start and end of the algorithm, and rectangles to contain the pseudocode instructions.
What are the orders of a design?
1 - IPO Chart 2 - Pseudocode & Assumptions 3 - Flow Chart 4 - TRACE or Truth Table 5 - Code & Test
How can we develop confidence that our design solves the problem?
We must test the design carefully: first with any sample values and then with any other possible values.
When designing tests we need to be very clear on what we are trying to accomplish. What are the 3 main things we test for?
- test that our code works as expected.
- test that our code works reasonably when bad values are put in.
- test that we have explored all the paths through our code.
What is a variable?
- the part of a program that can “remember” values.
- boxes in memory that can hold 1 thing at a time
ex. length = 3, word = “hello”
What is an expression?
- any piece of code that provides a value.
ex. 3, 3 + 2, x > 10, “Hi”, len( “hi” )
What is a statement?
- the smallest complete action of a program.
- comparable to a sentence.
ex. print( “hello” )
What does an input expression look like?
input( “What is your name? “ )
What is a literal?
A value that is explicitly defined in your source code is called a literal.
What is the primary difference between a literal and a variable?
The variable may change over the course of the program’s execution. A literal will remain the same.