{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Exam 2- 2011

# Returns false otherwise cs 115 exam 2 fall

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ot;too bad!" CS 115 Exam 2, Fall 2011 Page 6 of 9 (c) Write a function called compare_lists that… * Takes two lists of numbers as input parameters * Returns False if the two lists are of unequal length * Returns True if ALL elements of the first list are greater than the FIRST element of the second list. Returns False otherwise. CS 115 Exam 2, Fall 2011 Page 7 of 9 Problem 3: 30 points. For this problem, you must write a complete program. That includes a docstring, a def main(), any necessary library imports, etc. Read the instructions carefully before you start coding! Your program should contain the following: 1. A function called GetNum that does the following: o Asks the user to enter a number o If the user entered a valid number, returns that number o If the user did not enter a valid number, prints an error message and exits the program 2. A function called IsGrade that does the following: o Has one input parameter (a number) o Returns True if its input parameter is between 0 and 100 (inclusive) and False if it is not 3. A main function that does the following: o Uses GetNum to repeatedly prompt the user to enter a number, stopping when the user enters  ­1. o Uses IsGrade to test whether each number is a legitimate grade o If there were NO legitimate grades, prints an error message. You should only print this error message ONCE. o Otherwise, prints the average of all of the numbers that were legitimate grades. You should only print this average ONCE. CS 115 Exam 2, Fall 2011 Page 8 of 9 CS 115 Exam 2, Fall 2011 Page 9 of 9...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online