CBSE Class 11 Informatics Practices Question 22 of 40

Practice Paper — Question 4

Back to all questions
4
Question

Question 22

Write a Python program to calculate and display the square and cube of an inputted number.

Solution
num = int(input("Enter a number"))
s = num ** 2
c = num ** 3
print("Square of", num, "is:", s)
print("Cube of", num, "is:", c)
Output
Enter a number4
Square of 4 is: 16
Cube of 4 is: 64
Answer