Write a program in Python to accept an integer and print its square and cube.
Answers
Answered by
0
Answer:
user = int(input("Enter a number"))
square = user * user
cube = user * user * user
print("Square is " + str(square))
print("Cube is " + str(cube))
Explanation:
Answered by
0
You can use the script written by the another student if you want to keep it simple.
But if you want to add a finish to it, use this =>
#importing a module to calculate that you need
import math
#creating a function to accept the number
#this step is actually for recursion
def accept_num():
#using the try-except clause to avoid errors
try:
num= int(input("Enter your number: "))
except:
print("Please enter an integer!!")
#recurring the function
accept_num()
#using the math module
square= math.pow(num, 2)
cube= math.pow(num, 3)
#Final print..!!
#using the f string method
print(f"\nThe square of {num} is {square}, and its cube is {cube}.")
#Plz mark as brainliest..
Similar questions