Answered step by step
Verified Expert Solution
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 point of extra credit.
The only technical requirement for the question should result in a nonnominal number. The term nonnominal 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? is male, is female, is other.
What is your hair color? is blonde, is black, is brown, is other.
Where do you live? is Blacksburg, is not Blacksburg.
What is your favorite number?
When you have formulated your survey question, assign it to the variable named SURVEYQUESTIONS in your code as a string literal value.
Next, you will need to ask at least 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 SURVEYRESULTS.
Statistics
To analyze your survey results, you will write a set of functions. When defining these functions, you cannot use any builtin list handling functions eg len, sum or external modules eg statistics, numpy However, you are encouraged to use the following functions: round, int, sorted.
Here are the 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 builtin sorted function:
middle index length
As a further headache, remember that you can only use integers to index a list, not floats therefore, you will also need the int builtin 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.
standarddeviation: Consumes a list of numbers and returns a float representing their standard deviation. If the list has fewer than elements, you should return the special value None. The following formula should be used to calculate the standard deviation:
stdev sum of the values squaredsum of the values sum of the valuescount of the valuescount of the values
This formula is described more deeply hereLinks to an external site.. To resolve any ambiguity in the phrasing, consider the test case For this, the "sum of the values squared" variable refers to the computation The "sum of the values sum of the values" variable refers to the computation 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 sampleresults.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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started