Previous Lecture Complete and continue  

  Square a Number

Notes to Help You

  • Functions start with def
  • Don't forget your colons
  • Always return in functions rather than print!

Example Problem.
Write a function add_two that takes in two numbers as input and returns their sum.

10 comments
Adex Elizy
https://repl.it/FBEz/5
it's not printing your code is correct
ANURAG SHARMA
because you haven't called the test_square_number function
Phuc Le
def square_number(number):
squared=number*number
return squared
Zsolt Bisztray
https://repl.it/FBEz/2
ashish dagar
def square_number(number):
return number**2

print(square_number(number))
Sebastian Gomez
https://repl.it/FBEz/1
Thomas Liebig
def square_number(a):
return a * a
Tao Burga
huhhhh I've been trying for about an hour and when i gave up and saw the solution it was just as i had done it its just nothing would happen. i kept getting this:
IndentationError: unindent does not match any outer indentation level on line 25 test_square_number() ^ in main.py
heres my link in case you want to check it out: https://trinket.io/python/0c71971445
Tara Fahey
Six days late but eh. Your code wasn't wrong, per say, the only problem was that the last line ( the line that tests your code) had a single space throwing off the entire program. Simply get rid of that space and it'll work.

riya
def square(number):
return number*number
print (square(2))

for i in range(12):
print(square(i))