Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help. I'm so lost. I need steps on how to do this. Write a function mugPurchase that determines if your friend has purchased the mug

help. I'm so lost. I need steps on how to do this.

image text in transcribed
Write a function mugPurchase that determines if your friend has purchased the mug in any one day. 4 Your function should: 1. Receive 1 argument: chance : an float that represents the probability of the mug being purchase by your friend 2. Check if the mug got purchased using chance 3. Returns a Boolean value True : if purchase was made False : if purchase was not made . Your solution MUST employ the "flag" technique to determine the outcome. Also, please provide 5 extra test cases like the ones shown: [ ]: import numpy as np +0 # Your solution def mugPurchase(chance) : # Test cases - uncomment to run . .. Part 2: Probability of buying a the tea collection for my friend Write a function calculateProb that determines the probability of you buying your friend the tea collection as a gift. Use the mugPurchase function created in Part 1. Return the probability of you buy the tea collection. Your function should: 1. Receive 3 arguments: prob : a float number repsenting the probability of your friend buying the mug at any given day numDays : an integer number repsenting how many days you need to wait until the paycheck arrives . scenarios : an integer number representing how many scenarios you will run to determine the output probability 2. For each scenario, calculate the number of times the outcome was you buying the tea or the mug. For each day that the mug was not purchased yet use the mugPurchase function from part 1. . If the mug gets purchased before you reach the final day of the numDays , you can move one to the next scenario. As you already have your outcome, 3, Returns a float; the probability of you purchasing the tea collection

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions