*) +!),% -.+ /01 2 *#! 3 & ) & 5(+',

Size: px
Start display at page:

Download "*) +!),% -.+ /01 2 *#! 3 & ) & 5(+',"

Transcription

1

2 !"#!$% & '(!& & ) *) +!) % -.+ /01 2 *#! 3 & ) )2$0! & 5(+'!" # ) 6

3 & & ) 5 ' 5 4+! !'5 :/ 0; <= 7

4 )3 )99;? +.+? +' 0' ) :'4=/ ' ' AA0! 0 ' 4' %+ ': ' $ = ' ' ' 0! )! 7 " ' B'C' 0 B '' 4 ' ' 0 D? +D) + ' + $ 05 $ EB# # ' & ) "!BF;9B :FBF=G;979CF477> 0H I ' >

5 ''')2! $% ' & & '( " The CIS Forum is a Learning Community to support K-12 Computer and Information Science Education. We aim to provide a variety of high-quality resources support for teaching and online activities for students. The CIS Forum is just being launched. We are getting help from our friends at Math Forum. At first we are focusing on Computer Science but we will also be developing an Information Science Forum. Please check back to watch us grow. 0 3 " 0 ) For more information contact CISForum@drexel.edu $0+)2I4 + ' G

6 # %!? +.+?$1 #!3& ) #!? +.+ A1) A/+) %!&+ //3 + (0 $!? +.+ B 330! & ) "0 #! 3 & ) # )# J!".+ $0+ ()'!? # #! &+) E%(0 5 ) '(!& & ) KK24 E!"'#& ) D )+ ;

7 Tips and Techniques Sneaking in Extra Material Daniel Joyce Department of Computing Sciences Villanova University Villanova PA USA Introduction Did you ever wish you could sneak some extra material into a course but it just doesn t fit with the syllabus and there s not enough time to add another unit to an already crowded calendar? In this Tips and Techniques I described how I snuck some computing history into an introductory programming course. 2. Context When I found myself teaching an introductory programming course for the first time in many years in the Fall of 1999 I decided to try to include some exposure to computing history as part of the course. Part of the impetus for this mini-project was the fact that the first programming assignment that I gave to the class involved programs to encode and decode secret messages. I was struck by the fact that one of the earliest uses of computers during World War 2 was related to this first assignment. So I decided to tie the description of the assignment to computing history. Once I got started it became a challenge to also tie later assignments to some aspect of computing history. All together I linked 7 of my 10 programming assignments to computing history and/or some aspect of the modern use of computers. Hopefully this provided the students with a realistic context for the toy programs they were developing. 3. Application My first programming assignment required the students to write two programs one to encode a string so that it is difficult to read and one to decode the string. The assignment description was posted on the web and began as follows: The early development of computers was hastened by the need for computing power during World War 2 in England computing pioneer/genius Alan Turing continued his work on cryptanalysis (coding and decoding messages) work which helped the Allies immensely during the war. Read about this chapter (and others) of Turing's interesting life: Alan Turing - A short biography. The last five words of the above description were a web link to an interesting essay about the life of Turing. The problem introduction was of course followed by a description of the required program functionality along with some sample input and output. So the pattern was set. I would give an assignment description write a little bit about how it ties into some aspect of computing and provide a link to a related web site for the curious. Here is a list of the assignments that I managed to present following this pattern: 1. Encoding and decoding secret messages were connected to Alan Turing s life and work. 2. Creating an applet to draw art in its window was with a bit of a stretch related to Donald Knuth and his series titled The Art of Computer Programming. Hey I never claimed the connections between the assignments and history would be perfect! 3. A program that holds a conversation with its user is more clearly related to Joseph Weizenbaum s "Turing Test" program Eliza. 4. For an exercise in repetition I noted that it was the repetition inherent in engineering work that prompted pioneers like the German engineer Conrad Zuse to search for mechanical aids. 5. Implementing the dice game Pig was related to the relationship between computers and games. 6. Running multiple simulations of the Pig game and collecting and presenting information about the results was tied to the use of computers for simulations and modeling. 7. Extending the previous assignment to present the information as a histogram was tied to the use of computers for information visualization. The assignment descriptions are available at 4. Results If nothing else I had some fun making the assignments and tying them to computing history. It would be fair to ask if the students actually followed the links and read the historical information. Based on the results of a history related surprise bonus question that I included on the first test I would have to report that the students did not seem to absorb much of the historical information during the first third of the semester. But the good news is that they did much better on the history related surprise bonus questions on the remaining tests! Imagine that.

8 ?$1 # 3& )!3! 5?$!! 0 C %+ 5 5 '+0 +0 ;'L# 1 ' 0 >9 ' ' '' 0 7' + 1 D 1 0!!L :!0!L!+0 L! 01 4!!+L '?$= 0 D4 0 < ' 4 0. %+ '' ++. 4#

9 # )!? :1 = 5 '1! D + ' ) '''+ +M+ )4 C

