My notes on the handout change some things, add some things. == Test 1, hand back and go over the last two questions. Good job!!! Grades very high. One note, before I hand out the exam: This was your first exam, and the first time you had to write code like this without the computer. I took off points, but did not kill you for not following the specification in the docstring I think that's right to do that - the exam will help you understand the issues involved. but from now on, functions need to match the docstrings, and they need to be called with the right kinds of arguments. I will take more off for that in the future. similar comments for other things. So, please keep pushing and learning the material - you are doing well! ===Going over Test 1, questions 3 and 4 I put a solution on the web. I printed it out. I'll enter the code in wing during lecture. ===Assignment 2 Due Monday!!! No extension, since this was already pushed back. Point out that I added test files for you to compare. Let's look at the code, analysis.py I printed out analysis_sol.py ====Code From Lab 5 if __name__ == '__main__': #The following is a list of lists, where the inner lists consist of an ID and a grade average student_grades = [['999888777', 78.0], ['111222333', 90.0], ['444555666', 83.0]] # Here is an example of a nested list. Run and trace this until #you are sure you understand it. # Print contents of a nested list print "About to print the contents of the nested list" for student in student_grades: print student for x in student: print x raw_input("Enter 1 to move on ") measurements = [[33, 34, 30], [29, 31, 34], [28, 27, 30]] print "measurements is",measurements # Print the average of each inner list print "about to print the average of each inner list" for dataset in measurements: total = 0.0 for datapoint in dataset: total = total + datapoint print "the average of the values in",dataset, "is", print float(total) / len(dataset) raw_input("Enter 1 to move on ") # We can also use the function "total" print "about to print the average of each inner list...again" for dataset in measurements: print "the average of the values in", dataset, "is", print sum(dataset) / float(len(dataset)) #but sum contains a loop. I promise! raw_input("Enter 1 to move on ") # Create a list of averages print "about to print a list of the averages of the measurements" averages = [] for dataset in measurements: total = 0.0 for datapoint in dataset: total = total + datapoint averages.append(float(total)/len(dataset)) print averages def get_valid_command1(): '''Prompt for and return a string that is a valid command: one of "xxx", "yyy", and "zzz".''' command = "" while True: command = raw_input("Please enter a command: ") if command == "xxx" or command == "yyy" or command == "zzz": return command else: print "Invalid command" def get_valid_command2(): '''Prompt for and return a string that is a valid command: one of "xxx", "yyy", and "zzz".''' command = raw_input("Please enter a command: ") # While we don't have a valid command, go get another one. while command != "xxx" and command != "yyy" and command != "zzz": print "Invalid command" command = raw_input("Please enter a command: ") # We have a valid command! Return it. return command def get_valid_command(valid_commands): '''Prompt for and return a string that is in the list of valid commands.''' command = "" while command not in valid_commands: command = raw_input("Please enter a command: ") if command in valid_commands: return command else: print "Invalid command" if __name__ == "__main__": command = get_valid_command1() print command #command = get_valid_command2() #print command