%d %d in the last line gives an error because of the % in the middle. It's one of the arithmetic operators, and it seems to have an error because you couldn't read it as an arithmetic operator and then called % (real variable). How can I stay in this format but work it out?
num1 = int("Enter the first digit":")) num2 = int("Enter the second digit":"))
print("%d + %d = %d" % (num1,num2,num1+num2)) print("%d - %d = %d" % (num1,num2,num1-num2)) print("%d * %d = %d" % (num1,num2,num1*num2)) print("%d / %d = %d" % (num1,num2,num1/num2)) print("%d % %d = %d" % (num1,num2,num1 %num2))
python modular-operator
%%
num1 = int(input="Enter the first number":"))
num2 = int("Enter the second digit":"))
print("%d + %d = %d" % (num1,num2,num1+num2))
print("%d - %d = %d" % (num1,num2,num1-num2))
print("%d * %d = %d" % (num1,num2,num1*num2))
print("%d / %d = %d" % (num1,num2,num1/num2))
print("%d %% %d = %d" % (num1,num2,num1 %num2))
© 2024 OneMinuteCode. All rights reserved.