Header Ads

Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a In Python

Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a.
Suppose the following input is supplied to the program:
Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a In Python9
Then, the output should be:
11106
Hints:
In case of input data being supplied to the question, it should be assumed to be a console input.
Solution:
a = raw_input()
n1 = int( "%s" % a )
n2 = int( "%s%s" % (a,a) )
n3 = int( "%s%s%s" % (a,a,a) )
n4 = int( "%s%s%s%s" % (a,a,a,a) )

print n1+n2+n3+n4
Powered by Blogger.