Exercize to understand from three numbers which is more high

Bob Gailer bgailer at gmail.com
Fri Jan 25 08:30:17 EST 2019


On Jan 25, 2019 7:00 AM, "^Bart" <gabriele1NOSPAM at hotmail.com> wrote:
>
> number1 = int( input("Insert the first number: "))
>
> number2 = int( input("Insert the second number: "))
>
> number3 = int( input("Insert the third number: "))
>
> if number1 > number2 and number1 > number3:
>     print("Max number is: ",number1)
>
> if number2 > number1 and number2 > number3:
>     print("Max number is: ",number2)
>
> else:
>         print("Max number is: ",number3)
>
> Try to insert numbers 3, 2 and 1 and the result will be number 3 and 1,
can you help me to fix it?! :\

Suggestion:

Pretend that you are the computer.
Mentally execute each statement, providing input as required, and write
down the results.
Something like:
Statement   Input   Result
1                    3         number1 = 3
2                    2         number2 = 2
3                    1         number3 = 1
4                              Max number is  3
5                              False
6                              Max number is  1
Do not guess or assume anything. Just do exactly what each statement says.

As an alternative use some kind of debugger that will let you step through
the program statement by statement. Most interactive development
environments such as IDLE let you do this.

You might as well learn to do this now as you will be needing it more and
more as you go on.

Personally I would not have given any answer to the problem until you had
an opportunity to research it more thoroughly. We don't learn by being
given answers.

Also in the future use  tutor at python.org  as that's the proper place for
this kind of question.

Bob Gailer



More information about the Python-list mailing list