![smokey13](/avatars/1817.jpg)
smokey13
09.12.2021 •
Computers and Technology
(Compute greatest common divisor using recursion) The gcd(m, n) can also be defined recursively as follows: If m % n is 0, gcd(m, n) is n.Otherwise, gcd(m, n) is gcd(n, m % n). Write a recursive function to find the GCD. Write a test program that prompts the user to enter two integers and displays their GCD.
Solved
Show answers
More tips
- S Style and Beauty How to Choose the Perfect Hair Straightener?...
- F Family and Home Why Having Pets at Home is Good for Your Health...
- H Health and Medicine How to perform artificial respiration?...
- H Health and Medicine 10 Tips for Avoiding Vitamin Deficiency...
- F Food and Cooking How to Properly Cook Buckwheat?...
- F Food and Cooking How Many Grams Are In a Tablespoon?...
- L Leisure and Entertainment Carving: History and Techniques for Creating Vegetable and Fruit Decorations...
- P Photography and Videography How to Choose the Perfect Photo Paper for Your Images?...
- H Health and Medicine What vaccines do children need?...
- H Health and Medicine Reasons for the Appearance of Warts: Everything You Need to Know...
Answers on questions: Computers and Technology
- E English What is the 2015 south africas youth unemployment rate....
- B Biology What is the difference between a genotype and a phenotype?...
- M Mathematics Identify the prime numbers in the following lists. a. 5, 7, 12, 11 b. 14, 6, 3 c. 31, 17, 9, 15 d. 782, 61, 2...
- M Mathematics Find the solution to the system of equations y=x-4 and y=4x+2...
- S Social Studies Bipolar i disorder is to bipolar ii disorder as is to...
- E English How many grams are in 88.1 moles of mgcl2...
- H History Which states felt the most comfortable with the new jersey plan...
- E English Fast! i need writing my narrative essay. i wrote the introduction and now i need with the body and conclusion. the body needs to be 3 paragraphs and 300 words or more....
- M Mathematics The height of a tree in feet over x years is modeled by the function f(x). f(x)= 30/1+29e−0.5x which statements are true about the growth of the tree? select each correct...
- M Mathematics In which of the following do you expect the correlation coefficient to be closest to 1?...
Ответ:
Follows are the code to this question:
def Contestant_Score(l):#defining a method Contestant_Score that accepst a list
mi=min(l)#defining mi variable that use min method to hold Lowest value
ma=max(l)#defining ma variable that use max method to hold highest value
y=sum(l)#defining y variable that hold sum of list
x=y-(mi+ma)#defining x variable that exclude mi and ma value
print("Lowest score: ", mi)#print Lowest score
print("highest score: ", ma)#print highest score
print("Calculating average excluding highest and Lowest number: ",x/3)#print average value
l=[9,5,7,4,6]#defining an empty list
Contestant_Score(l)#calling method
Output:
Lowest score: 4
highest score: 9
Calculating average excluding highest and Lowest number: 6.0
Explanation:
In the given code a method "Contestant_Score" is defined that accept a list in its parameter and inside the method three variable "mi, ma, and y" is defined, that uses the "min, max, and sum" to hold a value in a variable.
In the next step, x variable is defined that exclude the "mi and ma" value from y and calculate its average value and use the print method to print its value.Outside the method, a list is defined that holds some value and pass into the method.