Command Palette

Search for a command to run...

Hectal
Phase 5: Functions
Python · Exercise 1 of 6Next
Beginner

Write a greeting function

Write a function greet(name, greeting="Hello") that returns text like Hello, Asha!: the greeting, a comma and a space, the name, and an exclamation mark.

It must return the text, not print it. Replace the pass line with your code. The last line of the starter already prints greet("Asha"), so leave it as it is.

What Check tests

  1. greet("Asha") returns Hello, Asha!
  2. greet("Ravi", "Hi") returns Hi, Ravi!
  3. A keyword call works
  4. Keywords work in any order, and the default is not changed
  5. It returns a string and does not just print
  6. The program prints Hello, Asha!

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.