0
Find bigges number in 3 numbers using conditional control statements
Any changes in my code https://code.sololearn.com/cqsC4iCzfMT4/?ref=app
5 Respostas
+ 6
you can find here an other example to calculate this (source: geegsforgeegs):
# Python program to find the largest
# number among the three numbers
def maximum(a, b, c):
if (a >= b) and (a >= c):
largest = a
elif (b >= a) and (b >= c):
largest = b
else:
largest = c
return largest
# Driven code
a = 200
b = 40
c = 30
print(maximum(a, b, c))
+ 3
Your program is definitely not accurate, for example, try entering 9 6 13, and your program says that 9 is big.
What you need to do is to nest conditional statements, otherwise, their are also other smart ways to do that. However, this will do as a proof of concept.
https://code.sololearn.com/cE5VgWBc9BTY/?ref=app
+ 2
This was the smart solution I meant by. It is particularly helpful if you do not want to preserve the values or by implementing functions.
https://code.sololearn.com/c3QCxXADpoj4/?ref=app
+ 2
#create empty list
list = []
#for-loop to add elements from input to the list. range(3) will have you input 3 values, change it if necessary
for i in range(3):
element = int(input())
list.append(element)
#print the max value from the list and unpack it with the *
print(max(*list))
+ 1
Modified right