# [Tutor] Comparison code (was blank)

Alan Gauld alan.gauld at btinternet.com
Tue Sep 3 17:31:14 EDT 2019

```Please provide a subject line - it helps in the archive!
Also provide a question, don;t make us guess what you want
to know. It may be obvious to you but its bot to us and we
don't have time to examine it in minute detail just in case.

That said, here are some general comments below...

On 03/09/2019 15:38, super ball xy wrote:
>
> n1 = int (input())
> n2 = int (input())
> n3 = int (input())
> if n1 > n2 and n1 > n3:
>     print (n1,"es el mayor")
> if n2 > n1 and n2 > n3:
>     print (n2,"es el mayor")
> if n3 > n1 and n2 > n2:
>
I think the last one should be n3 > n2   ???

>     print (n3,"es el mayor")
> if n1 < n2 and n1 < n3:
>     print (n1,"es el menor")
> if n2 < n1 and n2 < n3:
>     print (n2,"es el menor")
> if n3 < n1 and n2 < n2:
>     print (n3,"es el menor")
>
You could have used the max and min functions to do the same job:

data = (n1,n2,n3)

print( "The biggest is: ", max(data) )

print("The smallest is:", min(data) )

> if n1>n2 and n1>n3:
>     n1 = a
>
I think you mean

a = n1

You can't assign a to n1 because a doesn't have a value yet!

> if n2>n1 and n2>n3:
>     n2 = a
> if n3>n1 and n3>n2:
>     n3 = a
> if n1<n2 and n1<n3:
>     n1 = b
> if n2<n1 and n2<n3:
>     n2 = b
> if n3<n1 and n3<n2:
>     n3 = b
>

Same for the above. But you could have done this in the
first set of comparisons. No need to go through them
all a second time.

> print ("la suma de" ,a, "+" ,b, "=" ,a+b,
> print ("la multiplicación de" ,a, "x" ,b, "=" ,a*b,
> print ("la potencia de" ,a, "sobre" ,b, "=" ,a**b,
>

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

```