On the NASA Space Shuttle, three computers were in simultaneous use. Computation
ID: 3709805 • Letter: O
Question
On the NASA Space Shuttle, three computers were in simultaneous use. Computations were performed by all three computers. The result of each computation was put to a vote. If at least two of the computers provided the same result, that result was used. If all three computers each provided a different result, then the computation was discarded. Your second function will implement the voting algorithm. The second function you will write should be called ‘voteComp’. Your function should take three (3) arguments: each one an integer. The function should return one (1) value that will be either a number or string according to the following algorithm. Each input integer will represent the output of one of the three computers. If at least two of the arguments contain the same integer value, the function should return that value. If all three values are different, the function should return the string ‘ERROR’. Example Test Case: voteComp(34, 45, 34) returns 34
Explanation / Answer
Hi Dear,
Please find my code in python:
Output:
34
ERROR
Process finished with exit code 0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.