asked 82.0k views
1 vote
You can calculate the surface area of a cube if you know the length of an edge. Write a program that takes the length of an edge (an integer) as input and prints the cube’s surface area as output. An example of the program input and output is shown below: Enter the cube's edge: 4 The surface area is 96 square units. Grading When you have completed your program, click the Submit button to record your score.

asked
User Llanato
by
8.4k points

1 Answer

3 votes

Code in Python is below.

#For Math.pow()

import math

#Function

def calculateSurfaceArea(n):

#Take length and calculate the surface area with;

#Surface Area = 6 * (the length of edge)^2

return 6 * math.pow(n, 2)

#Main function

def Main():

#Get input from user.

edge = int(input("Enter the edge: "))

#Send it to our function.

print(f"Surface area: {calculateSurfaceArea(edge)} cm².")

#Declare the main.

if __name__ == "__main__":

Main()

You can calculate the surface area of a cube if you know the length of an edge. Write-example-1
answered
User Cricardol
by
8.3k points

No related questions found