Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Format a String

Combine text and values into a single formatted string using Python strings.

Python practice10 minVariables & Data TypesBeginnerLast updated December 29, 2025

Problem statement

Implement format_greeting(name, age) that returns a greeting sentence exactly in this format: Hello, {name}! You are {age} years old. The function should convert the age to text if necessary and insert the provided name and age into the template. Do not print; return the formatted string.

Task

Practice converting values to strings and using string formatting to produce a readable message.

Examples

Basic example

Input

format_greeting('Alice', 30)

Output

Hello, Alice! You are 30 years old.

Name and numeric age are inserted into the template.

Input format

Two arguments: name (string) and age (any value convertible to string).

Output format

A single string matching the greeting template exactly.

Constraints

Return a string. Preserve the input values as-is when converting (no rounding unless Python's default str() does it).

Samples

Sample 1

Input

format_greeting('Bob', '25')

Output

Hello, Bob! You are 25 years old.

Age provided as a string is placed into the template unchanged.