Need help in creating a program using calling functions. Instructions shown in p
ID: 3686226 • Letter: N
Question
Need help in creating a program using calling functions. Instructions shown in picture below, Python only.
Problem 4: Defining and calling functions (25 points) For this problem, you will write three functions, which should obey the rules given in Problem 3. To get full credityour functions should call each other where appropriate to avoid duplicating work. Define a function named increasing that. • Takes a list of numbers as a parameter Returns True if each element is greater than or equal to its predecessor, and False otherwise. It should return True if the list has 0 or 1 elements. Examples Should return True for [90, 90, 90, 90, 90] Should return False for (91, 92, 93, 85 , 94] Define a function named average that .. • Takes a list of numbers as a parameter Returns their mean aExplanation / Answer
def average(list):
sum = 0.0
for number in list: # each number in list
sum = sum + number
l = len(list)
return sum/l
def increasing(list):
for i in xrange(len(list) - 1):
if list[i] > list[i+1]: # check increasing order
return False
return True
def print_results(list):
print average(list)
if increasing(list) == True:
print "Good Job!"
else:
print "Not Good Job!"
def main():
list = []
while True: # taking input
input = raw_input("Enter the number in list, quit to end: ")
if input == "quit":
break
else:
list.append(int(input))
print_results(list)
main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.