CBSE Class 9 Computer Applications
Question 21 of 23
Introducing Python — Question 14
Back to all questions 14
Question Question 12
Write a program to read a number n and print n2, n3 and n4.
Solution
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