10 )%*+)!) - *(./ #! )!? +.+!? +BC98G! :;B9=GBCF777!I+ + ) 4 +N N '2! J 1 1 0! '!4!+! 0 '0 1 +? +.+ ' ' !0 +4 ' ) ' 0 0) ' J 0 ++' 3 4!'! : '<= '0! 4 1 ' 'A 'A ' ' 1 ' 0!0 +!' 0 0 ' 4 3 +' 0!0 J ' ' ) '+) 1 0 0!' 0 24! '!+00! 00 0 ' '+ +0 1!' $ 0 4 ' 5&' : = G9O6&' 0 J6:=3 52)$2)6&' 0 J6:$= )4 ' 1 ) 5'''+ +M879B91 0 ''!0 0 D'!' + +&+! '0+'4!!' 1 ' ' 0' + '! 0 ) '+0 1 ' ' 0+ 1 ' ' )! 4 B9

11 % )!&+ A1) A P+ +1+J!!! 0A A +0 1' 0 4 '! 0!+!0! 0 0': 4=5 5''' +B990 /+) KK' 1 0 0!+0 +0!+ +@ ' 01 + ' B+! + :.=0 5 BB : '4 = ' "0B! 0'5 5''' +9G BB

12 //3 + (0 $? +.+ 5& :+ += &D D+ 0 '' 0 : ='!! ' ' ' : JJ=) & ' 00$$ / ( / ' + :' = 4! ' %!1 $4+!! '!+ BG + (' 0 5 ( 2 '. % ) ' ' #+ '/!/0 ' ' ' %!+ 2 8 ' ' 3# //22 (' 0 0+ ' ) B ' + ' 00+( ' ++ ' 0'+ ' B

13 B 330 & ) ''0I 5): ' = + ' ' 0B B+! +0 + B +0 0!0 '0 NQBB799N +NQG99N 72 &NQG99N >$NQF999N G(NQG999N ;"NQG99N F)')'NQG9999N 8#NQGBGN C"NQ>7;F9N B9""NQ7G7F9N BBNQB7>9N BNQB779CN E!R# +S+ N + + ' />4! + >00 72! + 0 >! 0+ >0!;2!; +> + 1+! 01!!. 0 B7

14 "0 # 3 & ) )$ $/ $/ ) 0 ' +' ' 3 +'! + $/0'!@! "! +G 0 02! + 3'0 ' 0 ' B>

15 )$ 5HHHHHHHHHHHHHHHHHH "0* 5HHHHHHHHHHHHHHHHHHH 0''0 B ' 5 :=! :=!:=! :=. ) 01 0! 01 ) ) + 0:' = 1 7 B9 0 +/ B9! 2 0'' )"/)/( B 7 > G ; F 8 C B9 + B9 B99 B999 G999 B9999 G9999 B99999 $.$$")/( B 7 > G ; F 8 C B9 + B9 B99 B999 G999 B9999 G9999 B99999 )(/)/( B 7 > G ; F 8 C B9 + B9 B99 B999 G999 B9999 G9999 B99999

16 #()/( B 7 > G ; F 8 C B9 + B9 B99 B999 G999 B9999 G9999 B99999 T.E)/( B 7 > G ; F 8 C B9 + B9 B99 B999 G999 B9999 G9999 B99999 > ('! + J(0!! G 2 0! '! ' 0 '! - ' G ' 2 4! 0 ' 0 :0 $ := ) ) $00) ) #) T) ; 4! ' 0 ' ) :! =U- 9 0G99 )!$00! B999 #T$ ' ' G "! F " 4!' + 0 3! P' + ' 8994;99+P' 1 + '.4B99!999 B;

17 # )# J ".+ 5& # :BB B = +#: = + ' 0 0 +'' 0 D0 ' '# # ' 0 5 #: = ' #' ' 0! :> '= # D0 0D 0+! # 7 5 0!! 3 ' 0 0! 03 ' ' ' 'N D! 0 0 ' ' 3 # 0! 0+ ' ' ' ' ' '! 0 0 ' BF

18 ## 5!$ 0.5 B?0 B 0 # 7 ># $ 0 +0 G# +53 >!$ 0 0+ B# A+A!! 0 B 0 # 0$ 0 7# 0 7 B # 7 ># 0 G# 0$ 0 ;# F# >3 ' B ' ' # 7 ' ' ># 0$ 0 G# + ;# 0 0 F# 0$ 0 8# C# 0 +5 >! 0 ' ' B# A A +5 7! B# A)!D A # G B # B8

19 $0+ ()'? # 5& KK )! 0 Chapter 4 C++ Problem Solving with if statements 0 X>0? false negative true 1 positive Chapter 4 C++ Where is my animal? Write a program that uses nested if statements so the user can play a guessing game which of 4 animals the computer is thinking of. For example the program asks if the animal has 4 legs then if it can bark. The output should print the answer and tell the user if she guessed correctly. Scales? 4 legs? Bark? C++ Chapter 4 C++ More about if statements if/else statements review These 2 statements can be replaced if (x>0) cout << positive ; if (x<=0) cout << negative ; by one if/else statement: if (x>0) cout << positive ; else cout << negative ; This is bi-directional program flow or branching. and or not Chapter 4 C++ More about if statements &&! Logical Operators if ((age >12) && (age<19)) cout<< teenager ; if ((letter = Y ) (letter = y )) cout<< yes continue ; if (!((age>12) && (age<19)) cout << not a teenager ; Chapter 4 C++ Compound if statements if (condition) { multiple statements} else {multiple statements} If (temp<=40) {cout<< Wear a coat today. ; cout<< It is cold. ;} else {cout<< Do you wear a sweater (S) or blazer (B)? ; cin<< answer; If (answer == B ) cout << Use your blazer. //nested if else cout << Wear your sweater. cout<< It is cool but warming up. ; } Chapter 4 C++ if/else without ladder if (stones >1) cout<< large ; else if ((stones>0.1) && (stones <=1)) cout << medium ; if (stones < 0.1) cout << small ; large > 1 cm medium.1 to1 cm small < 0.1 cm clam fish cat dog Chapter 4 C++ if / else ladder Multi-directional flow Simplified ladder form: if (stones >1) cout<< large ; else if (stones>0.1) cout << medium ; else cout << small ; extra comparisons (boolean statements) removed Chapter 4 C++ if rewritten as ladder sample if (grade>=90) cout <<"A"; if (grade>=80) && (grade <90) cout <<"B"; if (grade>=70) && (grade <80) cout <<"C"; if (grade>=60) && (grade <70) cout <<"D"; if (grade <60) cout <<"F"; if (grade>=90) cout <<"A"; //must have a semicolon before the else else if (grade>=80) // eliminate && (grade <90) cout <<"B"; else if (grade>=70) // eliminate && (grade <80) cout <<"C"; else if (grade>=60) // eliminate && (grade <70) cout <<"D"; else // eliminate (grade <60) cout <<"F"; Chapter 4 C++ if problem Review 8 Write a program that asks the user for the number of strokes on one hole of a par 5 golf game then displays a message according to the list: 1 Hole in one! 2 Double-Eagle 3 Eagle 4 Birdie 5 Par 6 Bogey 7 Triple- Bogey 8 Double-Bogey 9 Or more = Disaster Chapter 4 C++ if problem C++ Review 11 Write a program that asks the user for the length width and height of a package and displays reject if any dimension is C++ greater than 10 cm and Accept if all the dimensions are less than or equal to 10 cm. Like a sieve stops at the right step of the ladder Chapter 4 C++ if problem Review 9 Find logic errors in this code. It should display one message or any value of Height. Rewrite this using an if/else ladder if (Height <150) cout<< short <<endl; if ((Height>150) && (Height<175)) cout << medium <<endl; if (Height>175) cout << tall <<endl; C++ BC

20 # &+) A + A +' 4 ) 3 ) B*3 6!4)!)) ' R S + %!7"%! B &+ 3! + ' 2! + 7 &+ ' 0 4 ' 2' -! + 3! + ' B > 2! + ' G (+' ' 9

21 : R&' S ) = 3 ) 42!4)!)) %!7"%! B &+ '05 '+ &'+! '! ' 0' 4 ' 0 ' + QG99!B9 0 :QB9= 0BG.! + 'QB89 :Q99>= '' ' 4 0 ' ' 3 : 0 =! ' + ' +@! +0 0! 0 ' ' 54 :QB89= ! -0 $! '!! & 5 NN 50V0 NN 0 '+ NN + :: == 00 + ' ' '! 0+:+!!0 = B

22 E%(0 5 ) '( & & ) I 5& ):%+= E%(0!!!0 ' 0E01! 0 0@ ' E0 ' ' ' :' = + 0! /! 0/# 70! ' E0! +! 0 0!0! 0 01 ' + + 'E 4! 0! : <= '0 +4)

23 E "'#& ) )B 2 99>99G 3 ' '!!!0'!! 01 ;O 4) :0 ' 4= ' )*)' := * := &*& := $*$':= (*(:= "*":= W* + * X Y )0 Y! 0 0 3! 4 0! 0! 4! X Y )0 Y ;O)4Y Y >0+! R PS + J ' G! X YG )0 YQ$99 ;O)4YQ$99 YQ$99 P! P! P! P! P 7

24 P 0! 4! 0' ' 3 +! HHHHHHHHHHHHHHHHH 01 0: =2" ZZ(##$(ZZ + '5 P 2" 3 (: 0'' > ' B99 = ; J # )0 ) ' ' ' 4 : 3' 06= )0:X 0 0J= ) 4 0!0!;O 4! 0! 4! ' ' R PS 0 2 B 2 := [:= ' [' := + ' ' 01 ' #+1 ;!"!! #$% $&&!!!FF >

Unit 7. 'while' Loops

Unit 7. 'while' Loops 1 Unit 7 'while' Loops 2 Control Structures We need ways of making decisions in our program To repeat code until we want it to stop To only execute certain code if a condition is true To execute one segment

More information

LAB 4.1 Relational Operators and the if Statement

LAB 4.1 Relational Operators and the if Statement LAB 4.1 Relational Operators and the if Statement // This program tests whether or not an initialized value of num2 // is equal to a value of num1 input by the user. int main( ) int num1, // num1 is not

More information

conditional statements

conditional statements L E S S O N S E T 4 Conditional Statements PU RPOSE PROCE DU RE 1. To work with relational operators 2. To work with conditional statements 3. To learn and use nested if statements 4. To learn and use

More information

Programming Language. Functions. Eng. Anis Nazer First Semester

Programming Language. Functions. Eng. Anis Nazer First Semester Programming Language Functions Eng. Anis Nazer First Semester 2016-2017 Definitions Function : a set of statements that are written once, and can be executed upon request Functions are separate entities

More information

Programming Language. Control Structures: Selection (switch) Eng. Anis Nazer First Semester

Programming Language. Control Structures: Selection (switch) Eng. Anis Nazer First Semester Programming Language Control Structures: Selection (switch) Eng. Anis Nazer First Semester 2018-2019 Multiple selection choose one of two things if/else choose one from many things multiple selection using

More information

Other Loop Options EXAMPLE

Other Loop Options EXAMPLE C++ 14 By EXAMPLE Other Loop Options Now that you have mastered the looping constructs, you should learn some loop-related statements. This chapter teaches the concepts of timing loops, which enable you

More information

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester Programming Language Control Structures: Repetition (while) Eng. Anis Nazer Second Semester 2017-2018 Repetition statements Control statements change the order which statements are executed Selection :

More information

Today in CS161. Lecture #7. Learn about. Rewrite our First Program. Create new Graphics Demos. If and else statements. Using if and else statements

Today in CS161. Lecture #7. Learn about. Rewrite our First Program. Create new Graphics Demos. If and else statements. Using if and else statements Today in CS161 Lecture #7 Learn about If and else statements Rewrite our First Program Using if and else statements Create new Graphics Demos Using if and else statements CS161 Lecture #7 1 Selective Execution

More information

CompSci 94 Making Decisions February 8, Prof. Susan Rodger

CompSci 94 Making Decisions February 8, Prof. Susan Rodger CompSci 94 Making Decisions February 8, 2018 Prof. Susan Rodger CompSci 94 Spring 2018 1 Class Today Asking questions and making decisions Using functions If statements CompSci 94 Spring 2018 2 Review

More information

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

Lesson 6 page 1. If you look at the bottom right of the Scratch color choices, you will see it say MORE BLOCKS in Purple.

Lesson 6 page 1. If you look at the bottom right of the Scratch color choices, you will see it say MORE BLOCKS in Purple. Lesson 6 page 1 LESSON 6: Feb 17-24 Hello everyone! We are going to learn about BYOB this week. This acronym stands for Build Your Own Blocks. If you look at the bottom right of the Scratch color choices,

More information

4.1. Chapter 4: Simple Program Scheme. Simple Program Scheme. Relational Operators. So far our programs follow a simple scheme

4.1. Chapter 4: Simple Program Scheme. Simple Program Scheme. Relational Operators. So far our programs follow a simple scheme Chapter 4: 4.1 Making Decisions Relational Operators Simple Program Scheme Simple Program Scheme So far our programs follow a simple scheme Gather input from the user Perform one or more calculations Display

More information

Relational Operators EXAMPLE. C++ By

Relational Operators EXAMPLE. C++ By C++ By 9 EXAMPLE Relational Operators Sometimes you won t want every statement in your C++ program to execute every time the program runs. So far, every program in this book has executed from the top and

More information

Introduction to Computer Science with Python Course Syllabus

Introduction to Computer Science with Python Course Syllabus CodeHS Introduction to Computer Science with Python Course Syllabus Course Overview and Goals The CodeHS Introduction to Computer Science in Python course teaches the fundamentals of computer programming

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection) Control Structures A computer can proceed: In sequence Selectively (branch) - making

More information

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.5. for loop and do-while loop

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.5. for loop and do-while loop Superior University Department of Electrical Engineering CS-115 Computing Fundamentals Experiment No.5 for loop and do-while loop Prepared for By: Name: ID: Section: Semester: Total Marks: Obtained Marks:

More information

5. Selection: If and Switch Controls

5. Selection: If and Switch Controls Computer Science I CS 135 5. Selection: If and Switch Controls René Doursat Department of Computer Science & Engineering University of Nevada, Reno Fall 2005 Computer Science I CS 135 0. Course Presentation

More information

Review. Relational Operators. The if Statement. CS 151 Review #4

Review. Relational Operators. The if Statement. CS 151 Review #4 Review Relational Operators You have already seen that the statement total=5 is an assignment statement; that is, the integer 5 is placed in the variable called total. Nothing relevant to our everyday

More information

Today in CS161. Week #3. Learn about. Writing our First Program. See example demo programs. Data types (char, int, float) Input and Output (cin, cout)

Today in CS161. Week #3. Learn about. Writing our First Program. See example demo programs. Data types (char, int, float) Input and Output (cin, cout) Today in CS161 Week #3 Learn about Data types (char, int, float) Input and Output (cin, cout) Writing our First Program Write the Inches to MM Program See example demo programs CS161 Week #3 1 Data Types

More information

Score score < score < score < 65 Score < 50

Score score < score < score < 65 Score < 50 What if we need to write a code segment to assign letter grades based on exam scores according to the following rules. Write this using if-only. How to use if-else correctly in this example? score Score

More information

3. Probability 51. probability A numerical value between 0 and 1 assigned to an event to indicate how often the event occurs (in the long run).

3. Probability 51. probability A numerical value between 0 and 1 assigned to an event to indicate how often the event occurs (in the long run). 3. Probability 51 3 Probability 3.1 Key Definitions and Ideas random process A repeatable process that has multiple unpredictable potential outcomes. Although we sometimes use language that suggests that

More information

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING MULTIPLE SELECTION To solve a problem that has several selection, use either of the following method: Multiple selection nested

More information

Chapter 4: Making Decisions

Chapter 4: Making Decisions Chapter 4: Making Decisions 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than or equal to

More information

LECTURE 04 MAKING DECISIONS

LECTURE 04 MAKING DECISIONS PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 04 MAKING DECISIONS

More information

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++

More information

Chapter 4: Making Decisions

Chapter 4: Making Decisions Chapter 4: Making Decisions CSE 142 - Computer Programming I 1 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >=

More information

BITG 1223: Selection Control Structure by: ZARITA (FTMK) LECTURE 4 (Sem 1, 16/17)

BITG 1223: Selection Control Structure by: ZARITA (FTMK) LECTURE 4 (Sem 1, 16/17) BITG 1223: Selection Control Structure by: ZARITA (FTMK) LECTURE 4 (Sem 1, 16/17) 1 Learning Outcomes At the end of this lecture, you should be able to: 1. Explain the concept of selection control structure

More information

Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Getting Started with Java Using Alice 1 Copyright 2013, Oracle and/or its affiliates. All rights Objectives This lesson covers the following objectives: Use the IF control structure to effect execution

More information

Preprocessor Directives

Preprocessor Directives C++ By 6 EXAMPLE Preprocessor Directives As you might recall from Chapter 2, What Is a Program?, the C++ compiler routes your programs through a preprocessor before it compiles them. The preprocessor can

More information

Grade 7/8 Math Circles Fall Nov.4/5 The Pythagorean Theorem

Grade 7/8 Math Circles Fall Nov.4/5 The Pythagorean Theorem 1 Faculty of Mathematics Waterloo, Ontario Centre for Education in Mathematics and Computing Grade 7/8 Math Circles Fall 2014 - Nov.4/5 The Pythagorean Theorem Introduction A right triangle is any triangle

More information

Welcome to the First Grade Math with LEGO Bricks Printable Pack!

Welcome to the First Grade Math with LEGO Bricks Printable Pack! Welcome to the First Grade Math with LEGO Bricks Printable Pack! This printable math pack contains three activities that are perfect for first grade math. Activity #1: Measuring with LEGO Bricks Activity

More information

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage: Discussion 1H Notes (Week 3, April 14) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 More on Arithmetic Expressions The following two are equivalent:! x = x + 5;

More information

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode STUDENT OUTLINE Lesson 8: Structured Programming, Control Structures, if- Statements, Pseudocode INTRODUCTION: This lesson is the first of four covering the standard control structures of a high-level

More information

Chapter 5: Control Structures II (Repetition) Objectives (cont d.) Objectives. while Looping (Repetition) Structure. Why Is Repetition Needed?

Chapter 5: Control Structures II (Repetition) Objectives (cont d.) Objectives. while Looping (Repetition) Structure. Why Is Repetition Needed? Chapter 5: Control Structures II (Repetition) Objectives In this chapter, you will: Learn about repetition (looping) control structures Explore how to construct and use countercontrolled, sentinel-controlled,

More information

In this lesson you will learn: How to capture the input from the user. How to write programs using variables and lists. Athletics Swimming Gymnastics

In this lesson you will learn: How to capture the input from the user. How to write programs using variables and lists. Athletics Swimming Gymnastics Lesson 4 A m In this lesson you will learn: How to capture the input from the user. How to write programs using variables and lists. Advanced Scratch Sports Day Jyoti and Tejas are planning to create a

More information

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017 Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls

More information

while for do while ! set a counter variable to 0 ! increment it inside the loop (each iteration)

while for do while ! set a counter variable to 0 ! increment it inside the loop (each iteration) Week 7: Advanced Loops while Loops in C++ (review) while (expression) may be a compound (a block: {s) Gaddis: 5.7-12 CS 1428 Fall 2015 Jill Seaman 1 for if expression is true, is executed, repeat equivalent

More information

Commas. Review Mini Lesson

Commas. Review Mini Lesson Commas Review Mini Lesson Why use a Comma? l A comma is a punctuation mark that helps keep distinct ideas separate. l Commas signal meaning, so it is critical to use them correctly! How do I use commas

More information

Boolean Data-Type. Boolean Data Type (false, true) i.e. 3/6/2018. The type bool is also described as being an integer: bool bflag; bflag = true;

Boolean Data-Type. Boolean Data Type (false, true) i.e. 3/6/2018. The type bool is also described as being an integer: bool bflag; bflag = true; Programming in C++ If Statements If the sun is shining Choice Statements if (the sun is shining) go to the beach; True Beach False Class go to class; End If 2 1 Boolean Data Type (false, ) i.e. bool bflag;

More information

Getting Ready to Teach Unit 6

Getting Ready to Teach Unit 6 Getting Ready to Teach Unit 6 Learning Path in the Common Core Standards In this unit, students study the attributes of triangles, quadrilaterals, and other polygons. They find perimeter and area of various

More information

Basic Triangle Congruence Lesson Plan

Basic Triangle Congruence Lesson Plan Basic Triangle Congruence Lesson Plan Developed by CSSMA Staff Drafted August 2015 Prescribed Learning Outcomes: Introduce students to the concept of triangle congruence and teach them about the congruency

More information

Computer Engineering Department CMPE110 Midterm Sample Questions, 2017/ Fall

Computer Engineering Department CMPE110 Midterm Sample Questions, 2017/ Fall Computer Engineering Department CMPE110 Midterm Sample Questions, 2017/2018 - Fall Q1) Give the correct answer for following: 1. What is the value of x after the following statement? double x; x = 3.0

More information

Computer Science 202 Introduction to Programming The College of Saint Rose Fall Topic Notes: Conditional Execution

Computer Science 202 Introduction to Programming The College of Saint Rose Fall Topic Notes: Conditional Execution Computer Science 202 Introduction to Programming The College of Saint Rose Fall 2012 Topic Notes: Conditional Execution All of our programs so far have had one thing in common: they are entirely sequential.

More information

Computational Expression

Computational Expression Computational Expression Conditionals Janyl Jumadinova 10 October, 2018 Janyl Jumadinova Computational Expression 10 October, 2018 1 / 16 Computational Thinking: a problem solving process Decomposition

More information

Add Subtract Multiply Divide

Add Subtract Multiply Divide ARITHMETIC OPERATORS if AND if/else AND while LOOP Order of Operation (Precedence Part 1) Copyright 2014 Dan McElroy Add Subtract Multiply Divide + Add - Subtract * Multiply / Divide = gives the quotient

More information

Statements execute in sequence, one after the other, such as the following solution for a quadratic equation:

Statements execute in sequence, one after the other, such as the following solution for a quadratic equation: Control Structures Sequence Statements execute in sequence, one after the other, such as the following solution for a quadratic equation: double desc, x1, x2; desc = b * b 4 * a * c; desc = sqrt(desc);

More information

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017 Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The

More information

Math 7 Notes - Unit 4 Pattern & Functions

Math 7 Notes - Unit 4 Pattern & Functions Math 7 Notes - Unit 4 Pattern & Functions Syllabus Objective: (3.2) The student will create tables, charts, and graphs to extend a pattern in order to describe a linear rule, including integer values.

More information

Boolean Unit (The obvious way)

Boolean Unit (The obvious way) oolean Unit (The obvious way) It is simple to build up a oolean unit using primitive gates and a mux to select the function. Since there is no interconnection between bits, this unit can be simply replicated

More information

LOOPS. Repetition using the while statement

LOOPS. Repetition using the while statement 1 LOOPS Loops are an extremely useful feature in any programming language. They allow you to direct the computer to execute certain statements more than once. In Python, there are two kinds of loops: while

More information

CSci 1113, Fall 2015 Lab Exercise 4 (Week 5): Write Your Own Functions. User Defined Functions

CSci 1113, Fall 2015 Lab Exercise 4 (Week 5): Write Your Own Functions. User Defined Functions CSci 1113, Fall 2015 Lab Exercise 4 (Week 5): Write Your Own Functions User Defined Functions In previous labs, you've encountered useful functions, such as sqrt() and pow(), that were created by other

More information

LAB: WHILE LOOPS IN C++

LAB: WHILE LOOPS IN C++ LAB: WHILE LOOPS IN C++ MODULE 2 JEFFREY A. STONE and TRICIA K. CLARK COPYRIGHT 2014 VERSION 4.0 PALMS MODULE 2 LAB: WHILE LOOPS IN C++ 2 Introduction This lab will provide students with an introduction

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

Encryption à la Mod Name

Encryption à la Mod Name Rock Around the Clock Part Encryption à la Mod Let s call the integers,, 3,, 5, and the mod 7 encryption numbers and define a new mod 7 multiplication operation, denoted by, in the following manner: a

More information

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators Boolean & If Statements Introduction to Decision Structures Chapter 4 Fall 2015, CSUS Chapter 4.1 Introduction to Decision Structures Different Types of Decisions A decision structure allows a program

More information

Chapter 2. Flow of Control. Copyright 2016 Pearson, Inc. All rights reserved.

Chapter 2. Flow of Control. Copyright 2016 Pearson, Inc. All rights reserved. Chapter 2 Flow of Control Copyright 2016 Pearson, Inc. All rights reserved. Learning Objectives Boolean Expressions Building, Evaluating & Precedence Rules Branching Mechanisms if-else switch Nesting if-else

More information

Chapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14

Chapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14 Chapter 4: Making Decisions 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than or equal to

More information

CHAPTER 2.1 CONTROL STRUCTURES (SELECTION) Dr. Shady Yehia Elmashad

CHAPTER 2.1 CONTROL STRUCTURES (SELECTION) Dr. Shady Yehia Elmashad CHAPTER 2.1 CONTROL STRUCTURES (SELECTION) Dr. Shady Yehia Elmashad Outline 1. The if Selection Structure 2. The if/else Selection Structure 3. The switch Multiple-Selection Structure 1. The if Selection

More information

Chapter 3. More Flow of Control. Copyright 2008 Pearson Addison-Wesley. All rights reserved.

Chapter 3. More Flow of Control. Copyright 2008 Pearson Addison-Wesley. All rights reserved. Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

INTRODUCTION TO COMPUTER SCIENCE - LAB

INTRODUCTION TO COMPUTER SCIENCE - LAB LAB # O2: OPERATORS AND CONDITIONAL STATEMENT Assignment operator (=) The assignment operator assigns a value to a variable. X=5; Expression y = 2 + x; Increment and decrement (++, --) suffix X++ X-- prefix

More information

IT Introduction to Programming for I.T. Midterm Exam #1 - Prof. Reed Spring 2008

IT Introduction to Programming for I.T. Midterm Exam #1 - Prof. Reed Spring 2008 IT 101 - Introduction to Programming for I.T. Midterm Exam #1 - Prof. Reed Spring 2008 What is your name?: (0 points) There are two sections: I. True/False..................... 20 points; ( 10 questions,

More information

Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1

Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1 Conditionals Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary CS105 04 Conditionals 1 Pick a number CS105 04 Conditionals 2 Boolean Expressions An expression that

More information

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points Files to submit: 1. HW3.py This is a PAIR PROGRAMMING Assignment: Work with your partner! For pair

More information

Computer Programming. Basic Control Flow - Decisions. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons

Computer Programming. Basic Control Flow - Decisions. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Computer Programming Basic Control Flow - Decisions Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Objectives To be able to implement decisions using if statements To learn

More information

Math 7 Notes - Unit 4 Pattern & Functions

Math 7 Notes - Unit 4 Pattern & Functions Math 7 Notes - Unit 4 Pattern & Functions Syllabus Objective: (.) The student will create tables, charts, and graphs to etend a pattern in order to describe a linear rule, including integer values. Syllabus

More information

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Programming Basics and Practice GEDB029 Decision Making, Branching and Looping Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Decision Making and Branching C language possesses such decision-making capabilities

More information

Beginning Programming in Perl

Beginning Programming in Perl http://www.perl.com Beginning Programming in Perl copyright 1999 Edward Irvine. Freely distributable for educational use. Contact the author for commercial (magazines etc) use. In this unit of study, you

More information

Python for Informatics

Python for Informatics Python for Informatics Exploring Information Version 0.0.6 Charles Severance Chapter 3 Conditional execution 3.1 Boolean expressions A boolean expression is an expression that is either true or false.

More information

Control Structures. A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping

Control Structures. A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping Control Structures A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping Conditional Execution if is a reserved word The most basic syntax for

More information

Binary Multiplication

Binary Multiplication inary Multiplication The key to multiplication was memorizing a digit-by-digit table Everything else was just adding 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 2 2 4 6 8 2 4 6 8 3 3 6 9 2 5 8 2 24 27 + You ve got

More information

Introduction to Programming Nanodegree Syllabus

Introduction to Programming Nanodegree Syllabus Introduction to Programming Nanodegree Syllabus Learn to Code Before You Start Prerequisites: In order to succeed, we recommend having experience using the web, being able to perform a search on Google,

More information

Lecture 7: General Loops (Chapter 7)

Lecture 7: General Loops (Chapter 7) CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 7: General Loops (Chapter 7) The Need for a More General Loop Read marks of students from the keyboard

More information

Boolean Expressions. Is Equal and Is Not Equal

Boolean Expressions. Is Equal and Is Not Equal 3 MAKING CHOICES Now that we ve covered how to create constants and variables, you re ready to learn how to tell your computer to make choices. This chapter is about controlling the flow of a computer

More information

Sending LESSON PLAN UNIT 1. Essential Question How do you connect with others through ?

Sending  LESSON PLAN UNIT 1. Essential Question How do you connect with others through  ? LESSON PLAN Sending Email UNIT 1 Essential Question How do you connect with others through email? Lesson Overview Students explore how they can use email to communicate with real people within their schools,

More information

Chapter 5 Selection Statements. Mr. Dave Clausen La Cañada High School

Chapter 5 Selection Statements. Mr. Dave Clausen La Cañada High School Chapter 5 Selection Statements Mr. Dave Clausen La Cañada High School Objectives Construct and evaluate Boolean expressions Understand how to use selection statements to make decisions Design and test

More information

5.1. Examples: Going beyond Sequence

5.1. Examples: Going beyond Sequence Chapter 5. Selection In Chapter 1 we saw that algorithms deploy sequence, selection and repetition statements in combination to specify computations. Since that time, however, the computations that we

More information

Software Design & Programming I

Software Design & Programming I Software Design & Programming I Starting Out with C++ (From Control Structures through Objects) 7th Edition Written by: Tony Gaddis Pearson - Addison Wesley ISBN: 13-978-0-132-57625-3 Chapter 4 Making

More information

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program 1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize

More information

Polygons in the Coordinate Plane

Polygons in the Coordinate Plane Polygons in the Coordinate Plane LAUNCH (8 MIN) Before How can you find the perimeter of the sandbox that the park worker made? During How will you determine whether the park worker s plan for the sandbox

More information

Lesson 7: If Statement and Comparison Operators

Lesson 7: If Statement and Comparison Operators JavaScript 101 7-1 Lesson 7: If Statement and Comparison Operators OBJECTIVES: In this lesson you will learn about Branching or conditional satements How to use the comparison operators: ==,!=, < ,

More information

Making Decisions In Python

Making Decisions In Python Making Decisions In Python In this section of notes you will learn how to have your programs choose between alternative courses of action. Decision Making Is All About Choices My next vacation? Images:

More information

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4 More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4 Ziad Matni Dept. of Computer Science, UCSB Administrative CHANGED T.A. OFFICE/OPEN LAB HOURS! Thursday, 10 AM 12 PM

More information

Processing. Data Visualization Programming Language. By Rutvi Joshi. Processing Visualization Language- By Rutvi Joshi

Processing. Data Visualization Programming Language. By Rutvi Joshi. Processing Visualization Language- By Rutvi Joshi Processing Data Visualization Programming Language What is Processing? A Graphical Sketch Book and Environment, to graphically teach the fundamentals of computer science But it has evolved into a tool

More information

15-110: Principles of Computing, Spring 2018

15-110: Principles of Computing, Spring 2018 15-110: Principles of Computing, Spring 2018 Programming Assignment 11 (PA11) Due: Tuesday, May 1 by 9PM IMPORTANT ANNOUNCEMENT You cant drop this assignment even if it is your lowest PA score. Failure

More information

Exam I Review Questions Fall 2010

Exam I Review Questions Fall 2010 Exam I Review Questions Fall 2010 The following review questions are similar to the kinds of questions you will be expected to answer on Exam I (scheduled for Oct. 14), which will cover LCR, chs. 1 7,

More information

if / if else statements

if / if else statements if / if else statements December 1 2 3 4 5 Go over if notes and samples 8 9 10 11 12 Conditionals Quiz Conditionals TEST 15 16 17 18 19 1 7:30 8:21 2 8:27 9:18 3 9:24 10:14 1 CLASS 7:30 8:18 1 FINAL 8:24

More information

Computer Science II Lecture 1 Introduction and Background

Computer Science II Lecture 1 Introduction and Background Computer Science II Lecture 1 Introduction and Background Discussion of Syllabus Instructor, TAs, office hours Course web site, http://www.cs.rpi.edu/courses/fall04/cs2, will be up soon Course emphasis,

More information

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5 CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5 This fifth problem set explores the regular languages, their properties, and their limits. This will be your first foray into computability theory,

More information

Excel Basics Fall 2016

Excel Basics Fall 2016 If you have never worked with Excel, it can be a little confusing at first. When you open Excel, you are faced with various toolbars and menus and a big, empty grid. So what do you do with it? The great

More information

More about Loops and Decisions

More about Loops and Decisions More about Loops and Decisions 5 In this chapter, we continue to explore the topic of repetition structures. We will discuss how loops are used in conjunction with the other control structures sequence

More information

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011 The American University in Cairo Department of Computer Science & Engineering CSCI 106-07&09 Dr. KHALIL Exam-I Fall 2011 Last Name :... ID:... First Name:... Form I Section No.: EXAMINATION INSTRUCTIONS

More information

CMSC 201 Computer Science I for Majors

CMSC 201 Computer Science I for Majors CMSC 201 Computer Science I for Majors Lecture 02 Intro to Python Syllabus Last Class We Covered Grading scheme Academic Integrity Policy (Collaboration Policy) Getting Help Office hours Programming Mindset

More information

C++ Programming: From Problem Analysis to Program Design, Fourth Edition. Chapter 5: Control Structures II (Repetition)

C++ Programming: From Problem Analysis to Program Design, Fourth Edition. Chapter 5: Control Structures II (Repetition) C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 5: Control Structures II (Repetition) Objectives In this chapter, you will: Learn about repetition (looping) control structures

More information

Math assignments. (Modern Language Association). offers examples for the general format of MLA research papers,.

Math assignments. (Modern Language Association). offers examples for the general format of MLA research papers,. Math assignments. (Modern Language Association). offers examples for the general format of MLA research papers,. Math assignments >>>CLICK HERE

More information

6 th Grade Enriched Math to 7 th Grade Pre-Algebra

6 th Grade Enriched Math to 7 th Grade Pre-Algebra Summer Work 2018 6 th Grade Enriched Math to 7 th Grade Pre-Algebra 6 th Grade Skills that are necessary for success in 7 th grade and beyond: - ability to add subtract, multiply and divide decimals, fractions

More information

Chapter 3, Selection. Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved.

Chapter 3, Selection. Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved. Chapter 3, Selection 1 The bool Type and Operators 2 One-way if Statements if (booleanexpression) { statement(s); } if (radius >= 0) { area = radius * radius * PI; cout

More information

Outline. Introduction to Programming (in C++) Algorithms on sequences. Reasoning about loops: Invariants. Maximum of a sequence. Maximum of a sequence

Outline. Introduction to Programming (in C++) Algorithms on sequences. Reasoning about loops: Invariants. Maximum of a sequence. Maximum of a sequence Outline Introduction to Programming (in C++) Algorithms on sequences. Reasoning about loops: Invariants. Algorithms on sequences Treat-all algorithms Search algorithms Reasoning about loops: invariants

More information

Digital Citizenship. Student Packet Grades K-2 UNIT

Digital Citizenship. Student Packet Grades K-2 UNIT Digital Citizenship Student Packet Grades K-2 UNIT 3 DOS AND DON TS OF POWERFUL PASSWORDS Powerful Passwords Directions Do you know how to make a powerful password? Write the word DO or DON T into each

More information

CMSC 2833 Lecture Memory Organization and Addressing

CMSC 2833 Lecture Memory Organization and Addressing Computer memory consists of a linear array of addressable storage cells that are similar to registers. Memory can be byte-addressable, or word-addressable, where a word typically consists of two or more

More information

Sending LESSON PLAN UNIT 1. Essential Question How do you connect with others through ? Lesson Overview. Learning Objectives

Sending  LESSON PLAN UNIT 1. Essential Question How do you connect with others through  ? Lesson Overview. Learning Objectives LESSON PLAN Sending Email GRADES K-2 UNIT Essential Question How do you connect with others through email? Lesson Overview Students explore how they can use email to communicate with real people within

More information