Three values a, b and c are entered from the keyboard.
The program shows several variables for setting the minimum and maximum value.
The PYTHON program is:
The program shows several variables for setting the minimum and maximum value.
The PYTHON program is:
# Minimum and Maximum element choice between a, b, c
a = input('First number:')
b = input('Second number:')
c = input('Third number:')
minim = a
if (minim > b):
minim = b
if (minim > c):
minim = c
print('Minimum from a, b, c is:', minim)
if(a < b):
if(a < c):
minim = a
else:
minim = c
elif (b < c):
minim = b
else:
minim = c
print('Minimum from a, b, c is:', minim)
minim = a if (a < b) else b
minim = minim if (minim < c) else c
print('Minimum from a, b, c is:', minim)
minim = (a if(a<c) else c) if(a<b) else (b if(b<c) else c)
print('Minimum from a, b, c is:', minim)
# Alegere element maxim dintre a, b, c
maxim = a
if (maxim < b):
maxim = b
if (maxim < c):
maxim = c
print('Maximum from a, b, c is:', maxim)
maxim = a if (a > b) else b
maxim = maxim if (maxim > c) else c
print('Maximum from a, b, c is:', maxim)
maxim = a if (a > b) else (b if(b > c) else c)
print('Maximum from a, b, c is:', maxim)
if(a > b):
if(a > c):
maxim = a
else:
maxim = c
elif (b > c):
maxim = b
else:
maxim = c
print('Maximum from a, b, c is:', maxim)
maxim = (a if(a>c) else c) if(a>b) else (b if(b>c) else c)
print('Maximum from a, b, c iss:', maxim)
============== RESTART: /Users/ionivan/Documents/MinimIFsimplu.py ==============
First number:
7
Second number:2
Third number:5
Minimum from a, b, c is: 2
Minimum from a, b, c is: 2
Minimum from a, b, c is: 2
Minimum from a, b, c is: 2
Maximum from a, b, c is: 7
Maximum from a, b, c is: 7
Maximum from a, b, c is: 7
Maximum from a, b, c is: 7
Maximum from a, b, c iss: 7
(March 21, 2022)
Comments
Post a Comment