The largest value is 78
The smallest value is -50
# LargeSmall.py - This program calculates the largest and smallest of three integervalues. # Declare and initialize variables herefirstNumber = -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))
Answer:
Here is the python code as per your requirement
Raw code:
#declaring given variables in question
firstNumber = -50
secondNumber = 53
thirdNumber = 78
#checking if the first number is greater than the second and third
if firstNumber>secondNumber and firstNumber>thirdNumber:
#if yes store the first in largest
largest=firstNumber
#checking if the second number is greater than the first and third
elif secondNumber>firstNumber and secondNumber>thirdNumber:
#if yes store the second in largest
largest=secondNumber
#if both aren't largest nmbers then the remaining will be largest so assign third to largest
else:
largest=thirdNumber
#checking if the first number is smaller than the second and third
if firstNumber<secondNumber and firstNumber<thirdNumber:
#if yes store the first in smallest
smallest=firstNumber
#checking if the second number is lesser than the first and third
elif secondNumber<firstNumber and secondNumber<thirdNumber:
#if yes store the second in smallest
smallest=secondNumber
#if both aren't smaller nmbers then the remaining will be smaller so assign third to smallerst
else:
smallest=thirdNumber
#printing values
print("The largest value is " + str(largest))
print("The smallest value is " + str(smallest))
Editor:
output:
Hope this helps you! If you still have any doubts or queries please feel free to comment in the comment section.
"Please refer to the screenshot of the code to understand the indentation of the code".
Thank you! Do upvote.
Two variables named largest and smallest are assigned for you. Use these variables to store the...
Swapping Values in python Summary In this lab, you complete a Python program that swaps values stored in three variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate....
I need help with this. Can someone please show me the solution. Declaring and Initializing Java Variables Summary In this lab, you declare and initialize variables in a Java program. The program file named NewAge.java, calculates your age in the year 2050. Instructions Declare an integer variable named newAge. Declare and initialize an integer variable named currentAge. Initialize this variable with your current age. Declare and initialize an integer variable named currentYear. Initialize this variable with the value of the...
Multiple Conditional Statements Summary In this lab, you complete a Python program that calculates an employee's annual bonus. Input is an employee's first name, last name, salary, and numeric performance rating. If the rating is 1, 2, or 3, the bonus rate used is .25, .15, or .1 respectively. If the rating is 4 or higher, the rate is 0. The employee bonus is calculated by multiplying the bonus rate by the annual salary. Variables have been declared for you,...
Exercise3 Suppose you have several points with coordinates (xk, v) located in the 2-D plane. The points are sorted from smallest to largest x coordinate. You want to find the slope of the line between each successive pair of points, i.e., between (xbw) and (xkl.yk. These are the points: (-5, 9), (-1, 5), (2,7), (8, 12), (13, 5), (15, -4), (20, 0), (45, 3), (66, 10), (70, 8) Write a program that meets these requirements: Create a 1-D array named...
(C++) Topic: Please write a function Order (int *largest, int *medium, int*smallest). The function of this function is to rearrange the value of the whole index pointed to by the three indicators, that is, how to set the indicator that is passed in. If the function ends, it must be largest to point to the largest value, smallest to the smallest value, medium to point to The value in the middle. For example, consider the following main(). The order of...
Write you code in a class named HighScores, in file named HighScores.java. Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look approximately like this: Enter the name for score #1: Suzy Enter the score for score #1: 600 Enter the name for score...
Write a C program that will do the following: 1.Declare four integers variables. intVar1, intVar2, intVar3,and intVar4. 2. Initialize intVar1 to the value 4; initialize intVar2to the value 5. 3. Declare four more integer variables. exp1, exp2,exp3, and exp4. 4. Declare a character variable charVar. 5. Assign the value of each expression below to variables exp1and exp2 respectively: exp1= intVar1 + ((5 * intVar2) / (3 * intVar1)); exp2 = intVar1 + (5 * (intVar2 / 3)) * intVar1; 6....
Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code. An array of 1000 integers is declared. What is the largest integer that can be used as an index to the array? Shows the code. Consider the declaration: int v[1]; What is the index of the last element of this array? Declare an array named a of 10 int elements and initialize the elements (starting with the first) to the...
Write an assembly program which prints the largest values among three variables. You can initialize three integers in data section (let's say 10, 45, 15).
C++ pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point to an int variable named someInt. Assign the value 451 to someInt and output (cout) the variable someInt and output (cout) the value pointed to by intPointer. Write an assignment statement that indirectly stores 900 into the value pointed to by intPointer. Output (cout) the value pointed to by intPointer and output (cout) the variable someInt, 2. Declare a pointer variable charArrPointer and initialize...