Introduction
Identifiers are descriptive names that are mapped to locations in the computer's memory. Once a memory location is given a specific name, you can refer to that location using the identifier rather than the numeric address. This system of associating a name with a memory location allows you to choose a name that is meaningful to the contents of a particular memory location.
Read
Problem Solving Basics and Computer Programming
By Ron Pasko and Matt Bauer
Assignment
Use lucidchart in your google drive.
- Create a flowchart for the following problem:
Now, on your own, work through the three steps of decomposition, flowcharting, and pseudocode for the following example.You have a store that sells lemons and oranges. Oranges are $.30 each and lemons are $.15 each. Your program should get from the user the numbers of oranges and lemons he/she wants and outputs the total amount of money they owe you.
- Create a flowchart for the following problem:
Given 2 numbers, determine whether or not their sum is greater than 100.
- Create a flowchart that:
will take as input the type of restaurant the user ate at, the cost of the meal, the number of people in his/her party, and how good the service was. Determine the dollar amount of the tip.
Base Tip:
Diner: 12%
Good Restaurant: 15%
Fancy Restaurant: 20%
Additions/Subtractions:
Poor Service: -2%
Good Service: +0%
Excellent Service: +2%
1-5 in party: +0%
6-10 in party: +3%
more than 10: +5%
Abstraction
How much information do you really need?
We are surrounded by a tremendous amount of information. Often you don't need all the details to understand a simulation, model or problem. Abstraction is the removal of detail so you can focus on the essence.
Automatic Generation of Detail Maps by Maneesh Agrawala
Generalization
Generalization is recognizing patterns.
When you write computer programs you abstract and generalize in order to create functions with parameters. Your goal is to write code that is not repetitive. Think about what inputs make sense to the problem.
Let's say you wanted to draw a square, triangle, pentagon, etc. By generalizing you should be able to see that the function that you want to create is how to draw an n-gon.
Abstraction is also seen when creating contracts, or specifications between entities. For example, say you are going to hire a contractor to dig a ditch. If you followed proper rules of abstraction, what would you be able to specify to the contractor?
- Who on their team should dig the ditch.
- Where to dig the ditch.
- How to dig the ditch.
- All of the above.
- None of the above.
Following the rules of abstraction, you're not allowed to tell the person how (method or personnel) to do the work. That's for them to decide. You ARE allowed to specify the important things about the task, like how much you'll pay, where it should be done, how big it should be, when you need it done by, when to stop (e.g., when they hit water or find the treasure), etc. This allows full flexibility for the contractor to do it in the best way they want (one big backhoe, an army of moles, etc).
Computational thinking is the the process of abstracting and generalizing.
You do not need to know how something works to use it effectively.
Kleenex is facial tissue, a Hoover is a vacuum cleaner, your social security number is how you are identified in the US. These are everyday examples of abstraction.
Functions
Functions take 0 or more inputs and return just 1 output
The same inputs yield the same outputs
Functions are not affected by states (prior history)
Variables inside functions do not get modified (no mutattion)
Nothing else happens (no side effects)
It can run on any computer and get the same answer.
Domain is the class of input a function accepts
Range is all the possible return values of a function