Question

In: Computer Science

Ask the user to enter a basketball player’s free throw percentage, eg. 70%. Your program will...

Ask the user to enter a basketball player’s free throw percentage, eg. 70%. Your program will simulate the player playing 5 games, each game making 10 free throws. Display the result of the free throws in each game. At the end, print a summary that shows the best/worst game for this player, and the average free throw percentage of the 5 games. Question: How do you simulate a 70% free throw shooter making a free throw? Hint: How about generating a number between 0-100, and checking if that number is less than or equal to 70. If so, you just made a free throw!

Solutions

Expert Solution

Find the code in Python below:

import random
print("Enter the user's free throw percentage = ")
freethrow = int(input())
sum1 = 0
max1=0
min1=100
for i in range(5):
    for x in range(10):
        randno = random.randint(1,101)
        if randno<=freethrow:
            sum1 = sum1 + randno
            if randno>max1:
                max1=randno
            if randno<min1:
                min1=randno
avg = sum1/50
print("Average freethrow percentage = " + avg)
print("Best Game = " + max1)
print("Worst Game = " + min1)



Related Solutions

A basketball player’s free-throw average is calculated as the average number of made shots relative to...
A basketball player’s free-throw average is calculated as the average number of made shots relative to total attempts. Suppose Shaquille currently has a 25% free-throw average and is a very consistent (if not a very good) shooter. During today’s game, this player will be at shoot exactly nine free throws (a) What is the probability that he ends up with three made shots? (b) What is the probability he ends up with no made shots? (c) What is the probability...
In your python program, ask the user to enter the annual income of an employee and...
In your python program, ask the user to enter the annual income of an employee and the years of experience. Pass these data to a function. The function decides if an employee does qualify for a loan or does not, then it prints a message based on the following rules: If the income is equal or greater than $40000, the function checks if the employee’s years of experience is greater than 4, if so the employee gets $6000 loan; otherwise,...
Write a program that will ask the user to enter the amount of a purchase. The...
Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 5 percent and the county sales tax is 2.5 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the...
1. Write a program that will ask the user to enter a character and then classify...
1. Write a program that will ask the user to enter a character and then classify the character as one of the following using only IF-ELSE and logical operators. (50 points - 10pts for syntax, 10pts for commenting and 30pts for successful execution) • Integer • Lower Case Vowel • Upper Case Vowel • Lower Case Consonant • Upper Case Consonant • Special Character
Write a program that does the following. It will ask the user to enter an integer...
Write a program that does the following. It will ask the user to enter an integer larger than 1, and the if entered integer is not larger than 1, it keeps prompting the user. After the user enters a valid integer, the program prints all the prime factors of the integer (including the repeated factors). For example, if the entered integer is 24, the program prints: 2 2 2 3 Run your program with the test cases where the entered...
A basketball player shoots 3 free throws. On each throw, she has a 70% chance of...
A basketball player shoots 3 free throws. On each throw, she has a 70% chance of making the shot. Assume the outcomes of the throws are independent. What is the probability that she makes the first two free throws and then misses the last one?
write a program i java that ask the user to enter salary, user ID and username...
write a program i java that ask the user to enter salary, user ID and username and out put them
Write a MIPS program that will ask the user to enter two numbers at the console...
Write a MIPS program that will ask the user to enter two numbers at the console and pass the values to a function that does multiplication
Kay has an 80% probability of making a free-throw in basketball,and each free-throw is independent....
Kay has an 80% probability of making a free-throw in basketball, and each free-throw is independent. Kay gets to take 2 free-throws, and must make both to win the game. What is the probability that Kay's team will win the game?1. 64%2. 80%3. 88%4. 160% (so 100%)
Your Application should ask the user to enter their name and their salary.
Create a C# Console Application, name the solution Homework 6 and the project TaxRate.Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT