5.6 1 Function Stubs Statistics
- Home »
- Questions »
- Engineering »
- Mechanical Engineering »
- Challenge Activity v.half-dozen.one: Function stubs:...
CHALLENGE ACTIVITY 5.half dozen.ane: Office stubs: Statistics. Ascertain stubs for the functions get_user_num(). ane answer below »
Challenge ACTIVITY five.half dozen.1: Function stubs: Statistics. Define stubs for the functions get_user_num() and compute_avg(). Each stub should impress "FIXME: Finish function_name()" followed by a newline, and should return-ane. Each stub must also comprise the function's parameters. Sample output with ii calls to get_user_num() and i phone call to compute_avg(): FIXME: Finish get_user_num( ) FIXME: End get_user_num( ) FIXME: Finish compute_avg() Avg: -ane 1 2. Your solution goes hither." 3 four user_num1 = 0 5 user_num2 = 0 6 avg_result = 0 seven 8 user_num1 get_user_num() 9 user_num2 = get_user_num() 10 avg_result = compute_avg(user_num1, user_num2) eleven 12 print('Avg:', avg_result) ZYDE v.7.1: User-defined functions make a program easier to understand. The problem below uses the role get_numbers() to read a number of integers from the user. Three unfinished functions are divers, which should impress but sure types of numbers that the user entered. Consummate the unfinished functions, calculation loops and branches where necessary. Friction match the output with the below sample: Enter 5 integers: 05 1 99 2-44 3 © four 12 Numbers: 5 99 -44 12 Odd numbers: v 99 Negative numbers: -44 599-44 0 12 Load default template... Run 15 return numbers 16 17 def print_all_numbers (numbers): eighteen # 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 impress("Negative numbers:') 28 29 xxx 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 one 99 2 -44 3 0 four 12 Numbers: Odd numbers: Negative numbers:
5.6 1 Function Stubs Statistics,
Source: https://www.transtutors.com/questions/challenge-activity-5-6-1-function-stubs-statistics-define-stubs-for-the-functions-ge-8421142.htm
Posted by: richardsonderd1969.blogspot.com

0 Response to "5.6 1 Function Stubs Statistics"
Post a Comment