mardi 26 avril 2016

ELIF statements

I have done the program, but I keep getting an invalid syntax at the close of main and cannot figure out what I am doing wrong. I am trying to get the elif to get the multiple of the larger number, and to indicate how many times the smaller integer divides into the larger. Also, on my else statement, the smaller integer is not a multiple of the larger one, the program would show the whole number quotient and remainder when the larger is divided by the smaller integer. Code below:

def main():
    num1 = int(input('Enter any numbers greater than 2:'))
    num2 = int(input('Enter any number less than num1:'))
    if num2 >= num1:
        print("Bad_Input.Try_Again")
    elif num1 % num2 == 0:
        quotient = num1 / num2
        print(quotient)
    else:
        print(num1 / num2)
        print(num1 % num2)
        print(num1,'divides by',num2,'=','and remainder',divmod(num1 / num2)

main()

Can anyone tell me why I keep getting an Invalid syntax error when trying to execute the program.

Aucun commentaire:

Enregistrer un commentaire