Python: getting started

Lesson 03 · 11 min

Functions, return, modules

def isn't a type. return gives back a value. No return — you get None. An import is like a file next to yours.

11 minLesson 3 of 8Practice includedAsk AI on any point

def greet(name): starts a function. The body is indented. return f"hi, {name}" gives back a string. Without a return the call returns None — a common hole when you expected a string and got "silence". Arguments work like in JS, but without function, and always with parentheses when calling: greet("Ada").

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.