Introduction to Computer Science – Chapter 5 CSc 2010 Spring 2011 Marco Valero.

Slides:



Advertisements
Similar presentations
CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Advertisements

CHAPTER 4 AND 5 Section06: Sequences. General Description "Normal" variables x = 19  The name "x" is associated with a single value Sequence variables:
String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
CS 1 with Robots Robot Sensors & Actuators Institute for Personal Robots in Education (IPRE)‏
Intro to Python Paul Martin. History Designed by Guido van Rossum Goal: “Combine remarkable power with very clear syntax” Very popular in science labs.
Computer Science 111 Fundamentals of Programming I Sequences: Lists.
Introduce about sensor using in Robot NAO Department: FTI-FHO-FPT Presenter: Vu Hoang Dung.
CMPT 120 Lists and Strings Summer 2012 Instructor: Hassan Khosravi.
CompSci Today’s topics Robots Myro Loops Notes from the Institute for Personal Robots in Education Upcoming ä More Python Reading Learning Computing.
Web Design. How to set up the robot How to link to robot How not to break my robot Sec Getting Started How to make it move How to control speed.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
Looping forever Reading/observing sensors (inputs) Reacting to sensors Obstacle sensors.
October 4, 2005ICP: Chapter 4: For Loops, Strings, and Tuples 1 Introduction to Computer Programming Chapter 4: For Loops, Strings, and Tuples Michael.
Introduction to Computer Science – Chapter 9 CSc 2010 Spring 2011 Marco Valero.
CompSci Today’s topics Java Review Just a bunch of headings meant to trigger questions A contraction of previous notes Upcoming Midterm Exam Reading.
Chapter 7 Lists and Tuples. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. Data Structures.
Fundamentals of Python: First Programs
Lists and Tuples Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Introduction to Computer Science – Chapter 4 CSc 2010 Spring 2011 Marco Valero.
Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
CIT 590 Intro to Programming Lecture 5 – completing lists.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 8 Working.
12/9/2010 Course A201: Introduction to Programming.
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 8 Lists and Tuples.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 8: Fun with strings.
More Strings CS303E: Elements of Computers and Programming.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
Sequences CMSC 120: Visualizing Information 2/26/08.
CIT 590 Intro to Programming Lecture 4. How are assignments evaluated Pay attention to what the HW says it is trying to teach you about ‘modular programming’
LISTS and TUPLES. Topics Sequences Introduction to Lists List Slicing Finding Items in Lists with the in Operator List Methods and Useful Built-in Functions.
Python Programing: An Introduction to Computer Science
Introduction to Computer Science – Chapter 6 CSc 2010 Spring 2011 Marco Valero.
Computer Science 101 Python Lists. Literals, Assignment, Comparisons, Concatenation Similar to the behavior of strings so far a = [1, 2, 3] b = range(1,
Strings CSE 1310 – Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington 1.
Python Lists and Sequences Peter Wad Sackett. 2DTU Systems Biology, Technical University of Denmark List properties What are lists? A list is a mutable.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
Web Design. How to link the robot How to turn on the robot Sec Getting Started What is python Programming in python How to move the robot How to.
String and Lists Dr. José M. Reyes Álamo.
Main Points: - Working with strings. - Problem Solving.
CS 100: Roadmap to Computing
Intro to CS Sept 22/23, 2015.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Engineering Innovation Center
Lists Part 1 Taken from notes by Dr. Neil Moore & Dr. Debby Keen
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Introduction to Strings
Perl Variables: Array Web Programming.
Lists – Indexing and Sorting
Loop Structures and Booleans Zelle - Chapter 8
4. sequence data type Rocky K. C. Chang 16 September 2018
Intro to Computer Science CS1510 Dr. Sarah Diesburg
String and Lists Dr. José M. Reyes Álamo.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Programming Training Main Points: - Working with strings.
Lists – Indexing and Sorting
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Topics Introduction to File Input and Output
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Introduction to Computer Science
Lists – Indexing and Sorting
Test Automation For Web-Based Applications
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CSE 231 Lab 6.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Lists basics A container is a construct used to group related values together and contains references to other objects instead of data. A list is a container.
Introduction to Computer Science
Presentation transcript:

Introduction to Computer Science – Chapter 5 CSc 2010 Spring 2011 Marco Valero

Overview Exteroceptor overview Camera sensor Light sensors Proximity sensors Lists Gamepad WWW Function redux

Exteroceptor Overview External sensors (exteroceptor) Camera ▫Capable of taking still pictures Light sensor ▫Three light sensors on front of the robot can detect brightness ▫Three light sensors on Fluke card as well Proximity sensor ▫IR sensors on robot as well as obstacle sensors on the Fluke card

The Camera Camera is located on the front of the Fluke dongle takePicture( ) ▫ = “color”, “gray”, or empty show(picture) ▫Displays the picture savePicture(picture, filename) ▫Saves the picture to disk Taking grayscale photos is easier than taking color

Light Sensing getLight() returns a list of all three values of light sensors getLight( ) returns a value of the given position ▫ = ‘left’ | ‘center’ | ‘right’ | 0 | 1 | 2 Low values imply bright light

Light Sensing Camera can also be used to sense light with the getBright() function getBright( ) ▫ = ‘left’ | ‘center’ | ‘right’ | 0 | 1 | 2 Higher the value, the brighter the light Normalizing the values relative to motion is a useful idea

Proximity Sensing Two IR sensors on the robot and three on the card Robot has getIR() and getIR( ) ▫ = 0 | 1 | ‘left’ | ‘right’ Boolean values determining whether path is clear or not ▫1 implies nothing impedes path, 0 implies something does getObstacle() and getObstacle( ) ▫ = 0 | 1 | 2 | ‘left’ | ‘center’ | ‘right’ ▫Values from 0 to 7000, with 0 implying nothing in sensor’s path and high numbers implying the presence of an object

Lists List is a sequence of objects ▫Numbers, letters, strings, images We have seen lists before with the range function Lists can contain no items as well ▫[]

List Operations len(N) ▫Returns the length of the list, N Index a list: list[index] ▫Returns the element located at index, where index is a number 0 or higher ▫If a list contains n elements, the last index is n – 1 Slice operator: list[begin:end] ▫Returns a view of the list that starts at the beginning positions and is less than the end Concatenate lists: + ▫mynewlist = mylist + myotherlist combines the two lists into a new list

List Operations Find an element: in ▫3 in [0, 1, 2, 3], ‘city’ in [‘car’, ‘dog’, ‘house’] Sort a list ▫Mylist.sort() Reverse a list ▫Mylist.reverse() Add to a list ▫Mylist.append(item)

Strings, a character sequence We can iterate through sequences of characters just like a list ABC = “ABCDEFGHIJKLMNOPQRSTUVWXYZ” for letter in ABC: speak(letter) String operation split ▫splits a string based on space as the separator and returns a list of strings ▫Sentence = “Obviously you’re not a golfer” ▫Words = Sentence.split()

Gamepad We can use a gamepad to control the robot getGamepad( ) ▫Returns the value of the device after input is received getGamepadNow( ) ▫Immediately returns the value of the device Axis values are from Button values or on/off or 1/0

WWW We can use python modules to retrieve data from the web from urllib import * Data = urlopen( print Data.read()

Functions Redux def ( ): Python returns a value for all functions, whether explicitly or implicitly def cube(x): return x*3 return