0

Can anyone help me with the logic behind this code?

def calc(x): p=4*x a=x*x return (p,a) side = int(input()) p, a = calc(side) print("Perimeter: " + str(p)) print("Area: " + str(a))

15th Sep 2021, 10:16 AM
Aniket Singh
Aniket Singh - avatar
3 Respuestas
0
What specifically don't you get? it defines a function that returns a tuple of two values. first is the x parameter times 4 and second is x squared. Then it prints the values
15th Sep 2021, 10:19 AM
Slick
Slick - avatar
0
So is side= x?
15th Sep 2021, 10:21 AM
Aniket Singh
Aniket Singh - avatar
0
No, x is a parameter in the function, it can be any number. 'side' is a specific number given from input. You just use it as an argument for the function so the value passes down.
15th Sep 2021, 10:28 AM
Slick
Slick - avatar