asked 144k views
0 votes
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
Two variables named largestand 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, if statements, or elifstatements 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))

1 Answer

1 vote

Below is a completion of the Python program that computes the largest and smallest of three integer values (-50, 53, 78):

The Completed Code

# 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

largest = max(firstNumber, secondNumber, thirdNumber)

smallest = min(firstNumber, secondNumber, thirdNumber)

# Output largest and smallest number.

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

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

This completion utilizes Python's max() and min() functions to find the largest and smallest values among the given integers and prints the results accordingly. The output will display:

The largest value is 78

The smallest value is -50

answered
User Robert Parham
by
7.9k points