Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Python Probability problem

shayman23

New Coder
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
I have the code for this in R but am struggling to do it in python.

Code:
GorBday <- sample(c("Good", "Bad"), size=1, prob=c(0.60, 0.40))

## This is the code to determines test scores on good days
GoodDayTscore <- sample(c("100", "75"), size=1, prob=c(0.80, 0.20))
GoodDayTscore
## This is the code that determines test scores on bad days
BadDayTscore <- sample(c("100", "75", "50"), size=1, prob=c(0.20, 0.30, 0.50))
BadDayTscore

I need help in taking this code from r and converting it to Python.
Thanks
 
I know very little about Python and nothing at all about R. But I see there are a lot of web pages dealing with converting R to Python. Is none of them any use to you ? What exactly is the problem that you have ?
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom