Type annotation on function parameters
📖 Scenario: You are building a simple calculator function that adds two numbers. To make your code clear and safe, you want to specify the types of the inputs.
🎯 Goal: Create a function called add that takes two numbers as parameters and returns their sum. Use type annotations on the function parameters.
📋 What You'll Learn
Create a function named
addAdd type annotations to both parameters to specify they are numbers
Return the sum of the two parameters
💡 Why This Matters
🌍 Real World
Type annotations help catch mistakes early and make your code easier to understand, especially when working with others.
💼 Career
Many programming jobs require writing clear, typed code to reduce bugs and improve maintainability.
Progress0 / 4 steps