Learn Python • #9 Functions • Python's Most Important Concept?
HTML-код
- Опубликовано: 25 июн 2024
- Functions are a fundamental building block of programming in Python.
They allow you to package code into a named, reusable unit that can be called from other parts of your program. In this video, you'll learn how to define a function, pass in arguments, and return values.
This video is part of a beginner tutorial series for anyone who wants to learn Python from scratch, and get to a point where you can start coding your own projects.
🔗 Project Code (GitHub): github.com/pixegami/python-fo...
🔗 Full Playlist: • Python For Beginners (...
🔗 Next Chapter: Coming Tomorrow!
👉 Follow me on Twitter: @pixegami
📚 Chapters
00:00 - Introduction to Functions in Python
01:01 - Creating a Function
03:28 - Input Arguments
08:57 - Multiple Arguments
10:43 - Positional Arguments
11:40 - Keyword Arguments
13:34 - Optional Arguments
15:46 - Common Mistakes With Functions
21:03 - What is "Abstraction"?
23:42 - Coding Exercise: Functions
def interest_cal (principle, rate, years):
amount= principle * (1 + rate) ** years
return amount
print(interest_cal (2000, 0.15, 5))... did this and it worked lol ... how do i make this into an android app
def apply_discount (price, discount):
disc = price * discount
return disc
def new_price (price, discount):
amount_paid = price - (price * discount)
return amount_paid
print(apply_discount(1000, 0.1))
print(new_price(1000, 0.1))
100.0
900.0