CBSE Class 10 Computer Applications
Question 20 of 31
Python Revision — Question 8
Back to all questions 8
Question Question 8
Write a program to input a number n and print n, n2, n3.
Solution
n = int(input("Enter n: "))
n2, n3 = n ** 2, n ** 3
print("n =", n)
print("n^2 =", n2)
print("n^3 =", n3)Output
Enter n: 2
n = 2
n^2 = 4
n^3 = 8