Using Python: This assignment requires the main function and a custom value-returning function. The value-returning function takes a list of random Fahrenheit temperatures as its only argument and returns a smaller list of only the temperatures above freezing. This value-returning function must use a list comprehension to create the list of above freezing temperatures. In the main function, code these steps in this sequence: create an empty list that will the hold random integer temperatures. use a loop to add 24 random temperatures  to the list. All temperatures should be between 10 and 55, inclusive. Duplicates are okay. sort the list in ascending order. use another loop to display all 24 sorted temperatures on one line separated by spaces. 32 could be in the list. If it is, report the index of the first instance of 32. if 32 isn't in the list, add it at index 4. assign a slice consisting of the first six temperatures to a new list. Then print it. execute the custom value-returning function with the complete list as its only argument. in the main function, report the coldest temperature in the list that was returned. sort the list of above freezing temperatures in high to low order use a loop to display all above freezing temperatures on one line separated by spaces.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question

Using Python:

This assignment requires the main function and a custom value-returning function. The value-returning function takes a list of random Fahrenheit temperatures as its only argument and returns a smaller list of only the temperatures above freezing. This value-returning function must use a list comprehension to create the list of above freezing temperatures.

In the main function, code these steps in this sequence:

  • create an empty list that will the hold random integer temperatures.
  • use a loop to add 24 random temperatures  to the list. All temperatures should be between 10 and 55, inclusive. Duplicates are okay.
  • sort the list in ascending order.
  • use another loop to display all 24 sorted temperatures on one line separated by spaces.
  • 32 could be in the list. If it is, report the index of the first instance of 32.
  • if 32 isn't in the list, add it at index 4.
  • assign a slice consisting of the first six temperatures to a new list. Then print it.
  • execute the custom value-returning function with the complete list as its only argument.
  • in the main function, report the coldest temperature in the list that was returned.
  • sort the list of above freezing temperatures in high to low order
  • use a loop to display all above freezing temperatures on one line separated by spaces.
Here are the temperatures, sorted ascending
12 13 16 22 23 23 24 26 27 27 28 28 30 35 36 37 37 46 47 48 52 53 54 55
The first six elements are now [12, 13, 16, 22, 32, 23]
The coldest temperature above freezing is 35
Here are the above freezing temperatures, sorted descending
55 54 53 52 48 47 46 37 37 36 35
Transcribed Image Text:Here are the temperatures, sorted ascending 12 13 16 22 23 23 24 26 27 27 28 28 30 35 36 37 37 46 47 48 52 53 54 55 The first six elements are now [12, 13, 16, 22, 32, 23] The coldest temperature above freezing is 35 Here are the above freezing temperatures, sorted descending 55 54 53 52 48 47 46 37 37 36 35
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning