Pythondex

Exercise

Functions Exercise

In this exercise, you’ll create a function that takes a user's name, age, and favorite number, and prints a formatted greeting.

Task

Write a Python program that:

  • Defines a function greet_user that takes name, age, and fav_number as parameters
  • Prints a greeting like "Hello Alice! You are 20 years old and your favorite number is 7."
  • Calls the function with user input

Hints

  • Use the def keyword to define the function
  • Use input() to get user data
  • Use print() with formatted strings

Example Output

Solve