FAQ: Introduction to Functions - What is a Function?

This community-built FAQ covers the “What is a Function?” exercise from the lesson “Introduction to Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science
Data Science

FAQs on the exercise What is a Function?

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I wonder why there’s “None” after all those.

1 Like

Don’t use print function, only use function sing_song(). Function print is in sing_song(), so you don’t need call it again.
I think function print in You’r example, is try to find argument’s or conditions for both sing_song(), and print can’t find it.

I’m only beginer, if i’m wrong, please correct me.

1 Like

Why does this exercise have print(sing_song) typed out in it already, if we’re not supposed to use print()? Is that a glitch in the exercise?

The instruction does not say, call print(sing_song()) , it says call(sing_song())

can I just insert a variable inside of the function like this:

def welcome_song():
song=""“Welcome to Engrossing Grocer’s.
Our special is mandarin oranges.
Have fun shopping!”""
print(song)

welcome_song()

I don’t see anything wrong with this:
def sing_song():
print(“You may say I’m a dreamer”)
print(“But I’m not the only one”)
print(“I hope some day you’ll join us”)
print(“And the world will be as one”)

call sing_song() below:

print(sing_song()),print(sing_song())

Here’s the output:

You may say I’m a dreamer
But I’m not the only one
I hope some day you’ll join us
And the world will be as one
None
You may say I’m a dreamer
But I’m not the only one
I hope some day you’ll join us
And the world will be as one
None

I figured it out. Don’t call print as it is already in the function.

I think it should be listed as below

print(sing_song())

this line of code means the sing_song() function will be called out every time you are trying to call it out.

"print" function is actually a “functional” button to the command. To run the function, we have to use the button to call it out.

so “print(sing_song())” is good enough for the question.

for me it says call sing_song() below

Earlier we learnt that we can also declare a variable and use triple quotes at start and end to print multi-line of strings.
What is the difference between using the multi-line of strings by using triple quotes and function?

The code below returns no errors or unwanted output. You simply have to make sure you’re calling sing_song() outside of the function which you can do by making sure sing_song() is NOT indented or has any spaces then right below it calling it again.

def sing_song():
  print("You may say I'm a dreamer")
  print("But I'm not the only one")
  print("I hope some day you'll join us")
  print("And the world will be as one")
  
# call sing_song() below:
sing_song() 
sing_song()

In this exercise, script.py introduced def without any explanation to its purpose. The introductory paragraph explains how to call a function but it did not got into details on how to create a function.

def sing_song():
print(“You may say I’m a dreamer”)
print(“But I’m not the only one”)
print(“I hope some day you’ll join us”)
print(“And the world will be as one”)

Is this keyword that we must always use with a function? Thank you.

Looks like this is explained in the next page Sorry!