Question: Using Python: 3 points] Create a file named roll_one.py . Write a program that rolls two, six-sided dice. Continue rolling both dice until exactly one

Using Python:

  1. 3 points] Create a file named roll_one.py. Write a program that rolls two, six-sided dice. Continue rolling both dice until exactly one of the dice has a one. Print the number of rolls needed to achieve this.
  2. [3 points] Create a file named comparison.py. In this file, create the following functions:
  • Write a function max2 that returns the larger of the two parameters. For example, print(max2(9,7)) would print 9.
  • Write a function max3 that returns the maximum of three parameters. For example, print(max3(4,2,9)) would print 9.
  • Write a function middle that returns the middle of three numbers. Calling print(middle(4,1,9)) would print 4.
  1. [4 points] Create a file named coin_flips.py that does the following:
  • Asks the user for the number of times to flip the coin.
  • Asks the user for the probability the coin lands heads side up as a decimal (0.5 would mean there is a 50% chance that the coin lands heads up). This is a biased coin like we discussed in the video lessons.
  • Flips the coin the specified number of times, tracking the number of times the coin lands on heads or tails.
  • Prints out the number of times the coin landed heads up and tails up.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!