Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Building Functions | What Is a Function in Python?
Python Functions Tutorial

Challenge: Building Functions

Write a function that outputs your name just as the example function outputs my name.

1234567
# Define the function `say_my_name` def say_my_name(): # The function prints the string `My name is Heisenberg` print('My name is Heisenberg') # Call the function `say_my_name` say_my_name()

The say_my_name function prints the phrase 'My name is Heisenberg' to the screen. You can call this function to display the output.

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 2
single

single

Challenge: Building Functions

Swipe to show menu

Write a function that outputs your name just as the example function outputs my name.

1234567
# Define the function `say_my_name` def say_my_name(): # The function prints the string `My name is Heisenberg` print('My name is Heisenberg') # Call the function `say_my_name` say_my_name()

The say_my_name function prints the phrase 'My name is Heisenberg' to the screen. You can call this function to display the output.

Task

Swipe to start coding

Write a function that prints your name in the console.

  1. Define a function named print_name.
  2. Inside the function, use print() to output a string with your name in the format: My name is {your name}, where {your name} is replaced with your actual name.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 2
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt