vendredi 20 novembre 2020

My if Statements are not working in Python

Below is the code please tell me why does it does not print the comments I have written in the if statements. Code -

    name = input("Hi! What is your name?")
    print("Hi" + name + 'Do you want to calculate the percentage of your marks in your exam?')
    var_1 = input('How many marks did you get?')
    var_3 = float(var_1)
    var_2 = input('Out of how many?')
    var_4 = float(var_2)
    percentage = var_3 * 100 / var_4
    print("you got " + str(percentage) + "%")
    if percentage <= 20.0:
    print("Your percentage is very low and you failed you must study a lot to buck up")
    if percentage <= 40.0 and percentage > 20.0:
        print('you almost failed you must study if you want to live a decent life')
        if percentage <= 60.0 and percentage > 40.0:
            print('you passed with decent marks this shows that you studied a bit if you work even harder and try you can get better marks next time.')
            if percentage <= 80.0 and percentage > 60.0:
                print('you passed with good marks well done but not too good you still have to work harder')
                if percentage <= 90.0 and percentage > 80.0:
                    print('very well done you must have worked hard just a little work a you will be a excellent student')
                    if percentage <= 100.0 and percentage > 90.0:
                        print('why are you worrying dont waste time on this pc go and throw a party')
                        if percentage == 100.0:
                            print("You are as smart as ramanujan hope you didn't cheat")

Aucun commentaire:

Enregistrer un commentaire