Two variables named largest and smallest are assigned for you. Use these variables to store the largest and smallest of the three integer values. You must decide what other variables you will need and initialize them if appropriate.

Write the rest of the program using assignment statements, ifstatements, or elif statements as appropriate. There are comments in the code that tell you where you should write your statements. The output statements are written for you.

Execute the program. Your output should be:

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))

Respuesta :

ijeggs

Answer:

# 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

#Finding the Largest

if firstNumber>secondNumber and firstNumber>thirdNumber:

   largest = firstNumber

elif secondNumber>firstNumber and secondNumber>thirdNumber:

   largest = secondNumber

else:

   largest = thirdNumber

#Finding the smallest

if firstNumber<secondNumber and firstNumber<thirdNumber:

   smallest = firstNumber

elif secondNumber<firstNumber and secondNumber<thirdNumber:

   smallest = secondNumber

else:

   smallest = thirdNumber

# Output largest and smallest number.

print("The largest value is " + str(largest))

print("The smallest value is " + str(smallest))

Explanation:

Given that Most part of the code has already being written using python programming language. Our task was to add the necessary if and else statements that will check the three numbers and return the largest and smallest among them. Check the attached screenshoot for the program output, also read the comments made in  the code

Ver imagen ijeggs