Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please solve the following programming problem the code must be done in python also I wont forget to like the answer thank you Roll a
please solve the following programming problem the code must be done in python also I wont forget to like the answer thank you
Roll a dice many times, you will see that each face value will count of roughly 1/6 write a function roll a dice once, return value will be 1-6, use your functin call your function 6000 times count how many times of face 1 count how many times of face 2 print out the numbers of total face 1, 2, ..., 6 you counted I wrote a flip coin code for your reference, you can make the rolling dice similarily. function return 1 or 0 in this case call function 10000 times and print out In [15]: import random def flip_coin(): x = random.random() if x > 0.5: return 1 else: return o #test the function print(flip_coin()) In [22]: # use the function defined above ere to search o ^ = 2:58 AM 1) 2/10/2020 4 In [2]: # use the function defined above random.seed (0) heads = 0 tails = 0 for i in range (10000): x = flip_coin() if x == 0: heads = heads + 1 else: tails = tails + 1 print(" heads:", heads, " It tails:", tails) heads: 4980 tails: 5020Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started