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))
3 Answers
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
0
So is side= x?
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.