dimanche 27 octobre 2019

Printing the functions with if statement

I have created an if statement function. And with this way I am supposed to print the largest number of the inputs (Please check my code). However, as there should not be any errors, or mistakes in the code itself, I still can not print out the largest_Number. Could you please help me with that?

I have tried writing the print() statement outside the function, then inside, also typing print(largest_Number) in every if lines, still nothing has been changed.

Number_1 = int(input("Please type your 1st number: "))
Number_2 = int(input("Please type your 2nd number: "))
Number_3 = int(input("Please type your 3rd number: "))
Number_4 = int(input("Please type your 4th number: "))
Number_5 = int(input("Please type your 5th number: "))
Number_6 = int(input("Please type your 6th number: "))

def largest(Number_1, Number_2, Number_3, Number_4, Number_5, Number_6):
    if (Number_1 >= Number_2) and (Number_1 >= Number_3) and (Number_1 >= Number_4) and (Number_1 >= Number_5) and (Number_1 >= Number_6):
        largest_Number == Number_1;
    else:
        if (Number_2 >= Number_1) and (Number_2 >= Number_3) and (Number_2 >= Number_4) and (Number_2 >= Number_5) and (Number_2 >= Number_6):
            largest_Number == Number_2
        else:
            if (Number_3 >= Number_1) and (Number_3 >= Number_2) and (Number_3 >= Number_4) and (Number_3 >= Number_5) and (Number_3 >= Number_6):
                largest_Number == Number_3
            else:
                if (Number_4 >= Number_1) and (Number_4 >= Number_2) and (Number_4 >= Number_3) and (Number_4 >= Number_5) and (Number_4 >= Number_6):
                    largest_Number == Number_4
                else:
                    if (Number_5 >= Number_1) and (Number_5 >= Number_2) and (Number_5 >= Number_3) and (Number_5 >= Number_4) and (Number_5 >= Number_6):
                        largest_Number == Number_5
                    else:
                        if (Number_6 >= Number_1) and (Number_6 >= Number_2) and (Number_6 >= Number_3) and (Number_6 >= Number_4) and (Number_6 >= Number_5):
                            largest_Number == Number_6
                            print(largest_Number)

Aucun commentaire:

Enregistrer un commentaire