Print square and cube of a number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Print square and cube of a number

13th Sep 2018, 11:16 AM
Sushma Chowdary
Sushma Chowdary - avatar
2 Answers
+ 2
x=2 print(x**2) # for square of number #output=4 print(x**3) #for cube of number. #output=8
13th Sep 2018, 4:22 PM
Maninder $ingh
Maninder $ingh - avatar
0
import math n = int(input()) print(str(n) + "^2 = " + str(n*n)) print(str(math.sqrt(n)) + " * " + str(math.sqrt(n)) + " = " + str(n))
13th Sep 2018, 11:36 AM
Anton Böhler
Anton Böhler - avatar