Day 7: Python Syntax: Basic Concepts — Functions and Parameters.

Day 7: Python Syntax: Basic Concepts — Functions and Parameters.

Python in 30 Days: A Practical and Theoretical Approach for Beginner.

Screen Shot 2025 07 15 at 6.52.24 PM Simply Creative Minds

Functions in Python

A function is a block of reusable code that performs a specific task.

We can define a function using the def keyword.

def function_name(parameters):
    # Code to be executed
    return result  # Optional
def greet(name):
    print(f"Hello, {name}!")

greet("Tom")  # Output: Hello, Tom!

In this example:

  • def is used to define the function greet.
  • name is the parameter of the function.
  • greet("Tom") is calling the function and passing an argument ("Tom").

Parameters and Arguments

  • Parameters: These are the placeholders we define in your function. They are like variables that are used to accept values.
  • Arguments: These are the actual values you provide when calling the function. They match the order of the parameters.

Example with multiple parameters

def introduce(name, age):
    print(f"Hello, my name is {name} and I am {age} years old.")

introduce("Tom", 25)  # Output: Hello, my name is Tom and I am 25 years old.

Happy Coding and Stay Tuned 🙂

Kind is always cool !!!

Share knowledge to gain knowledge !!!!

Be kind and treat people with respect !!!

If you find my blog helpful, then please subscribe, claps and follow to support 🙂

image 35 Simply Creative Minds

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *