{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
Sep 22 2010 CMSC143 - O'Hara 1 1 CMSC 143 Collecting and  Analyzing Data Keith O’Hara [email protected]
Image of page 1

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

View Full Document Right Arrow Icon
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
Image of page 2
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!
Image of page 3

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

View Full Document Right Arrow Icon
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
Image of page 4
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
Image of page 5

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

View Full Document Right Arrow Icon
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)
Image of page 6
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”
Image of page 7

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern