In: Computer Science
Post a Python program that accepts at least three values as input, performs some computation and displays at least two values as the result. The program must include an if statement that performs different computations based on the value of one of the inputs. Include comments in your program that describe what the program does. Also post a screen shot of executing your program on at least two test cases.
Solution:-
As per given question, we take two sets of three inputs.
In the first picture the inputs are 105 34 29
a[0]= 105 a[1]= 34 a[2]=29
if a[0]>100: // 105 >100 true
a[0]=a[0]+1 // 105+1=106
print(a[0]) // prints 106 and doesnt enters to else statement.
if a[2]< 50: // 29 <50 true
a[2]=a[2] - 10 // 29-10 =19
print(a[2]) // displays 19
2nd picture:
The inputs are 30 28 59
a[0]= 30 a[1]= 28 a[2]=59
if a[0]>100 // 30 >100 false and enters else statement
else:
a[0]=a[0]-5 // 30-5 =25
print(a[0]) // displays 25
if a[2] < 50 // 59 <50 false and enters else
else:
a[2]=a[2]*2 // 59*2=118
print(a[2]) //displays 118
Thanking you Sir/Madam.
Please upvote it if you are satisfied.
Your appreciation really matters to me.