Day 63 of #100DaysOfCode — Python Refresher Part 3 + Introduction to Apps in Django
Yesterday I introduced Django and covered some Python basics. Today I went deeper into Python, specifically functions and OOP, because I realized these are the real building blocks you need before ...

Source: DEV Community
Yesterday I introduced Django and covered some Python basics. Today I went deeper into Python, specifically functions and OOP, because I realized these are the real building blocks you need before Django starts making sense. I also took a first look at how Django organizes code into apps. Functions in Python A function in Python is defined using the def keyword. def greet(name): return f"Hello, {name}!" print(greet("Haris")) # Hello, Haris! Simple enough. But Python functions have some powerful features worth knowing. Default Arguments You can assign a default value to parameters, making them optional when calling the function. def greet(name, greeting="Hello"): return f"{greeting}, {name}!" print(greet("Haris")) # Hello, Haris! print(greet("Haris", "Hey")) # Hey, Haris! *args: Variable Positional Arguments When you don't know how many arguments will be passed, use *args. It collects all extra positional arguments into a tuple. def add_all(*args): return sum(args) print(add_all(1, 2, 3