Logic in Python #1 | Using If-else to find the largest number

list = [234, 77855555, 18176]
list.sort()
print(list)
print('the largest number is : ', list[-1])

What’s the logic?

Okey, Suppose I have 3 variables a, b, and c.

When is variable b said to be the largest?

So the answer is that variable b will be said to be the largest if it is greater than the value of a and also greater than the value of c.

a, b, c = (234, 77855555, 18176 )
print('show value A : ', a)
print('show value B : ', b)
print('show value C : ', c)

if a > b and a > c:
print('the largest A value with the value : ', a)
elif b > a and b > c:
print('the largest B value with the value : ', b)
else:
print('the largest C value with the value ', c)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
NUR ARIF

NUR ARIF

30 Followers

Backend | Content Writer | Python Programming | I like to learn new things to get new experiences