Description
Image credit: www.flexjobs.com/
This is an individual assignment.
LEARNING OBJECTIVES, TOPICS THAT YOU WILL BE SPECIFICALLY WORKING WITH:
• Interaction with user
• For loops, if statements
• Repeated accumulation
• Lists manipulation
• Using several accumulators and List of accumulators
• Using functions
• At least one function definition is required (4 functions recommended)
Similarly to the previous assignment (T-shirt greeter, Travel agent bot),
• submit in Canvas two files: your .py file and your .txt reflection file,
• YOU SHOULD NOT SUBMIT JUST THE REPL URL – UPLOAD THE PYTHON .py FILE ALSO
PROBLEM DESCRIPTION
Create a Python program, which implements a simplified statistics analysis of popular preferences
Start by asking the user the number of people that will be surveyed (n), and then the dialog will be as if several questions are asked to each of those n people. You can also think that the user types in the answers for each person being interviewed.
To each surveyed person, the program should ask:
a. which season they prefer, (if Spring, Summer, Fall or Winter)
b. if they choose Winter, the person should be asked if they prefer “sunny and cold” days or
“cloudy and warm”days (two options)
c. they should also answer how much they like chocolate, any number rating from 1 (don’t like chocolate) to 5 (they love chocolate)
d. and finally, which month of the year they prefer (from 1 to 12)
After collecting the data from the n people, the program should show various final results: A. % of preference for each season given the total people asked,
B. Considering those who prefer Winter, the % that prefers sunny-cold vs. cloudy-winter days C. average rating of chocolate,
ASSIGNMENT #4 – Popularity Contest
D. how many votes there were per month (can be shown as a list) E. Bonus: which is the month that is most preferred
REQUIREMENTS OF CODE ORGANIZATION AND ASSUMPTIONS
• Your code needs to follow the general coding guidelines (See Home website More LINKS Python source code general guidelines), including comments as described there
• You need to include TRACE printing exactly as included in the sample runs.
• The order in which the questions are asked to the user and the people being surveyed should be the same as in the sample runs
• Assume that when the user is asked a number, he/she provides a number, and always types correctly always.
• NO VALIDATION OF THE USER INPUT IS NEEDED IN ANY WAY
• NO CONFIRMATION TO THE USER OF WHAT WAS TYPED IS NEEDED
• Define at least one function which does not receive any parameter and asks the user the preferred seasons, returning a code for the preferred seasons.
• You are recommended to define fours functions, one per data asked , the function includes all the messages, and returns the code associated to the value being asked. NO VALIDATIONS REQUIRED
HINTS
• Consider using a list with the seasons names and a list of accumulators (initially with all 0’s), both with 4 elements, and so that if the first season is Spring, then first the name in the seasons names list is “Spring”, and the first accumulator in the seasons list of accumulators corresponds to the number of people preferring spring.
• Similarly you can define more lists.
• Define all lists outside the functions – this will allow to access them form any function
• To print the output information with fixed spacing, consider using the character “ ” (tabulation)
WHAT YOU ARE REQUIRED TO SUBMIT:
• Your python file, named mypopularity.py.
• A reflections.txt file, where you include how much time it took you to do this exercise (approximate, in hours, minutes) and any comments reflecting on what you learned and/or any comment to your marker.
ASSIGNMENT #4 – Popularity Contest
See SAMPLE RUNS posted together with this description.
The sample runs also describe the problem!
One sample run (executing the program once) will process the responses of the n people.
End of popularity contest assignment description
Reviews
There are no reviews yet.