In: Computer Science
Summary
In this lab, you complete a prewritten Python program that computes the largest and smallest of three integer values. The three values are -50, 53, 78.
Instructions
The largest value is 78 The smallest value is -50
# LargeSmall.py - This program calculates the largest and
smallest of three integer values.
# Declare and initialize variables here
firstNumber = -50;
secondNumber = 53;
thirdNumber = 78;
# Write assignment, if, or if else statements here as appropriate
# Output largest and smallest number.
print("The largest value is " + str(largest))
print("The smallest value is " + str(smallest))
Thanks for the question, here is the simple short python code to find the largest and smallest number among the 3 numbers.
====================================================================
firstNumber = -50
secondNumber = 53
thirdNumber = 78
if (firstNumber >= secondNumber
and firstNumber >= thirdNumber):
largest = firstNumber
elif (secondNumber >= firstNumber
and secondNumber >= thirdNumber):
largest = secondNumber
else:
largest = thirdNumber
if (firstNumber <= secondNumber
and firstNumber <= thirdNumber):
smallest = firstNumber
elif (secondNumber <= firstNumber
and secondNumber <= thirdNumber):
smallest = secondNumber
else:
smallest = thirdNumber
print('The largest value is ' +
str(largest))
print('The smallest value is ' +
str(smallest))