Lab 6: files, ifs, loops, and functions Due date: 7/10/2022 Problem: You have been hired by Channel 5 to help produce st

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Lab 6: files, ifs, loops, and functions Due date: 7/10/2022 Problem: You have been hired by Channel 5 to help produce st

Post by answerhappygod »

Lab 6 Files Ifs Loops And Functions Due Date 7 10 2022 Problem You Have Been Hired By Channel 5 To Help Produce St 1
Lab 6 Files Ifs Loops And Functions Due Date 7 10 2022 Problem You Have Been Hired By Channel 5 To Help Produce St 1 (72.12 KiB) Viewed 67 times
Lab 6 Files Ifs Loops And Functions Due Date 7 10 2022 Problem You Have Been Hired By Channel 5 To Help Produce St 2
Lab 6 Files Ifs Loops And Functions Due Date 7 10 2022 Problem You Have Been Hired By Channel 5 To Help Produce St 2 (64.51 KiB) Viewed 67 times
Lab 6 Files Ifs Loops And Functions Due Date 7 10 2022 Problem You Have Been Hired By Channel 5 To Help Produce St 3
Lab 6 Files Ifs Loops And Functions Due Date 7 10 2022 Problem You Have Been Hired By Channel 5 To Help Produce St 3 (51.56 KiB) Viewed 67 times
Lab 6 Files Ifs Loops And Functions Due Date 7 10 2022 Problem You Have Been Hired By Channel 5 To Help Produce St 4
Lab 6 Files Ifs Loops And Functions Due Date 7 10 2022 Problem You Have Been Hired By Channel 5 To Help Produce St 4 (58 KiB) Viewed 67 times
Lab 6: files, ifs, loops, and functions Due date: 7/10/2022 Problem: You have been hired by Channel 5 to help produce statistics for their weather department. They have files with the daily temperatures for each month and they want you to process them. You must display the highest and lowest temperatures. You have to determine the median temperature and then display the daily temperatures indicating whether them are greater than, less than, or equal to the median. You want to make a good impression and decided you write a program that will do all this for you. Instead of running the program for each month that you must process, you resolved to use a loop to keep processing files if the user of the program chooses to. If they like it, you may get a pay raise! Ⓒ The program must: 1) Ask to Enter the name of the month to be processed. Due 2) Ask to enter the name of the file to be processed. 3) Determine and display the highest, lowest, and median temperature. 4) Display for each day the temperature and whether it is greater than, less than, or equal to the median. 5) Ask the user" Do you want to process another month[y/n]?". 2/10 If the answer is 'y', the program must repeat steps 1 through 4. Any other answer must end the program. Your task: implement in Python the algorithm solution shown below. Algorithm solution (in pseudocode): # Import the statistics module # Function definition # Define a function that receives the list with the temperatures and the month's name # Display the title: "List of temperatures corresponding to month", month_name # Get the median using the statistics module and save it # Display the lowest, highest, and median temperature # Initialize a counter for the day number # Use a loop to print the values in the list def # te (degree, # Display for each day: "Day", day_number, temperature, and whether it is greater than, less than, or equal to the median (display day_number using 2 columns and temperature using 3 columns) # Increment the counter This line is just to show where the function definition ends month -name] # Program starts here Initialize answer to 'y' #Loop while answer is 'y' # Prompt the user to "Please enter the name of the month to be processed: " and save it
#Prompt the user to "Please enter the name of the file to be processed: " and save it #Open file specified by the user and assign it to a file variable # Create an empty list # Use a for-loop to get each value from the file Append the content of the line read from the file (converted to int) at the end of the list # Call the function to print the data # Close the file # Prompt the user "Do you want to process another month[y/n]?" and save it Note: You must choose the MOST appropriate type of if statement and loop to implement this algorithm. In some cases, you may need to use several Python statements to implement a single step of the algorithm, use your excellent critical thinking and problem-solving skills to come up with the best implementation possible. # This lab requires you to use the tools I taught so far so review your class notes and read the tutorial. Look at the examples used in my lectures. If you have concerns or specific questions, post them on the Discussion Board of Blackboard. To get information about the statistics module click on https://docs.python.org/3/library/statistics.html I am showing a sample run of my solution for your reference. Please run your program and ensure that it works like mine. The input and output formatting must be like the one used in my sample solution. Don't forget to include the following comments at the top of your program. CSCI 1380 First and Last Name First and Last Name of teammate Summer I 2022 Summer 1 2022 Lab # 6 Please name your file lab6TXX (where XX are the two digits corresponding to your team number). Do not include blank spaces in the name of the file please. The following is the Rubrics: When done, upload and submit your program solution through Blackboard using the link corresponding to this assignment. Do Not email it. Include the link to your replit.com solution in the Comments box. 1) Correct implementation of the if statement 2) Correct implementation of the loop
3) Correct implementation of the function 4) Program to implement the algorithm provided 5) Appropriate comments in source code 6) Good formatting of the input 7) Good formatting of the output 8) Python file 9) Link to replit.com solution 10) Correcty file name Sample runs of my program Please enter the name of the month to be processed: September Please enter the name of the file to be processed: sep_temp.txt List of temperatures corresponding to month September Lowest temperature: 74 Highest temperature: 90 The median for the month is: 84.5 Day 1: 87 is greater than median Day 2: 86 is greater than median Day 3: 86 is greater than median Day 4: 84 is less than median Day 5: 82 is less than median Day 6: 83 is less than median Day 7: 80 is less than median Day 8: 74 is less than median Day 9: 83 is less than median Day 10: 80 is less than median Day 11: 79 is less than median Day 12: 81 is less than median Day 13: 84 is less than median Day 14: 88 is greater than median Day 15: 84 is less than median Day 16: 85 is greater than median Day 17: 86 is greater than median Day 18: 90 is greater than median Day 19: 89 is greater than median Day 20: 89 is greater than median Day 21: 90 is greater than median Day 22: 88 is greater than median Day 23: 86 is greater than median Day 24: 86 is greater than median Day 25: 87 is greater than median Day 26: 86 is greater than median Day 27: 84 is less than median Day 28: 80 is less than median Day 29: 82 is less than median Day 30: 82 is less than median SumuvCE
Do you want to process another month[y/n]? y Please enter the name of the month to be processed: October Please enter the name of the file to be processed: oct_temp.txt List of temperatures corresponding to month October Lowest temperature: 13 Highest temperature: 75 The median for the month is: 68 Day 1: 72 is greater than median Day 2: 73 is greater than median Day 3: 74 is greater than median Day 4: 75 is greater an median Day 5: 73 is greater than median Day 6: 70 is greater than median Day 7: 69 is greater than median Day 8: 70 is greater than median Day 9: 72 is greater than median Day 10: 70 is greater than median Day 11: 60 is less than median Day 12: 66 is less than median Day 13: 72 is greater than median Day 14: 73 is greater than median Day 15: 70 is greater than median Day 16: 48 is less than median Day 17: 48 is less than median Day 18: 59 is less than median Day 19: 65 is less than median Day 20: 68 is equal to median Day 21: 71 is greater than median Day 22: 71 is greater than median Day 23: 59 is less than median Day 24: 50 is less than median Day 25: 36 is less than median Day 26: 53 is less than median Day 27: 55 is less than median Day 28: 13 is less than median Day 29: 31 is less than median Day 30: 54 is less than median Day 31: 66 is less than median Do you want to process another month[y/n]? n
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply