print("This trick only works for range 10 to 199 included")
num1 = int(input("Enter 1st no.:"))
num2 = int(input("Enter 2nd no.:"))
max1 = max(num1, num2)
min1 = min(num1, num2 )
cond = (min1 > 9) and (max1 < 200)
def print2(res1, res2):
res3 = num1+num2-100
res4 = (num1-100) * (num2 -100)
print(f"""
Step 1 :
{num1} is {num1-100} greater than 100
And
{num2} is {num2-100} greater than 100
Hence,
The first 2 digits are 100+({num1-100})+({num2-100}) = {res3}
The last digits are {num1-100} * {num2 -100} = {res4}
Total {res1}{res2}
""")
def print1(res1, res2):
print(f"""
Step 1 :
{num1} is {num1-100} greater than 100
And
{num2} is {num2-100} greater than 100
Hence,
The first 3 digits are 100+({num1-100})+({num2-100}) = {res1}
The last 2 digits are {num1-100} * {num2 -100} = {res2}
Total {res1}{res2}
""")
def check_len(res1, res2):
if len(str(res2)) < 2:
res2 = str(0)+str(res2)
print1(res1, res2)
elif len(str(res2)) > 2:
res1 = res1 + int(str(res2)[:-2])
res2 = str(res2)[-2:]
print2(res1, res2)
def main(num1, num2):
res1 = num1 + num2 - 100
res2 = (num1-100)*(num2-100)
if cond:
if num1 == num2 == 100:
print(10000)
elif max1 < 100:
if len(str(res2)) == 2:
res2 = str(res2)[-2:]
print2(res1, res2)
else:
check_len(res1,res2)
elif min1 > 100:
if len(str(res2)) == 2:
print1(res1, res2)
else:
check_len(res1,res2)
else :
res1 = max1 - 100
res2 = min1 - 100
res3 = (min1 + res1) * 100
res4 = res1*res2
print(f"""
Step 1 : {max(num1, num2)} - {100} = {res1}
Step 2 : ({num2} + {res1}) + 00 = {res3}
Step 3 : {res1} x {res2} = {res4}
Total
{res3}+({res4}) = {res3+res4}
""")
else:
print("This trick won't work", num1, num2)
exit(0)
main(num1, num2)
Example 1: When the numbers are less than 100
This trick only works for range 10 to 199 included
Enter first number:56
Enter second number:67
Step 1 :
56 is -44 greater than 100
And
67 is -33 greater than 100
Hence,
The first 2 digits are 100+(-44)+(-33) = 23
The last digits are -44 * -33 = 1452
Total 3752
[Program finished]
Example 2: When greater than 100
This trick only works for range 10 to 199 included
Enter first number:110
Enter second number:120
Step 1 :
110 is 10 greater than 100
And
120 is 20 greater than 100
Hence,
The first 2 digits are 100+(10)+(20) = 130
The last digits are 10 * 20 = 200
Total 13200
[Program finished]
Example 3: One is smaller and one is greater than 100
This trick only works for range 10 to 199 included
Enter first number:126
Enter second number:98
Step 1 : 126 - 100 = 26
Step 2 : (98 + 26) + 00 = 12400
Step 3 : 26 x -2 = -52
Total
12400+(-52) = 12348
[Program finished]
We cannot change the output as kids might not understand technical jargon Although, I admit its not that well formatted. I tried my best. The purpose is for kids to check stepwise where they are wrong.