Concept explainers
Test Average and Grade
Write a
▪ calc_average. This function should accept five test scores as arguments and return the average of the scores.
▪ determine_grade. This function should accept a test score as an argument and return a letter grade for the score based on the following grading scale:
Score | Letter Grade |
90-100 | A |
80-89 | B |
70-79 | C |
60-69 | D |
Below 60 | F |
Learn your wayIncludes step-by-step video
Chapter 5 Solutions
Starting Out with Python (4th Edition)
Additional Engineering Textbook Solutions
Java How To Program (Early Objects)
Starting Out With Visual Basic (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Modern Database Management
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Computer Systems: A Programmer's Perspective (3rd Edition)
- FizzBuzz Interview Question Create a function that takes a number as an argument and returns "Fizz", "Buzz" or "FizzBuzz". If the number is a multiple of 3 the output should be "Fizz". If the number given is a multiple of 5, the output should be "Buzz". If the number given is a multiple of both 3 and 5, the output should be "FizzBuzz". If the number is not a multiple of either 3 or 5, the number should be output on its own as shown in the examples below. The output should always be a string even if it is not a multiple of 3 or 5. Examples fizz_buzz (3) "Fizz" fizz_buzz (5) → "Buzz fizz_buzz (15) "FizzBuzz" fizz_buzz (4) "4" 11arrow_forwarder 6 Functions Programming Exercises te 1. Rectangle Area ngle Area The area of a rectangle is calculated according to the following formula: Area = Width X Length Design a function that accepts a rectangle's width and length as arguments and returns the rectangle's area. Use the function in a program that prompts the user to enter the rectangle's width and length, and then displays the rectangle's area.arrow_forwardDomino's Time Function Name: dominosTime() Parameters: N/A Returns: None Description: During the summer, you ordered a lot of food from Domino's. Pizzas are $12, an order of pasta is $6, and chicken wings are $8. Write a function that asks the user how many of each food item they would like, and then print a response telling them what their order to- tal will be. The order total should be an integer. >>> dominosTime() How many pizzas do you want? 3 How many orders of pasta do you want? 2 How many orders of chicken wings do you want? 2 By ordering 3 pizzas, 2 orders of pasta, and 2 orders of chicken wings, your order total comes to $64.arrow_forward
- Student Number, Grade 101029383,90 192736611,10 109800384,0 292833315,80 Complete the function below. If a line is long, you may write it in multiple lines at one blank, but please only write a single statement. def write_final_grades (assignment_grades: Dict, resubmit_grades: Dict, fname: str) -> None: """Write final marks to a final grade file named fname. assignment_grades maps student numbers to grades for the original assignment submission. resubmit_grades maps student numbers to grades for the resubmission of the same assignment. The resubmit penalty of 20% has not been applied within resubmit_grades. The higher mark, after resubmit penalties are applied, is the final mark for a student. Assume that the same student IDs are in both dictionaries. Assuming "grades.txt" is the original grade file shown (on the previous page) and "resubmit.txt" is the file above this function header: >>> original = make_dictionary ("grades.txt") >>> resubmit = make_dictionary ("resubmit.txt") >>>…arrow_forward____ are declared within the body of a function. (A) Variables (B) Local variables (C) Main functions (D) Arraysarrow_forwardPhython: Create a function so that when giving you a month it tells you the season of that month, for example: if it is January it will be winter.Using the def, try and except ValueError functions.arrow_forward
- A function may return a struct: True Falsearrow_forwardThe Problem__: Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: ⚫ void getScore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of the five scores to be entered. ⚫ void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. ⚫int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. Input Validation: Do not accept test scores lower than 0 or higher than 100. YOU MUST USE THE STATED FUNCTIONS AND COMPLETE Input VALIDATION. **DO NOT use an ARRAY OR GLOBAL VARIABLES!!. you MUST USE function prototyping TEST THE FUNCTION TWICE.…arrow_forwardhelppp meee Instructions: You are provided with the isLeapYear() function which is already declared and defined for you. Your task is to ask the user for a year and then call the isLeapYear function to check whether the year is a leap year or not. Input 1. Year to be checked Output should be like this: Enter year: 2020 2020 is a leap year note: If a certain year is a leap year, print "<INSERT_YEAR_HERE> is a leap year" Otherwise, print "<INSERT_YEAR_HERE> is not a leap year" MY CODE: (IN C LANGUAGE PLEASE) #include<stdio.h> int isLeapYear(int); int main(void) { // TODO: Write your code here return 0;} int isLeapYear(int n) { if( (n % 4 == 0 && n % 100 != 0) || (n % 100 == 0 && n % 400 == 0) ) { return 1; } return 0;}arrow_forward
- C++ Visual 2019 Write a program that determines which of five geographic regions within a major city (north, south, east, west, and central) had the fewest reported automobile accidents las year. It should have the following two functions, which are called by main: int getNumAccidents() is passed the name of a region. It asks the user for the number of automobile accidents reported in that region during the last year, validates the input, then returns it. It should be called once for each city region. void findLowest() is passed, the five accident totals. It determines which is the smallest and prints the name of the region, along with its accident figure. Input Validation: Do not accept an accident number that is less than 0.arrow_forward5. Falling Distance determine the distance the object falls in a specific time period: 1 d The variables in the formula are as follows: d is the distance in meters, g is 9.8 - t is the amount of time, in seconds, that the object has been falling. Design a function named fallingDistance that accepts an seconds) as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Design a program that calls the functiion in a loop that passes the values 1 through 10 as arguments and displays the return value object's falling time (inarrow_forwardFunctions are called by writing the name of the function followed by zero or more ____ enclosed in parentheses.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage