Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (4th Edition)
Starting Out with Java: Early Objects (6th Edition)
Starting Out with C++: Early Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Java How To Program (Early Objects)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- In python Write a function max_magnitude() with two integer input parameters that returns the largest magnitude value. Use the function in a program that takes two integer inputs, and outputs the largest magnitude value. Ex: If the inputs are: 5 7 the function returns: 7 Ex: If the inputs are: -8 -2 the function returns: -8 Note: The function does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the built-in absolute value function to determine the max magnitude, but you must still output the input number (Ex: Output -8, not 8). Your program must define and call the following function:def max_magnitude(user_val1, user_val2)arrow_forwardfor python program 1. 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, however, 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.Tip:Recall that the % operator divides one number by another and returns the remainder of the division. In an expression such as num1 % num2, the % operator will return 0 if num1 is evenly divisible by num2arrow_forwardYou are given 2 out of 3 angles in a triangle, in degrees. Write a function that classifies the missing angle as either "acute", "right", or "obtuse"based on its degrees. An acute angle is less than 90 degrees. A right angle is exactly 90 degrees. An obtuse angle is greater than 90 degrees (but less than 180 degrees). Example: missing_angle(27, 59) → obtuse WRITE IN PYTHON PLEASEarrow_forward
- 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: - getScore– This function ask the user for a test score, store it in a reference parameter variable, and validate it. For input validation, do not accept test scores lower than 0 or higher than 100. This function should be called by main () once for each of the five scores to be entered. - calcAverage – This function calculates and display the average of the four highest score. This function should be called just once by main (), by should be passed the five scores. - findLowest – This function finds and returns the lowest of the five scores passed to it. It should be called by calcAverage function, which uses the function to determine which of the five scores to drop.arrow_forwardWrite a program that paints the 4 areas inside the mxm square as follow: Upper left: black. RGB (0, 0, 0) Upper right: white. RGB (255, 255, 255) Lower left: red. RGB (255, 0, 0) Lower right: random colors Random colors Hint: Define a function that paints one of the four squares. Call the function 4 times to complete the painting. (painting means setting the pixels)arrow_forwardA prime number is an integer greater than 1 that is evenly divisible by only 1 and itself. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided by 1, 2, 3, and 6. Write a Boolean function named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, and false otherwise. Demonstrate the function in a complete program.arrow_forward
- write a python program 9. You are a class teacher at a kindergarten school. As a task, you asked your students to write a paragraph. Unfortunately, you notice that most of the students did not use capital letters correctly. Your task is to write a function which takes a string as its only parameter and returns a new copy of the string that has been correctly capitalized. Your function should: Capitalize the first letter in the string Capitalize the first letter after a full-stop, exclamation mark or question mark • Capitalize the word “i" if it is in lowercase. Summary: You have to write a function that reads a string from the user and capitalizes. The string is then returned and displayed. Sample Input ('my favourite animal is a dog. a dog has sharp teeth so that it can eat flesh very easily. do you know my pet dog's name? i love my pet very much.') Sample Output My favourite animal is a dog. A dog has sharp teeth so that it can eat flesh very easily. Do you know my pet dog's name? I…arrow_forwardWrite a C program that asks the user to enter an iPhone 6 wholesale cost and its markup percentage. Then, it should display the iPhone 6 retail price. For example: If user enters wholesale cost of iPhone is RM3 500.00 and its markup percentage is 100%, then the iPhone retail price RM7 000.00. The name of this function for this program is retailPrice ( ) that receives the wholesale cost and the markup percentage as parameters. Once the calculation has been made, this function will display the price. a- function with return value - display in main(), b- function without return value - display output in function definitionarrow_forwardI need to write a program named Palindrome.java that prompts the user to enter a string. The program should have a a static function named isPalindrome. This function should accept a string as an input and should return a boolean. The return value is true if the given string is a palindrome and false otherwise. (For this task you can assume the input string consists of alphanumeric characters.) Prompt the user to enter a string, then use isPalindrome to determine if the user input string is a palindrome or not. (Do not print to console in isPalindrome) A palindrome is a word, phrase, number, or other sequences of characters that reads the same backward or forward. Output should be as picture showsarrow_forward
- Implement a function named get_player_selection. This function has parameters for the players number (which will be either 1 or 2), and the number of sticks remaining on the board. For this function you will need to do the following: Use the input function to get the player to type in their selection. Validate the user’s input, printing out a message if they enter an invalid number and continually prompting them until they do enter a valid number. The user may enter any number between 1 and 3, unless there are fewer than 3 sticks remaining, in which case they can only enter between 1 and the number of sticks remaining. As in the example, the input prompt should list the valid range of numbers. Return the (validated) number as an integer (not a string). You should test that this function works by running it in the REPL. Make sure you try different scenarios, like the user entering an invalid number multiple times in a row. After you are done testing and fixing any errors you find,…arrow_forwardIn Python: Write a function called is_prime that receives a single integer value between 1 and 50 determines whether or not the integer is a prime. To determine if a number less than 50 is prime, you only need to divide it by all prime numbers less than or equal to the square root of 50 (i.e., 2, 3, 5, and 7). If any of them are smaller than the number and evenly divide the number, then it is not prime. By definition, 1 is not prime. Your solution should use the guess-and-check pattern. Write a main() function in your file to exercise your function to show that it works correctly. Your test implementation should not rely on visual inspection to determine if the tests pass.arrow_forwardWrite a program in python that prints a pyramid made of letters in the middle of the screen. Use functions with parameters for this assignment. The base width of the pyramid is determined by a character the user enters. If the user enters the letter o, the following pyramid will be printed. It can be assumed that the screen width is 80 characters. a aba abcba abcdcba abcdedcba abcdefedcba abcdefgfedcba abcdefghgfedcba…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education