Suppose every day you wake up and you are randomly in a GOOD mood 60% of the time or in a BAD mood 40% of the time. Furthermore, anytime you have a quiz or test in a course, the grade you receive is also random based on the following:
If you take a quiz or exam when you are in a GOOD mood,
- you get a 100 on 80% of such days
- you get a 75 on 20% of such days
If you take an exam when you are in a BAD mood,
- you get a 100 on 20% of such days
- you get a 75 on 30% of such days
- you get a 50 on 50% of such days
Write python code that does the following
- Write a function to generate your grade on a random quiz/exam day - name this function takeOneTest()
Comments: this function may or may not have any parameters.
when you run this function, it will output one random test score (a 50, 75, or 100).
there are multiple ways for this function, consider using the runif() or sample() functions for the random components and if-else structures.
- Write a 2nd function to calculates an arbitrary number of exam results - name this function SemesterGrades(num_tests).
Comments: This function should call takeOneTest() a user specified number of times (num_tests).
when you run this function, it will output num_tests values, each value corresponding to a single random test score. This can be done in multiple ways as well [while() or for() ].
so for example, output from SemesterGrades(6) may result in: 100 50 75 75 100 75
This is some code I have but in R
GorBday ← sample(c(“Good”, “Bad”), size=1, prob=c(0.60, 0.40))
GoodDayTscore ← sample(c(“100”, “75”), size=1, prob=c(0.80, 0.20))
BadDayTscore ← sample(c(“100”, “75”, “50”), size=1, prob=c(0.20, 0.30, 0.50))