
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
![Write a Python program that will take a string as a user input where
multiple numbers are separated by commas. If the string contains anything
other than Integer numbers and commas, then print "Failed to complete the
taskl". Otherwise, make a list of numbers from the input string.
If the sum of all the numbers in the list is EVEN, then replace the MAXIMUM
value in the list with the AVERAGE number. Otherwise, replace the MINIMUM
value in the list with the AVERAGE number. Finally, print the modified
list. You need to make sure all the numbers in the modified list are
Integer type.
Sample Input 1:
7,9,6,3,8
Sample Output 1:
Before modification: [7, 9, 6, 3, 8]
1.
After modification: [7, 9, 6, 6, 8]
Explanation 1:
Sum of all the numbers in the list is 7 + 9 + 6 + 3 + 8 = 33 which is odd.
The average is 33/5 = 6.6 and the minimum value is 3. So, after converting
the average value into integer and replacing it with the minimum value, we
get the desired output.](https://content.bartleby.com/qna-images/question/0d584d04-78d2-496b-88c2-3ac1e5cc3ed8/6c95f071-efa9-48fc-90df-8816b9152ef1/hjah9p_thumbnail.jpeg)
Transcribed Image Text:Write a Python program that will take a string as a user input where
multiple numbers are separated by commas. If the string contains anything
other than Integer numbers and commas, then print "Failed to complete the
taskl". Otherwise, make a list of numbers from the input string.
If the sum of all the numbers in the list is EVEN, then replace the MAXIMUM
value in the list with the AVERAGE number. Otherwise, replace the MINIMUM
value in the list with the AVERAGE number. Finally, print the modified
list. You need to make sure all the numbers in the modified list are
Integer type.
Sample Input 1:
7,9,6,3,8
Sample Output 1:
Before modification: [7, 9, 6, 3, 8]
1.
After modification: [7, 9, 6, 6, 8]
Explanation 1:
Sum of all the numbers in the list is 7 + 9 + 6 + 3 + 8 = 33 which is odd.
The average is 33/5 = 6.6 and the minimum value is 3. So, after converting
the average value into integer and replacing it with the minimum value, we
get the desired output.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
Similar questions
- Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Assume that the list will always contain less than 20 integers. Ex: If the input is: the output is: 5 50 60 140 200 75 100 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. For coding simplicity, follow every output value by a comma, including the last one. Such functionality is common on sites like Amazon, where a user can filter results. 5 6 50,60,75, 1 #include 2 3 int main(void) { 4 78991 11 10 } const int NUM_ELEMENTS = 20; int userValues [NUM_ELEMENTS]; /* Type your code here.arrow_forwardWrite a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow. Ex: If the input is: 5 2 4 6 8 10 the output is: all even Ex: If the input is: 5 1 3 5 7 9 the output is: all odd Ex: If the input is: 5 1 2 3 4 5 the output is: not even or odd Your program must define and call the following two functions. is_list_even() returns true if all integers in the list are even and false otherwise. is_list_odd() returns true if all integers in the list are odd and false otherwise.def is_list_even(my_list)def is_list_odd(my_list) if __name__ == '__main__': both def and if need to be included and functions called from both defs def is_list_even(my_list):for i in range(len(my_list)):if my_list[i] % 2 != 0:return False or Truedef is_list_odd(my_list):for i in range(len(my_list)):if my_list[i] % 2 == 0:return False or Trueif is_list_odd == True:print("all…arrow_forwardI need help coding this in Java language pleasearrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY