01 Aug IFT 194 CH 9.2
Q1 Finding the average weather temperature ( coded temperatures, for example, the mean could have been subtracted from each actual temperature)
Scenario: Given a list of weather temperatures in fahrenheit coded as follows:
weatherF = [ 1, 3, 1, 5, 3, 3, 2, 1, 1, 4, 4 ,4, 1, 1, 1 ] # note these are the ‘coded’ temperatures
Write the Python code to calculate the average temperature for the weatherF list, doing it two ways. Use the ‘len’ function to get the length of an array, don’t manually count. Use this ‘len’ function to determine maxIndex as well as the denominator for the average calculation. Avoid magic numbers..
A :Write a Python program to calculate the average temperature using a while loop and using indexes to get the element temperatures
Print out the temperature at each iteration. Print the average temperature after the loop terminates.
B : Write a Python program to calculate the average temperature using a for loop
Print out the temperature at each iteration. Print the average temperature after the loop terminates.
Q2 : Finding the frequency distribution of the temperatures
Write a Python program to find the frequency distribution of the temperatures.
That is, weatherF is a list of temperatures: how many times does the temperature value of ‘1’ occur? Manually, I can see it occurs 7 times, but I want to automate that analysis.
To start off, name your frequency distribution list as frequencyDistribution.
Hints: How many different values of elements must it hold? That will be its size.
The frequencyDistribution[0] element should be ‘7’, that is, there are ‘7’ ones. What should the other indices hold?
Use a for loop to go through weatherF list, and for each element encountered, bump the contents of the frequencyDistribution array index holding that element ‘s value. That is, for example, frequencyDistribution[0] ‘s contents will be bumped 7 times, which equals the number of ‘1’ s encountered.
Q3 : Write a Python program to find the max and min of the weatherF list. Print those out at the termination of the loop. ( use either style you like)
Use constants to represent the initial max and min values.
Q4 : Write the Python function that accepts a list of numerics as an argument and returns the average of the list elements. Note, this is a generalization of what you did in question Q1. Now the list is just a list of numbers. Hint, use the ‘len’ function to determine the denominator for the aver
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.