Challenge: Building Functions
Let's introduce ourselves. I've written a function that outputs my name, and your task is to write a function that outputs your 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 simply prints the phrase 'My name is Heisenberg'
to the screen, and we can call this function to see this output.
Swipe to start coding
Write a function that prints your name in the console.
- Define a function named
print_name
. - 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.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 4.35
Challenge: Building Functions
Sveip for å vise menyen
Let's introduce ourselves. I've written a function that outputs my name, and your task is to write a function that outputs your 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 simply prints the phrase 'My name is Heisenberg'
to the screen, and we can call this function to see this output.
Swipe to start coding
Write a function that prints your name in the console.
- Define a function named
print_name
. - 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.
Løsning
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 4.35single