How to Use Functions in Python in

Опубликовано: 12 Октябрь 2024
на канале: MCQ'S Factory
3
1

Welcome To Python Using Functions
A function is a block of code which only runs when it is called.

You can pass data, known as parameters, into a function.
In Python a function is defined using the def keyword:

Example
def my_function():
print("Hello from a function")

A function can return data as a result.

Calling a Function
To call a function, use the function name followed by parenthesis:

Example
def my_function():
print("Hello from a function")

my_function()

Arguments
Information can be passed into functions as arguments.

Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.