HW #7 Temperature Data Statistics Design and test a Python program which asks the user to enter a list of temperature values (any length) and calculates and displays the following statistics (see list below). Temperature values can be in C or F (be clear to user). You may use any list methods (functions). Produce values with one digit to right of decimal place. Include 3 test cases. Each test case should contain 5 to 15 input values. You can use any method to ask user for input data (prompt user for each value or have user enter a list of values). Include units. NOTE: do not use list comprehensions. 1) max 2) min 3) average 4) standard deviation (use a function for this - given in lecture notes) 5) median 6) list data in sorted order (low to high) 7) list data in reverse sorted order (high to low) 8) Calculate the number of temperatures are above or equal to freezing temperature 9) Calculate the number of temperatures that are above the average temperature
Added by Robert G.
Close
Step 1
Step 1: Ask the user to enter a list of temperature values. Show more…
Show all steps
Your feedback will help us improve your experience
Supreeta N and 84 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Economics Class Rick recently got admission at a business school. The first class he attended was Economics and it was a refresher of concepts like mean and median. Mean is the average of all the numbers in the data and median is the midde value when all the numbers in the data are sorted in case the number of elements is odd or when the number of elements is even, it is the average of the two middle elements. As homework, Rick was given a dataset with a large number of elements, he had to find a subset of that dataset which would give the largest value of the difference between mean and median (mean-median) Since it is a tedious task, Rick and you decide to develop a program that retums a subset of the original amay such that the value of difference of mean and median is largest in it Input Specification: input1: An integer value denoting the number of elements in the array(dataset) input2: An integer amay representing the dataset Output Specification: Return an integer array which is a subset of the anginal array(dataset) such that the value of difference between the mean and median (mean-median) is largest Example 1: input1:4 input2: {1,2,3,4} Output {1,2,4} Explanation: If we take the subset (1,2,4), we get mean as 7/3 and median as 2, so, the value of difference of mean and median (mean-median) is 1/3
Supreeta N.
Project 1: For this project, you will import the statistics module. Write a class called Student that has two private data members - the student's name and grade. It should have an init method that takes two values and uses them to initialize the data members. It should also have a get_grade method. Write a separate function (not part of the Student class) called basic_stats that takes a list of Student objects as a parameter and returns a tuple containing the mean, median, and mode of all the grades. To do this, use the mean, median, and mode functions in the statistics module. Your basic_stats function should return those three values as a tuple, in the exact order given above. As an example, your code could be called as follows by the grader: s1 = Student("Kyoungmin", 73) s2 = Student("Mercedes", 74) s3 = Student("Avanika", 78) s4 = Student("Marta", 74) student_list = [s1, s2, s3, s4] print(basic_stats(student_list)) # should print a tuple of three values You can test your program with the above example, but make sure not to include it as part of your submission. The file must be named: basic_stats.py Mini-review: A private data member of a class has a name that begins with an underscore. Private data members can be directly accessed from within the class but not from outside the class. Instead, if a data member needs to be accessed or manipulated from outside the class, then the class should provide a method that can be called to carry out the necessary actions. This access restriction is not enforced by the Python language as it is in some other languages, due to the Python philosophy of "we're all adults here".
Akash M.
Python Exercise While Loop, For Loop, Function 1. Write a loop to print numbers from 10 to 0. 2. Write a loop to print from 0 to 20 with step of 3. For example, 0 3 6 9 12 ... 3. Write a program that asks the user for a positive integer value. The program should write all the integers from 1 up to the number entered. For example, if the user enters 15, the loop will write 1, 2, 3, 4, ... 15. 4. Write a loop that will ask the user to enter their scores of five homework. Each time it prints ‘Good’ if the score is greater than or equal to, otherwise it prints ‘Need Improvement’. 5. Write a function called Calculator_Banner that does not have any input parameters or does not accept two any arguments and prints the following banner. **************** * CALCULATOR * **************** 6. Write a function called Addition that accepts two numbers as input, calculates the sum of the numbers and returns the sum of the two arguments. 7. Write another function called main. The main() function asks the user to input two numbers and stores the numbers. First it calls Calculator_Banner function to draw the banner (like above). Then it calls the Addition function with the number arguments provided by the user and prints the output that Addition returns. 8. Write a function Find_Max that accepts two numbers as arguments and prints the largest number two. Write another function main, in main() function accept two numbers from user and call Find_Max.
Shaiju T.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD