def square_number(n):
return n * n
print(square_number(5))
print(square_number(10))
#source code --> clcoding.com
Code Explanation:
Define the Function:
def square_number(n): → This defines a function named square_number that takes a single parameter n.
Calculate the Square:
return n * n → This multiplies n by itself and returns the result.
Calling the Function:
square_number(5) → It passes 5 as an argument, which returns 5 * 5 = 25.
square_number(10) → It passes 10, which returns 10 * 10 = 100.
Example Output
25
100
0 Comments:
Post a Comment