Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to create a survey question. You have great freedom to think of a question, but it should be creative and unique. Think outside

You need to create a survey question. You have great freedom to think of a question, but it should be creative and unique. Think outside of the box, because your grand alien leader will reward the most interesting survey question with 1 point of extra credit.
The only technical requirement for the question should result in a non-nominal number. The term non-nominal is used to avoid questions where the numbers are being used as labels, and they have no order or numerical significance.
For example, here are some GOOD questions:
How many corgis do you wish you owned?
How many pages are in your favorite book?
What is the ideal number of people to have at a party?
How many colors do you hate?
How wide is your favorite blanket?
Here are some BAD questions, because they are nominal:
What is your gender? 0 is male, 1 is female, 2 is other.
What is your hair color? 0 is blonde, 1 is black, 2 is brown, 3 is other.
Where do you live? 0 is Blacksburg, 1 is not Blacksburg.
What is your favorite number?
When you have formulated your survey question, assign it to the variable named SURVEY_QUESTIONS in your code as a string literal value.
Next, you will need to ask at least 10 people your question. Obviously, there is no strict way to enforce this process, but remember you that you are signing an honor pledge to actually complete this assignment. When you have your responses, encode them as a list literal of integers or floats in a variable named SURVEY_RESULTS.
Statistics
To analyze your survey results, you will write a set of 8 functions. When defining these functions, you cannot use any built-in list handling functions (e.g., len, sum) or external modules (e.g., statistics, numpy). However, you are encouraged to use the following functions: round, int, sorted.
Here are the 8 functions you need to define:
count: Consumes a list of numbers and returns an integer representing the length of the list.
summate: Consumes a list of numbers and returns an integer representing the total sum of all the numbers in the list.
mean: Consumes a list of numbers and returns a float value representing the mean of the list. The formula for the mean of a list is
mean = sum / count
Think strategically about how you can use functions you have already written to simplify this function's definition. If the list is empty, then return the special value None. You should use the round function to round the result to two decimal places.
maximum: Consumes a list of numbers and returns the highest number from the list. If the list is empty, then return the special value None.
minimum: Consumes a list of numbers and returns the lowest number from the list. If the list is empty, then return the special value None.
median: Consumes a list of numbers and returns the median number from the list. If the list is empty, then return the special value None. To calculate the median, you will need to find the middle index of the list after it has been sorted (you can easily sort a list using the built-in sorted function):
middle index = length/2
As a further headache, remember that you can only use integers to index a list, not floats - therefore, you will also need the int built-in function. This is actually a simplified version of the real median formula. You do not need to worry about finding the average in the even case, simply apply the formula above regardless of whether there are an even or odd number of elements.
square: Consumes a list of numbers and returns a new list of numbers where each element has been squared.
standard_deviation: Consumes a list of numbers and returns a float representing their standard deviation. If the list has fewer than 2 elements, you should return the special value None. The following formula should be used to calculate the standard deviation:
stdev =(((sum of the values squared)-(sum of the values * sum of the values)/(count of the values))/(count of the values -1))**.5
This formula is described more deeply hereLinks to an external site.. To resolve any ambiguity in the phrasing, consider the test case [1,2,3,4,5]. For this, the "sum of the values squared" variable refers to the computation 1**2+2**2+3**2+4**2+5**2=55. The "sum of the values * sum of the values" variable refers to the computation (1+2+3+4+5)*(1+2+3+4+5)=(1+2+3+4+5)**2=225. Take advantage of functions you have already written to simplify this function's definition. You should use the round function to round the result to two decimal places.
Refer to the sample_results.txt file (using your Programmer Friendly Text Editor) to see the exact values that should be returned for each function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions