Skip to main content
🐍 Python Basics 🐍

Read Some Python πŸ‘€

Welcome to Python! 🐍 Don't worry β€” we'll go one tiny step at a time, and you can't break anything.

Coders read a lot of code before they write any. So let's read a little first.

Here is a tiny machine called a function. You give it a name, and when you call it, it hands something back with the word return:

def greet():
    return "Hi there!"
  • def is how you define (make) a function.
  • greet is its name.
  • return hands a value back to whoever called it.

When we call greet(), it hands back the words "Hi there!". The words in "quotes" are called a string β€” that's just coder-speak for text. 🧡

Read the code above, then answer below. πŸ‘‡

When we call greet(), what does it hand back?

Here is another function:

def pet():
    return "cat"

What does pet() hand back?

The word def is used to: