Hi, need help in this exercise, actually I do have a part of the exercise but I'm lacking of creativity, and now I'm struggling to keep up on the assignment. Actually tried an different answer but it...



Hi, need help in this exercise, actually I do have a part of the exercise but I'm lacking of creativity, and now I'm struggling to keep up on the assignment. Actually tried an different answer but it doesn't work out



If could get an explanation on where to change or even to start from the beginning, doesn't matter, have a good one (I accept critics as well, I just recently started learning this language)


Create a program that assignsa random integerto the total rainfall for a calendar year, Using a
dictionaryto
store the month and random rainfall.



- Do NOT usethe month_list = ["January", "February", "March",month_list = ["January", "February", "March", etc. hardcoded month list we used in the previous assignment.


- All the work including appending rainfall must be done using a dictionary.Do NOT usethe built in dict() conversion. It defeats the purpose of the lesson and will earn no credit.


- The random.randint function for assigning rainfall to the months can only appear ONCE in your code. Multiple instances will result in a zero for the assignment.


- Instead of the aforementioned list use a dynamically created list using the datetime module see sample https://onlinegdb.com/NwOa3CLtO (Links to an external site.)


-The same rules apply maximum rain in a month 4 inches.


- Use | as a separator in the minimum and maximum strings vs comma we used in the past.


- You will need to print the dictionary, results, and an output file calledrandout.txt. This output file will contain the same data as your dictionary stored in random order. The randomizing of the output data must be done usingrandom.choice(Links to an external site.) function. Make sure you don't confuse random.choice with random.choices.
To avoid duplication you will have to remove (pop) the values out of the dictionary one by one once they are printed. The random output file will have 12 unique values that match the dictionary.


- The code must be modularized and usefunctions. Nofunctionsno points. Constants such as MAXRAIN should be at the top outside any defined (def) functions.
- The remaining code must either be inside defined (def) functions.
- The only exception is if __name__ == "__main__": or similar which calls the first function to execute.


- The code needs to include at leastfunctionsto generate rain, print results, and write to file.


- If you have a dictionary and need a list to use in the random,choice function you may use the built in list().)


key = random.choice(list(month_dict))

Sep 27, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here