Computer Science, asked by shrinivaspatil125, 4 months ago

Write a program to input a three digit number. Display its digits raised to the power of their
respective position.
Sample Input: 465
Sample Output: 5^1 = 5
6^2=36
4^3=64

Answers

Answered by surajnegi0600
0

Answer:

Here is a simple Python program that takes in a three-digit number and displays its digits raised to the power of their respective position:

num = int(input("Enter a three-digit number: "))

num = str(num)

for i in range(len(num)):

   digit = int(num[i])

   power = i+1

   print(digit, "^", power, "=", digit**power)

Explanation:

In this program, the input function is used to take in the three-digit number as an integer. The input number is then converted to a string so that we can access each digit individually. Then the for loop is used to iterate through the individual digits of the number. The variable i is used to keep track of the position of the digit in the number. The power of the digit is calculated by adding 1 to the position variable i. The program then uses the print function to display the digit, the symbol "^" , power and the result of the operation digit**power.

More questions and answers

https://brainly.in/question/38819390

https://brainly.in/question/38819298

#SPJ1

Answered by yashsehara720
1

Answer:

please give me my answer

Similar questions