Question: In Python, 2.2 Implement each of the following programs as a SISO Python program. In each case you may assume the input is valid (i.e.,

In Python,

2.2 Implement each of the following programs as a SISO Python program. In each case you may assume the input is valid (i.e., consists of a correctly formatted list of integers). (a) Write a program that takes as input a list of integers separated by whitespace. The output is a string representing the sum of every second integer in the list. For example, if the input is 58 41 78 3 25 9 then the output is 53, because 41 + 3 + 9 = 53. (b) Write a program, similar to the program in (a), but adding up every third element of the input instead of every second element. (c) Write a decision program that accepts a list of integers if the sum of every third element is greater than the sum of every second element, and rejects otherwise. Your program must import and use the programs from (a) and (b).

You can use this code as a starting point for a, all you need to change is lines 9-12

In Python, 2.2 Implement each of the following programs as a SISO

N def multiplyAll (inString): # split on whitespace numbers = inString.split() 6 # convert strings to integers for i in range (len (numbers)): numbers [i] = int (numbers [i]). 00 10 # compute the product of the numbers array product = 1 for num in numbers: product = product * num 12 14 # convert the product to a string, and return it productString = str (product) return productString 16

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!