-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathEX4.8.py
41 lines (37 loc) · 771 Bytes
/
EX4.8.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# (Sort three integers) Write a program that prompts the user to enter three integers
# and displays them in increasing order.
import math
a, b, c = eval(input("Enter a, b, c: "))
A, B, C = False, False, False
s = ""
if a <= b and a <= c:
s += str(a) + ", "
if b < c:
s += str(b) + ", "
C = True
else:
s += str(c) + ", "
B = True
elif b <= a and b <= c:
s += str(b) + ", "
if a < c:
s += str(a) + ", "
C = True
else:
s += str(c) + ", "
A = True
elif c <= a and c <= b:
s += str(c) + ", "
if b < a:
s += str(b) + ", "
A = True
else:
s += str(a) + ", "
B = True
if A:
s += str(a)
if B:
s += str(b)
if C:
s += str(c)
print(s)