CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Winter 2012.

Slides:



Advertisements
Similar presentations
CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2012.
Advertisements

CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2010.
CSE 113 Introduction to Computer Programming Lecture slides for Week 10 Monday, October 31 th, 2011 Instructor: Scott Settembre.
Chapter 5: Repetition Statements. In this chapter, you will learn about: Basic loop structures while loops Interactive while loops for loops Loop programming.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop.
CS123 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2010.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
CPS120: Introduction to Computer Science Fall: 2002 Instructor: Paul J. Millis.
CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All.
CPS120 Introduction to Computer Science Iteration (Looping)
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2009 ©By the author. All rights reserved. Permission.
CS 140 Computer Programming (I) Second semester (3 credits) Imam Mohammad bin Saud Islamic University College of Computer Science and Information.
CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Spring 2010.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2009 ©By the author. All rights reserved. Permission.
The Writing Algoma University Marissa Ross, Instructor.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
CPSC 171 Introduction to Computer Science Algorithm Discovery and Design.
CPS120: Introduction to Computer Science Winter 2002 Instructor: Paul J. Millis.
C++ for Engineers and Scientists, Third Edition1 Objectives In this chapter, you will learn about: Basic loop structures while loops Interactive while.
CS 122 / CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.
Visual Basic Programming
CS122 Instructor Assignments Winter, 2010 Term. Overview Some changes in assignments due to schedule considerations Some new initiatives / revised strategies.
CS101 Computer Programming I Chapter 4 Extra Examples.
CS 153: Concepts of Compiler Design September 16 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2010 ©By the author. All rights reserved. Permission.
CS122/CS123 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Summer 2011.
CS122 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Winter 2012.
CS 123 Lab 4 Instructor: Mark Boady Course Designer: Professor Bruce Char Department of Computer Science Drexel University Spring 2013.
CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS122 / CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.
CS 121 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2010.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2010 ©By the author. All rights reserved. Permission.
CPS120 Introduction to Computer Science Iteration (Looping)
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2012 ©By the author. All rights reserved. Permission.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
CS123 Engineering Computation Lab Lab 1 Section Instructor: Mark Boady Content By: Bruce Char Department of Computer.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Spring 2012.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Winter, 2011 ©By the author. All rights reserved.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2012 ©By the author. All rights reserved. Permission.
CS 122 Engineering Computation Lab Lab 4 Dan De Sousa and Bruce Char Department of Computer Science Drexel University Summer 2009 ©By the author. All rights.
Midterm Review Important control structures Functions Loops Conditionals Important things to review Binary Boolean operators (and, or, not) Libraries (import.
CS123 Engineering Computation Lab Lab 2 Instructor: Mark Boady Content By: Bruce Char Department of Computer Science Drexel University.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2013.
CS 121 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Fall 2010 ©By the author. All rights reserved. Permission.
CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011.
CSE 1340 Introduction to Computing Concepts Class 1 ~ Intro.
CS122 – Quiz 2 Winter, 2013 Quiz Hints. Quiz 2 Hints Question 1 – working with the “if” statement  First, we did not fully explain the structure of the.
CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Winter 2010.
CS122 – Quiz 1 Winter, 2013 Quiz Hints. Quiz 1 Hints Question 1 – Understanding procs  First, we did not fully explain the structure of the Maple proc,
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
CS123 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Spring 2013.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2011.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2012.
CS 122/CS123 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.
CS122 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Winter 2013.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
Control Flow (Python) Dr. José M. Reyes Álamo.
CS122 Engineering Computation Lab Lab 4
CS 121 Engineering Computation Lab Lab 3
CS123 Engineering Computation Lab Lab 4
CS122 Engineering Computation Lab Lab 3
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
Repetition Control Structure
Chapter 8: More on the Repetition Structure
Presentation transcript:

CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Winter 2012

Review of Lab 1 Cycle Lab 1 – pre lab quizlet, lab 1 and quiz 1 completed along with pre lab 2 quizlet –Quiz grades to be issued this week –More usage of CLC noticed than in cs121 Initial lab completion session held on 1/24 – about 112 attendees Major Lab 1 concepts to remember –Use of code edit regions to develop, test and debug scripts –Use of Car Simulator API to learn about “while” loops

Administrative Notes Please contact your individual instructors with questions and problems CLC (room 147 UC) will be staffed at same times as for cs121 in Fall (odd weeks) In order to be eligible for a lab completion session, please see you instructor at the end of the lab period In order to be eligible for a makeup lab session, you must contact your instructor for permission as soon as you miss your regularly scheduled lab Extra Consultation sessions –If you have not already done so, please apply as per the global directions (enrollment ends on Friday, 2/3) –Students with B or lower in cs121 eligible –1 st session on Tuesday, 2/7

Lab 2 Overview Based on materials from Chapter 10, 11 and 12 readings –More practice using the Car Simulator API to simulate engr102 robot lab manipulations Additional usage of simple and nested “while” loops and counter variables –Repetitive action “for” loops – chapter 12 –Using “if” statements to make decisions – also from chapter 12

Lab 2 Overview – Part 0 Part 0 exercises include: –A – introduction to “for” loops –B – introduction to “if” statements –C – review of Lab 1 Car Simulator exercise (Problem 5 – moving to the nth gap) – comparing “while” and “for” loop based solutions In this lab’s Part 0, we will focus on analyzing and comparing existing code solutions as opposed to developing and running code

Lab 2 Overview Problem 1 – moving in a figure 8 Problem 2 – recognizing a 4 way intersection Problem 3 – moving on a diagonal Problem 4 – moving around a barrier to a target

Lab 2 programming concepts Nested loop constructs Using both “while” and “for” loops Introduction to “for” and “if” Advanced techniques for specifying conditions –Used in both “while” loop and “if” statement constructs –Emphasis on boolean operators “and” and “or”

Lab 2 programming concepts Nested loop constructs In lab 1 – moving in a square problem (1) –Outer loop  loop over 4 sides »Inner loop  create 1 side by “move(1)” In lab 1 – nth gap problem (5) – outer loop  loop over n or n-1 gaps »Inner loop  move(1) until you get to a gap Nested loop opportunity in lab 2 –Problem 1 – figure 8 (using 2 squares)

Lab 2 programming concepts “for” loop introduction –Appropriate to use when the number of loop iterations is known prior to loop entry Ex – move(1) n times to trace the side of a square Ex – loop 4 times to trace all 4 sides of a square Ex – loop over a list of elements where “nops” defines the loop size –Basic syntax for i from 1 to n do –Loop action end do; –Will demo with introductory examples in Part 0

Lab 2 programming concepts “if” statement introduction –Enables a program to selectively execute code only if a condition is true –Basic “if” syntax if (condition) then –Action to execute if condition is true end if; –We will cover additional variants of the “if” later if – else if – elif - else –Will demo with introductory examples in Part 0

Lab 2 programming concepts Constructing conditions –while (condition) do –if (condition) then Value of condition is always “true” or “false” In Lab 1: –while isTouching(d, ‘bt’) do move(1); –end do; Also  not isTouching(d,’bt’)  if not touching a barrier is true, then keep moving – not at the target yet

Lab 2 programming concepts Constructing conditions –while (condition) do –if (condition) then In lab 2: –Problem 2 – detecting a 4 way intersection while (isTouching(0,’bt’) or isTouching(Pi/2,’bt’) or etc……. –If any side of the car is touching any wall, then keep moving – you are not at an intersection Use “and” instead of “or” if you want to check if touching several walls –Problem 3 (diagonal step movement) printing message when number of steps exceeds 10 –if (stepcount = 11) then # set to 11 if you are testing within the loop »Print(“some message”) –end if;

Course activities next week (2/6-2/12) Quiz 2 will be released on Friday (2/3) at 6 PM –Deadline: Thursday (2/9) at 4:30 PM –Makeup quiz – from Friday (2/10) at 9 AM through Sunday (2/12) at 11:00 PM 30% penalty Pre-lab 3 quizlet –From Thursday (2/9 – noon) through Monday (2/13 – 8 AM) Be sure to visit the CLC for quiz assistance