This program takes two integers, b and p, as input from the user. It then calculates the result of b raised to the power of p using the pow() function in Python, which returns the value of b raised to the power of p.
The result of the calculation is then converted to a string using the str() function, and the digits of the resulting number are extracted using a list comprehension. The list comprehension converts each digit in the string to an integer and adds it to a list.
Finally, the sum() function is used to add up all the integers in the list, which gives the sum of the digits of the result of b raised to the power of p.
For example, if the user inputs b=5 and p=3, the program calculates 5^3, which is 125. The digits of 125 are 1, 2, and 5, so the program prints the sum of these digits, which is 8.
b = int(input("Enter the Base Number :")) p = int(input("Enter the Power Number :")) print(sum([int(i) for i in str(pow(b, p))]))
Enter the Base Number :5 Enter the Power Number :12 28
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions