KnowledgeBoat Logo

Computer Science

Write a program to read a number n and print n2, n3 and n4.

Python

Python Funda

207 Likes

Answer

n = int(input("Enter n: "))
n2, n3, n4 = n ** 2, n ** 3, n ** 4
print("n =", n)
print("n^2 =", n2)
print("n^3 =", n3)
print("n^4 =", n4)

Output

Enter n: 2
n = 2
n^2 = 4
n^3 = 8
n^4 = 16

Answered By

106 Likes


Related Questions