In
Write a program that computes and displays the batting average for a baseball player when the user inputs the number of hits and at-bats for that player. Batting average is computed by dividing the number of hits by the number of at-bats. You will need the following variables:
Hits (an Integer) AtBats (an Integer) BatAvg (a Float)
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
Prelude to Programming
Additional Engineering Textbook Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Concepts Of Programming Languages
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Database Concepts (7th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Database Concepts (8th Edition)
- in python Create a single function that will return the area OR the volume of an object. i.e. if you call the function with the values (10,8), it will return 80; if you call the same function using values (10,2,3) it will return 60.arrow_forwardPython code Screenshot and output is mustarrow_forwardWrite a wholly creative quiz program that consists of three original questions that you make up according to these specifications: One question should require user input of type int One question should require user input of type float One should require a string input The quiz should be scored by using a counter variable that has an initial value of zero and is incremented by one for every correct answer. Provide feedback to the user for each question, and report the total score when the quiz has finished. Example runs not shown. It's a creative exercise. def main():points = 0states = int(input('How many states in the USA? '))if states == 50:points +=1print('Correct. Good job!')else:print('Sorry, the answer is 50') points = 0capital = input('What is the capital of England? ')if capital == "London":points+=1print('Correct. Well done.')else:print('Sorry, the answer is London .') points = 0points = float(input('How many points does a pentagram have? '))if points == 10:points…arrow_forward
- IN PYTHON PLEASE AND FLOWCHART DRAWING COMPUTERIZED PLEASE!! In many businesses across the country, people are buying food and goods using cash. Whenever a purchase is made with cash, it is usual that change must be back to the customer. Business point of sales software help to ensure that the correct change is return to a customer by providing detailed information of the change that should be returned to the customer. using the fewest number of bills and coins. In this assignment, you are asked to design and implement a program that writes out what bills (ones, fives, tens, twenties) and coins (pennies, nickels, dimes, and quarters) that should be returned to the customer given two inputs from the user: A total cost of a sale. The amount that was paid by the customer. Ensure that your output is grammatically correct. If the customer does not provide adequate payment, you should print the following statement, the program should end. Did not receive enough cash from the customer.…arrow_forward5. A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, how- ever, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Use the function in a program that prompts the user to enter a number then displays a message indicating whether the number is prime. 6. In another program, use the function you wrote in question 5 to print the prime numbers between 1 and 100 using for loop.arrow_forwardQUESTION 5 This is a MULTIPLE ANSWER question, which means you are able to select one or more answers as being correct. Note that this does not necessarily mean that there are multiple correct answers. In any case, select all the answers you believe are correct. (NB: There are no part marks awarded for multiple answer questions.) Consider the following Python code, where the variables level and threshold have integer values: alarm = 3 if level = threshold: if level < 100: alarm = 1 alarm = 2 What initial values for variables level and threshold guarantee that variable alarm ends up with the value of 2 after the code has executed? When level is 200 and threshold is 99 When level is 4 and threshold is 5 ☐ When level is 200 and threshold is 100 When level is 400 and threshold is 300 When level is 5 and threshold is 4 When level is 3 and threshold is 4 When level is 1 and threshold is 2 O When level is 10 and threshold is 10arrow_forward
- In CORAL LANGUAGE please and thank you! Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray). Given values for red, green, and blue, remove the gray part. Ex: If the input is: 130 50 130 the output is: 80 0 80 Hint: Find the smallest value, and then subtract it from all three values, thus removing the gray.arrow_forwardA Fibonacci Number sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is calculated by adding up the two numbers before it. Write a program called fib.cpp. The program will print out the n" Fibonacci Numbers using a function called: void FibonacciNumber (int n, int& fib_no) This function will calculate the n term in the Fibonacci Numbers and return in fib_no. By definition, the function returns 0 for n=1, and returns 1 for n = 2. For the subsequence number: nth = (n - 2)th + (n - 1)th You need to verify the input n > 0. Task 2 Sample Output Please enter the nth term Fibonacci number to compute: -1 Please enter a number greater than 0! Please enter the nth term Fibonacci number to compute: 12 The Fibonacci series is: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 The 12th. term is: 89arrow_forward60. Please solve in Python and provide Code. Thank youarrow_forward
- A game calculates the average game scores for their players in three attempts. The score in the game is based on the number of attempts and the score in each attempt. Write a python program using void function with parameters concept. • Function accepts the number of attempts as a parameter. • Use loop to do the following, Accept the attempt score. Accept the number of players. • Calculate the final score, Final score = attempt score + (Number of players*0.25) • Calculate the average score, Average score = Total Final Scores in three attempts / number of attempts • Display the output of Average score. Call the function with three attempts. Sample output: Accept the attempt score: 80 Accept the number of players Accept the attempt score: 50 Accept the number of players Accept the attempt score: 90 Accept the number of players Average score= 4 74.33333333333333 Your are required to copy and paste the code in the given white area below the question. You need also to upload a word file…arrow_forwardA business that uses functions to calculate the weekly payment amounts of employees in a workplace.you are asked to write a program.The weekly payment amount of an employee depends on the following variables:- Number of hours worked - (minimum: 0, maximum: 60)- Hourly wage - (minimum: 0.00 TL, maximum: 30.00 TL)- Number of exemptions - (minimum: 0, maximum: 5)Using these 3 values,- Gross payment amount- General income taxLocal income tax- Social security amount- Net payment amountwill be calculated. →The maximum number of hours an employee can work before earning overtime pay is 40 hour. If the number of hours worked is less than or equal to 40, the gross payment amount will be equals the product of the wage. If the number of hours worked is more than 40, the gross payment amount is 40 times the hourly wage. plus 1.5 times the hourly rate for every hour over 40 →The general withholding tax is 55.77 TL for the weekly payment period. The employee is subject to general taxation the gross…arrow_forwardWrite a function that returns the number of days in a year using the following header:def numberOfDaysInAYear(year):Write a test program that displays the number of days in the years from 2010 to 2020.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning