Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CHALLENGE ACTIVITY 5.6.1: Function stubs: Statistics. Define stubs for the functions get_user_num() and compute_avg(). Each stub should print FIXME: Finish function_name() followed by a newline,

image text in transcribedimage text in transcribed

CHALLENGE ACTIVITY 5.6.1: Function stubs: Statistics. Define stubs for the functions get_user_num() and compute_avg(). Each stub should print "FIXME: Finish function_name()" followed by a newline, and should return-1. Each stub must also contain the function's parameters. Sample output with two calls to get_user_num() and one call to compute_avg(): FIXME: Finish get_user_num( ) FIXME: Finish get_user_num( ) FIXME: Finish compute_avg() Avg: -1 1 2. Your solution goes here." 3 4 user_num1 = 0 5 user_num2 = 0 6 avg_result = 0 7 8 user_num1 get_user_num() 9 user_num2 = get_user_num() 10 avg_result = compute_avg(user_num1, user_num2) 11 12 print('Avg:', avg_result) ZYDE 5.7.1: User-defined functions make a program easier to understand. The problem below uses the function get_numbers() to read a number of integers from the user. Three unfinished functions are defined, which should print only certain types of numbers that the user entered. Complete the unfinished functions, adding loops and branches where necessary. Match the output with the below sample: Enter 5 integers: 05 1 99 2-44 3 4 12 Numbers: 5 99 -44 12 Odd numbers: 5 99 Negative numbers: -44 599-44 0 12 Load default template... Run 15 return numbers 16 17 def print_all_numbers (numbers): 18 # Print numbers 19 print('Numbers:') 20 21 def print_odd_numbers (numbers): 22 # Print all odd numbers 23 print('Odd numbers:') 24 25 def print_negative_numbers (numbers): 26 # Print all negative numbers 27 print("Negative numbers:') 28 29 30 31 nums = get_numbers (size) 32 rint_all_numbers (nums) 33 print_odd_numbers(nums) 34 nrint negative numbers (nums) 35 Enter 5 integers: 05 1 99 2 -44 3 0 4 12 Numbers: Odd numbers: Negative numbers

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions