CPSC 101/WMST 201: Connecting with
Computer Science
Module 4: Processes
Recipes from Scratch
Module 4.2: Recipes and variables
Here is a recipe for Jello Instant Pudding
1. put 3 cups of milk in a bowl
2. add entire contents of package
3. whisk for 2 minutes
4. transfer to serving bowls
5. let stand for 3-5 minutes
6. serve!
CPSC 101 – 2012W T1
2
Module 4: Processes
Learning Goals: at the end of this module, you will be able to: recognize and explain the five essential properties of an algorithm: input specified output specified definiteness effectiveness finiteness CPSC 101 – 2012W T1
3
Module 4: Processes
Learning Goals (continued) recognize and explain the concepts of sequences of instructions, variables, loops, functions, conditional statements, and arrays
in short programs specified in a programming language such as JavaScript, or in other clearly expressed processes (which may or may not be computer related)
CPSC 101 – 2012W T1
4
Module 4: Processes
Learning goals (continued): determine, simulate and explain how short programs or program fragments work make small modifications to short program fragments to achieve clearly specified tasks explain and simulate simple algorithms for fundamental problems such as searching and sorting
CPSC 101 – 2012W T1
5
Module 4: Processes
Module Outline
Programs and algorithms.
Recipes and variables.
Loops.
Functions.
Conditional statements.
Arrays.
CPSC 101 – 2012W T1
6
Module 4.1: Programs and algorithms
Exercise: write an algorithm for making a peanut butter and jam sandwich. Your algorithm can use: peanut butter sliced bread jam knife spoon plate
CPSC 101 – 2012W T1
7
Module 4.1: Programs and algorithms
? Did your group succeed in getting a proper sandwich made?
a) Yes, right away.
b) Yes, after 1-2 revisions to the instructions
c) Almost.
d) No.
CPSC 101 – 2012W T1
8
Module 4.1: Programs and algorithms
? What was the main point you took away from the exercise? a) Making sandwiches is hard.
b) Humans are smart.
c) Specifying a process precisely is hard.
d) Carrying out precise instructions is hard.
CPSC 101 – 2012W T1
9
Module 4.1: Programs and algorithms
Processes (programs, algorithms) are everywhere allow us to make computers and people do things they otherwise couldn’t.
you come up with 3
? Canprimarily meant to beexamples of “programs” not executed by computers?
CPSC 101 – 2012W T1
10
Module 4.1: Programs and algorithms
Jumping in at the deep end:
Processing: Depth
Scratch: Dancing triangles
[processing.org]
[scratch.mit.edu]
Don’t Panic!
It’s OK to not understand parts of a program
Web search can help
Experimentation aids understanding
Module 4: Processes
Module Outline
Programs and algorithms.
Recipes and variables.
Loops.
Functions.
Conditional statements.
Arrays.
CPSC 101 – 2012W T1
13
Module 4.2: Recipes and variables
Here is a more interesting recipe for Duck breast with Seville orange & savoy cabbage http://www.bbcgoodfood.com
Ingredients (for 4):
4 duck breasts
1 large Seville orange, zested and juiced
2 tbsp honey
2 cloves
1 cinnamon stick chicken stock fresh, cube or concentrate, made up to 300ml
1 savoy cabbage, quartered, heart removed and shredded butter mashed potato, to serve
CPSC 101 – 2012W T1
14
Module 4.2: Recipes and variables
Duck breast recipe (continued)
Preparation:
1. Heat a non-sticking frying pan.
2. Put in the duck breasts, skin side down, then turn down the heat and leave for 10 minutes until the fat on the duck
Related Documents: Essay about Programming concepts
to computer programming. Programs are directions in order, which gives the computer hardware the order in which to perform data. The two types of programming languages that will be compared in this paper are Procedural programming and Object-Oriented programming. Programmer often use flowchart diagram that can represents, and visualize the program process. The key difference between Procedural and Object-Oriented programming is the object-oriented program will break down programming task into objects…
Windows? They are created using something called Programming. Programming, at its simplest form, is lines of code (or text) you type into a computer, to tell it to do the actions you specify. Computer programming is used to create almost everything now. From Games, to the stuff you see on the screen of your phone, and even the whole Windows from Microsoft. Programming is a growing concept, and beginning to become part of our everyday lives. Programming can be useful in many ways, you can learn: To dive deeper into the Computer…
Part 3 Introduction to Object Orientated Programming Chapter 8 Learning About Classes and Objects In this chapter, you will learn how to: • Define and describe benefits of designing programs using object orientated design techniques. • Analyze the differences between structured programming techniques and object oriented programming techniques. • Define and apply the components of class objects to a business problem. • Demonstrate…
FOUNDATION REVIEW Contents FR.1 Graphing linear inequalities 2 FR.2 The linear programming model 7 FR.3 Interpreting linear programming results 13 Review questions 16 Introduction Linear programming is commonly used in short-term operations planning. In MA2, you will use linear programming and its related concepts to make relevant management accounting decisions. Knowing how to formulate and interpret a linear program will help you determine the optimum production plan to analyze various…
introduction to basic computing and programming concepts. Students gain an understanding of, and practical experience in, computer programming; practical experience in implementing informal prose descriptions of problem solutions using an imperative language; an understanding of, and practical experience in, designing, coding, testing and debugging simple algorithms; and an understanding of the principle of incremental development. Other topics include: the concept of program correctness; the differences…
Procedural programming is nothing more than a set of instructions which, tells someone how exactly something needs to be done. For example in a series circuit the sequential path must be met in order to get the expected output or voltage. Whereas the Object-oriented…
known as “linear programming.” In the book The Mathematical Method of Production Planning and Organization published in 1939, Kantorovich showed that all problems of economic allocation can be reduced to maximizing a function subject to constraints. Kantorovich introduced many new concepts into the study of mathematical programming such as giving necessary and sufficient optimality conditions on the base of supporting hyper planes at the solution point in the production space, the concept of primal-dual…
is the trend for a large portion of software in use today. We can make another comparison between two different models of programming - structured and object oriented programming. In structured programming, blocks of programming statements (code) are executed one after another. Control statements change which blocks of code are executed next. In object oriented programming, data are contained in objects and are accessed using special methods (blocks of code) specific to the type of object. There…
consider evidence on such stereotypes in the media, and connect that evidence to theories and research findings discussed in class or in your textbook. Goals for this paper: 1) Choose two media programs with different target audiences, observe some programming, and describe some differences in way stereotypes are represented. For example, you might choose a magazine targeted to men and another magazine targeted to women, and discuss gender stereotypes represented. Another possibility might be to watch…