Skip to main content
← CoursesPython FoundationsModule 2 · Data structuresWelcome functionwrite17 / 170
💬 Discuss🧪 Playground+75 XP
Task
📝 **Task:** Greeting function with two parameters. 📋 **Steps:** 1. Define `def greet(name, time_of_day):` 2. Use `if/elif/else` to check `time_of_day`: - "morning" → return `"Good morning, {name}!"` - "afternoon" → return `"Good afternoon, {name}!"` - "evening" → return `"Good evening, {name}!"` 3. Call `greet("Ivan", "morning")` and print it 💡 **Similar example (BMI):** ```python def bmi(weight, height): return round(weight / (height ** 2), 1) print(bmi(70, 1.75)) # 22.9 ``` ⚠️ **Hint:** use an f-string: `f"Good morning, {name}!"`. 🎯 **Expected output:** `Good morning, Ivan!`

Keep going

✏️ Write your code here
🐍
Loading Python...
First visit only — ~5-10s. Stays cached afterward.
📊 Result
Press Run to see result...
📣 Help someone learn PythonShare this lesson with a friend — the first 15 are free, no signup.Tweet

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…