Jeopardy-review-exam2

Jeopardy-review-exam2 - CS 1301 Jeopardy Hosted by Jay ©...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 1301 Jeopardy Hosted by Jay © Don Link, Indian Creek School, 2004 Robot True? $200 $200 $200 $200 $200 $200 $400 $400 $400 $400 $400 $600 $600 $600 $600 $600 $800 $800 $800 $800 $800 $1000 $1000 $1000 $1000 $1000 Programs Data Types Potpourri This myro function returns 0 or 1 value(s) based upon obstacles behind the robot. obstacles Robot for $200 getIR() Motors(-1,1) causes the Motors(-1,1) robot to do this. Robot for $400 Spin counterclockwise (left). Range of possible values returned by the getObstacle() function. function. Robot for $600 0 to 7000 The dimensions of the picture returned The by the takePicture() function. Robot for $800 256 (X) by 192 (Y) Difference between the getLight() and getBright() functions. and Robot for $1000 getLight() returns values from sensors on robot, getBright() returns sum of pixel values from fluke camera. What is the values of: What ( (14 >= 0) or (4 != 3) ) (14 True? for $200 True True All recursive functions All have these 2 parts: a base have (terminating) case, and a recursive call. recursive True? for $400 False getIR(“left”) and (5 % 2 == 3) getIR(“left”) True? for $600 False for i in range(5,3,-1): for if (i % 2 == 0): if return True else: else: return False True? for $800 False ( (5 > 4) or (10 >= 10) ) or (not (5 / 4 == 1)) True? for $1000 True True What this program prints: What for i in range(10): print i + 1 Programs for $200 Numbers 1 through 10, one per line. x=5 while (x > 0): print x print x = x-1 x-1 Programs for $400 Numbers 5 to 1, one per line Write this using a while loop: Write for i in range(5,10,2): print i print Programs for $600 x=5 while ( x < 10): print x print x = x+2 x+2 Result of mystery(2,3): Result def mystery(a,b): if (a == 0): if return b return else: else: return mystery(a-1, b+1) return Programs for $800 5 What the mystery function does: What def mystery(a,b): if (a == 0): if return b return else: else: return mystery(a-1, b+1) return Programs for $1000 Sum a and b. Five immutable Five data types. Data types for $200 int, float, string, bool, tuple myList = [True,34, [5,6],”test”] myList An expression that accesses the number six (6) from the list(s) above. Data types for $400 myList[2][1] How to change How myStr = “Jay” To myStr = “jay” Data types for $600 myStr = ‘j’ + myStr[1:] A = [5,6,7,8] [5,6,7,8] B=A B[3] = B[2]+3 The value of A[3] Data types for $800 10 r = “Python is Great!” “Python The result of: r[2]+r[12]+r[8]+r[14]+r[15] r[2]+r[12]+r[8]+r[14]+r[15] Data types for $1000 test! test! This return value means This that a function did not that return a specific value. return Potpourri for $200 None, (of type NoneType) These are the three types of These sensors on the Lancet Fluke. Potpourri for $400 IR Obstacle sensors (getObstacle), IR the camera (takePicture, getBright), and the the battery voltage (getBattery) sensor. Arithmetic operators (like +, -, *, /) have _____ precedence than logical operators (like or, and, not) so arithmetic is done _____. arithmetic Potpourri for $600 Higher/greater, first Rewrite the following code using a for loop. for x=7 while (x > 3): print x print x = x -1 -1 Potpourri for $800 for x in range(7,3,-1): print x print This is the sorting algorithm that Donald Knuth credits John von Neumann with inventing. von Potpourri for $1000 Merge Sort ...
View Full Document

Ask a homework question - tutors are online