Exercise: Personalized Greeting
Leer en Español | Solve Online
Background/Motivation
Interacting with users often involves formatting strings to include personal information. Python's f-strings provide a powerful and readable way to perform string interpolation. In this exercise, you'll practice using f-strings with multiple variables.
The Task
Write a function personalized_greeting(name, age) that takes a name (string) and an age (integer) and returns a greeting string in the format: "Hello {name}, you are {age} years old".
Specifications
- Function Name:
personalized_greeting - Arguments:
name(str): The person's name.age(int): The person's age.
- Return Value:
str: The formatted greeting.
Constraints
namewill be a non-empty string.agewill be a positive integer.
Example
Instructions
- Open
exercises/personalized_greeting/solution.py. - Implement the function.
- Change
SUBMIT = FalsetoSUBMIT = Truewhen ready. - Run
python solution.pyto verify with built-in self-tests.