0

Help pls i want a python program for this

ok simple, I want to display all numbers from 10 to 99 such that square of sum of their digits minus 18 is the same number example 32 should be equal to (3+2)**2-18=32 how do I code this in python, I tried but it shows no output. pls help

20th Sep 2018, 5:24 PM
Dhairyashil Deshpande
Dhairyashil Deshpande - avatar
13 ответов
+ 5
use '//' because 11/10 returns 1.1 but you need 1
20th Sep 2018, 6:53 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 4
Please show your code first
20th Sep 2018, 6:24 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 4
Dhairyashil Deshpande Missing simple things is part of the learning process ☝️ Do you still want an explanation of my code? Because it would take me two hours to write it
20th Sep 2018, 7:10 PM
Anna
Anna - avatar
+ 3
I agree with Mert Yazıcı, but this code is too beautiful not to share: https://code.sololearn.com/cK04aqvbAAcE/?ref=app
20th Sep 2018, 6:51 PM
Anna
Anna - avatar
20th Sep 2018, 7:31 PM
David Ashton
David Ashton - avatar
+ 2
I have no experience with Python but I think this should help for i in range (10, 99): firstDigit = i // 10; secondDigit = i% 10; if ((firstDigit + secondDigit)**2 - 18 == i): print(i) I hope i didn't mess anything up xd
20th Sep 2018, 6:24 PM
Shadowa
Shadowa - avatar
+ 2
Dhairyashil Deshpande if question is related to Python, why you have tagged c and c++ in question? please untag these two so that people don't get confused
20th Sep 2018, 7:04 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
no thanks, I figured it out
20th Sep 2018, 7:22 PM
Dhairyashil Deshpande
Dhairyashil Deshpande - avatar
+ 1
Anna could you explain your code,,, and if possible can you give a simple solution? many thanks
20th Sep 2018, 6:54 PM
Dhairyashil Deshpande
Dhairyashil Deshpande - avatar
+ 1
thank you Mert Yazici thanks a lot
20th Sep 2018, 6:56 PM
Dhairyashil Deshpande
Dhairyashil Deshpande - avatar
+ 1
it worked,,, I feel stupid for missing simple things damn
20th Sep 2018, 6:57 PM
Dhairyashil Deshpande
Dhairyashil Deshpande - avatar
0
ya I tried the same, but it shows no output
20th Sep 2018, 6:51 PM
Dhairyashil Deshpande
Dhairyashil Deshpande - avatar
0
for i in range (10,99): x=i%10 y=i/10 if i == ((x+y)**2-18): print(i) I tried this
20th Sep 2018, 6:52 PM
Dhairyashil Deshpande
Dhairyashil Deshpande - avatar