{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

analyzing-data-7

# analyzing-data-7 - Collectingand AnalyzingData Keith OHara...

This preview shows pages 1–9. Sign up to view the full content.

Sep 22 2010 CMSC143 - O'Hara 1 1 CMSC 143 Collecting and  Analyzing Data Keith O’Hara [email protected]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sep 20 2010 CMSC143 - O'Hara 2 Robot Interpreter Problem Give time parameter to command? f2b1a3 cmdstr = raw_input(“Enter Commands: “) idx = 0 while idx < len(cmdstr) : if cmdstr[idx] == “f”: forward(1,1) elif cmdstr[idx] == “b”: backward(1,1 elif cmdstr[idx] == “l”: turnLeft(1,1) elif cmdstr[idx] == “r”: turnRight(1,1) elif cmdstr[idx] == “a”: beep(1, 440) else: print “Unknown Command”, cmdstr[idx] idx = idx + 1
Sep 22 2010 CMSC143 - O'Hara 3 Sensing the World(s) Sensors give you information about the world(s) Geology of Mars Temperature and humidity of a forest Structural Soundness of a building of bridge Enemies on Battlefield Sometimes processed on the robot before transmission Too much data!

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sep 22 2010 CMSC143 - O'Hara 4 Gather Data with the Scribbler Program to gather and analyze data about light levels of the room Average Minimum Maximum Variance Light Sensors
Sep 22 2010 CMSC143 - O'Hara 5 Computing Statistics Compute statistics about light levels of the room Average Minimum Maximum Variance Use lists to store data data = getLightData(10) avg = computeAverage(data) min = computeMinimum(data) max = computeMaximum(data) variance = computeVariance(data) print “avg = “, avg, “var = “, var avg = 9.1, var = 66.09

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sep 22 2010 CMSC143 - O'Hara 6 Lists So Far range(5) # evals to [0, 1, 2, 3, 4] notes = [440, 466, 494, 523] for i in range(5): print i for note in notes: beep(1, note)
Sep 22 2010 CMSC143 - O'Hara 7 List Operations val = [2, 3, 5, 7, 11] Length of Lists len(val) #evals to 5 len(range(9)) #evals to 9 Indexing val[0] #evals to 2 val[4] #evals to 11 val[5] #error! Member of a list? 2 in val #evals True 10 in val #evals to False Concatenation [1, 3, 5] + [2, 4, 6] # evals to [1, 3, 5, 2, 4, 6] [] + [1] # evals to [1] Lists are Mutable val[1] = “v”

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sep 22 2010 CMSC143 - O'Hara 8 List Arithmetic v1 = [2, “3”, 5.0, 7, “11”] v2 = [2, 3, 5]
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern