Python Python Basics Functions and Looping Create a Function

Brian Steyer
Brian Steyer
6,527 Points

Where can i find an example of how to assign a specific variable to square the integer in this function? Thanks!

Are there more reference points where I can look to ensure the formatting and syntax of my code are on target? Thanks!

Brian

squaring.py
def square(number):
    number = (number**)

2 Answers

Antonio De Rose
Antonio De Rose
19,227 Points
def square(number):
    number = (number**)

# 3 errors
# 1, you've been asked to return, so dont assign to number, use return
# 2, syntax error, take off the parenthesis, surrounded by the number**
# 3, square is write like, square**2 or simply square * square
Philip Schultz
Philip Schultz
10,107 Points

Hey, You actually don't have to worry about assigning the value to a variable within the function, just return it. For task 1 of 2 it wants you to simply make a function that accepts a number and return the number squared. Like so,

def square(number):
    return number**2

For task 2 of 2, it wants you to call the function, give it an argument of 3, then store the result in a variable called result.

result = square(3)