1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jul 2013
Posts
3
Rep Power
0

#### Int to Str

Hi,
I have an input less than 99
I need a result that will show two digit output
eg 05 if input 5, 13 if input 13.
Because it is only starting course I cannot use if, only use arithmetic operations and greatest integer (//) and remainder (%).
I am very confused
2. Omitting the theory lesson about representation of numbers and that Intel processors are designed to be really good at finding remainders leaves us with only the solution. After viewing these answers I'm sure you'll agree that the program would be worse with an "if" statement. "if" could work though.
Code:
```# 3 solutions

for i in (5,27,):
print('\n'*2)

print('%d%d'%divmod(i,10), 'divmod')

ones = i % 10   # remainder after dividing by 10
tens = int(i/10) # works with both modern versions of python.  If you're feeling advanced look up the // operator.
print('{}{}'.format(tens,ones), 'explicit divmod')

print('{:0>2d}'.format(i), 'string formatting')```
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jul 2013
Posts
3
Rep Power
0
Thanks, but found this
Code:
`print( str(n//10)+str(n%10))`