Skip to main content

Posts

Showing posts with the label Positional Arguments in Python

Standard Normal Distribution with examples using Python

Positional Arguments in Python

Positional Arguments in Python Positional Arguments in Python allow arguments to be passed to a function implicitly based on the order in which they appear in the function argument list. When you define a Python function, you expect some values or arguments to be passed to the function. Let's define a function to understand this better. def print_stats(name,age,type_batsman, avg_runs): print(f"Name of cricketer is {name}.") print(f"Age of {name} is {age} years.") print(f"{name} is {type_batsman} handed bastsman.") print(f"Career ODI Average for {name} is {avg_runs} runs.") In this function, name , age , type_batsman , avg_runs are called positional arguments . The function expects the order to be maintained when you pass in parameters to this function. Let's call this function to see this. print_stats("Sachin Tendulkar", 49, "right", 44.8) Name of cricketer is Sachin Te...