Exam 1- 2011

O the length of the hypotenuse has the following

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: ady been assigned values for you. Do not overwrite these values. Your task: If a and b are the legs of a right triangle, compute that triangle’s perimeter. Helpful facts: o The perimeter of a triangle is the sum of the lengths of the two legs and the hypotenuse. o The length of the hypotenuse has the following relationship to the lengths of the legs: a2 + b2 = c2 CS 115 Exam 1, Fall 2011 Page 5 of 8 (c) Ask the user to enter an integer. If the user enters a valid integer, print “Congratulations, _____ is an integer!” (filling in the number the user entered) If the user does not enter a valid integer, print “Fail!” Your program should not crash. (d) Ask the user to enter 50 words or phrases. Afterward, print the number of times the user’s input was the word chicken. CS 115 Exam 1, Fall 2011 Page 6 of 8 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 do the following: 1. Prompt the user to enter 25 grades. You can assume that the user enters valid numbers. 2. If the user enters a grade that is less than zero or greater than 100, print an error message and exit the program immediately. 3. If the user has entered 25 legitimate grades, print the average (mean) of those grades. 4. Print the user’s letter grade according to the following scale. Decimal values should be truncated (cut off) – in other words, grades are rounded down. You should only print the user’s letter grade once. o 90+ = A o 80 ­89: B o 70 ­79: C o 60 ­69: D o Below 60: F CS 115 Exam 1, Fall 2011 Page 7 of 8 CS 115 Exam 1, Fall 2011 Page 8 of 8...
View Full Document

This note was uploaded on 02/08/2014 for the course CS 115 taught by Professor Staff during the Fall '08 term at Sonoma.

Ask a homework question - tutors are online