At the end, the minimum value is -- not the maximum and minimum value true false How do you get the maximum value to be --?

Asked 2 years ago, Updated 2 years ago, 17 views

A = int (("Enter the first digit")

B = int (input ("Enter the second digit"))

C = int (input ("Enter the third digit"))

print("Maximum value is A", A>Band A>C)

print ("Maximum value is B," B>A and B>C)

print ("Maximum value is C," C>Band C>A)

print("Minimum value is A."), not(A>B or A>C))

print ("Minimum value is B."), not (B>A or B>C))

print("Minimum value is C."), not(C>B or C>A))

python

2022-09-20 17:04

1 Answers

There are many ways. The way that comes to mind right away is to use it as a conditional sentence, but I'll explain it a little bit because you don't seem to know.

if conditional expression:
    What to process
if a > b and a > c:
    print ('Maximum value is ', a, ')')
elif b > a and b > c:
    print ('Maximum value is ', b, ')')
elif c > a and c > b:
    print ('Maximum value is ', c, ')')

But if there are more variables in this way, you have to add more conditional sentences, so I don't use it like this.

print('max:', max(a, b, c))
print('min: ', min(a, b, c)))

So I think it'd be better to use this kind of chords. Python has this function, so look it up and use it~


2022-09-20 17:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.