question archive CIS241 – Python Programming UNIT 3: Program – Functions, Files and Exceptions Due Date: 11:59 pm EST, Sunday of Unit 3 Points: 100 Overview: In this assignment, you will be analyzing global variables and global constants, functions, files, and exceptions
Subject:Computer SciencePrice:15.86 Bought3
CIS241 – Python Programming UNIT 3: Program – Functions, Files and Exceptions Due Date: 11:59 pm EST, Sunday of Unit 3 Points: 100 Overview: In this assignment, you will be analyzing global variables and global constants, functions, files, and exceptions. Instructions: Create the following program exercises: 1. A user needs to be billed for the use of a telephone. You will ask the user to type in the rate per second, how many communications were made, the duration of each communication expressed in hours, minutes and seconds. As a result, you will have to inform the duration in seconds of each communication and their cost. 2. Design a function that receives the three coefficients of a second-degree equation of the form ax2 + bx + c = 0 and returns a list with its real solutions. If the equation has only one real solution, it returns a list with two copies of it. If you have no real solution or if you have infinite solutions, return a list with two copies of the value "None". 3. Write a program that asks for a score between 0.0 and 1.0. If the score is outside that range, it displays an error message. If the score is between 0.0 and 1.0, show the rating using the following table: Score Rating > = 0.9 Outstanding > = 0.8 Notable > = 0.7 Good > = 0.6 Enough < 0.6 Insufficient Enter score: 0.95 Outstanding Enter punctuation: perfect Incorrect score Enter score: 10.0 Incorrect score Enter score: 0.75 Good Enter score: 0.5 Insufficient * Run the program repeatedly, as shown above, to test with several different input values. 4. Write a program that asks for the name of a file and then read that file, looking for lines that have the form: X-DSPAM-Confidence: 0.8475 When you find a line that begins with “X-DSPAM-Confidence:”, separate that line to extract the floating-point number that appears on it. Count these lines and also calculate the total spam probability values of these lines. When you reach the end of the file, it shows on the screen the average value of spam probability. Enter the name of the file: mbox.txt Average value of spam probability: 0.894128046745 Enter the name of the file: mbox-short.txt Average value of spam probability: 0.750718518519 5. Sometimes, when programmers get bored or want to have some fun, they add a harmless Easter Egg to their programs. Modify the previous program that asks the user for the name of the file to print a funny message when the user writes the exact name "na na boo boo". The program should behave normally with all other files, both those that exist and those that do not. Next, a sample of the execution of the program: python egg.py Enter the name of the file: mbox.txt There are 1797 subject lines in mbox.txt python egg.py Enter the name of the file: missing.tyxt Could not open file: missing.tyxt python egg.py Enter the name of the file: na na boo boo NA NA BOO BOO FOR YOU - I've caught you! * We are not encouraging you to put Easter Eggs in your program — it is just an exercise. Requirements: • • • Submit a Word document with your coding and the Python file. For all justification exercises, remember to use the definitions and principles that we have learned thus far o Include all your work for each question. o You can include screenshots of work done on paper. For all justification exercises, remember to use the definitions and principles that we have learned thus far. Requirements: • Each program should meet the following requirements: o o o o Execution: No errors. Meets all the requirements and execute the code in the most efficient manner. Output: The program output is exactly correct. Readability: The code is clean. The formatting is well organized, and very clear, spaces to spread out code to make it easier to read. Comments: Comments are used to explain all logic and make it easy for the grader to follow the program. Submit a Word document with your coding and the Python file. • For all justification exercises, remember to use the definitions and principles that we have learned thus far. • Be sure to read the criteria by which your work will be evaluated before you write and again after you write. Grading Rubric Category Program #1 Program #2 Program #3 Program #4 Program #5 Deficient 0 – 6 points The program is missing or does not meet any of the program requirements. 0 – 6 points The program is missing or does not meet any of the program requirements. 0 – 11 points The program is missing or does not meet any of the program requirements. 0 – 16 points The program is missing or does not meet any of the program requirements. 0 – 16 points The program is missing or does not meet any of the program requirements. Needs Improvement 7 – 10 point Some program requirements are met. 11 – 14 points Most program requirements are met. 15 points All program requirements are met. 7 – 10 point Some program requirements are met. 11 – 14 points Most program requirements are met. 15 points All program requirements are met. 12 – 15 point Some program requirements are met. 16 – 19 points Most program requirements are met. 20 points All program requirements are met. 17 – 20 point Some program requirements are met. 21 – 24 points Most program requirements are met. 25 points All program requirements are met. 17 – 20 point Some program requirements are met. 21 – 24 points Most program requirements are met. 25 points All program requirements are met. Proficient Exemplary
Purchased 3 times