Python BasicsIntro
Your First Function
~6 mincode completion
Write greet(name, age) that returns exactly this sentence:
Hi NAME, you are AGE years old.
So greet("Ada", 36) returns "Hi Ada, you are 36 years old."
Examples
- Input
- greet("Ada", 36)
- Output
- "Hi Ada, you are 36 years old."
A different name and age produce a different sentence
- Input
- greet("Grace", 45)
- Output
- "Hi Grace, you are 45 years old."
Hints
Hint 1
An f-string builds the result in one line. Put the values in braces.
Hint 2
A common slip here: printed instead of returned.
Requirements
name: a string, e.g. "Ada"age: a whole number, e.g. 36Return a string like "Hi Ada, you are 36 years old."
Constraints
Standard library only, no imports required
Time limit: 200 ms, Memory: 64 MB
Where this shows up
~6 min
••••••
3 employers weight this skill
2 frontier labs, 1 AI product company. Top match scores 80.
Python
def greet(name, age):
"""
Build a greeting sentence.
Args:
name: a string, e.g. "Ada"
age: a whole number, e.g. 36
Returns:
A string like "Hi Ada, you are 36 years old."
"""
# YOUR CODE HERE
pass