Function
Defining a function:
def greeting():
name = "Pranab Das"
print("Good morning " + name)
Later calling the function to print the greeting:
- Input
- Output
greeting()
Good morning Pranab Das
Function with argument:
- Input
- Output
def greeting_new(name):
print("Good morning", name)
greeting_new("Pranab")
Good morning Pranab
Some mathematical operations:
- Input
- Output
def add_two_numbers(input_1, input_2):
result = input_1 + input_2
return result
add_two_numbers(23, 43)
66
Get arbitrary number of input in a function:
- Input
- Output
def get_biggest_number(*args):
return max(args)
get_biggest_number(2, 4, 1, 8)
8