This is a Python Program to read a number n and compute n+nn+nnn.
The program takes a number n and computes n+nn+nnn.
Here is the source code of the Python Program to read a number n and compute n+nn+nnn. The program output is also shown below.
1 2 3 4 5 6 7 8 |
n=int(input("Enter a number n: ")) temp=str(n) t1=temp+temp t2=temp+temp+temp comp=n+int(t1)+int(t2) print("The value is:",comp) |
Program Explanation
1. User must first enter the value and store it in a variable n.
2. The integer is converted to string for concatenation of the value of n.
3. The string is then concatenated once and twice and stored in separate variables.
4. Later to find the total sum, the string is converted back to integer.
5. The total value of the expression is then printed.