How do I make my code to make display values with a string on each output?

  Kiến thức lập trình

Hello I am a python fresher and I am looking for some extra help.

CODE SNIPPET:

def cube(side):
  volume =  side **3
  surface_area = 6 * (side**2)
  return volume, surface_area
my_cube = cube(5) 
print(my_cube)

#output is 125,150

in the code above, I want the output to include a statement like:

“The volume is 125, and The surface area is 150”

New contributor

DONALD ZIKO is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Use f-strings

def cube(side):
    volume =  side **3
    surface_area = 6 * (side**2)
    return volume, surface_area

my_cube = cube(5) 

print(f"The volume is {cube[0]}, and The surface area is {cube[1]}")

LEAVE A COMMENT