Top 30 Python Functions You Need To Know | Python Tutorials | Most Used Python Functions Ep. 30
ฝัง
- เผยแพร่เมื่อ 23 ก.ค. 2024
- Whether you are using Python for backend development, AI, data science, or machine learning, understanding these functions is crucial for writing efficient and concise Python code.
Dive into the world of essential Python functions with our comprehensive guide on the top 30 functions you need to know!
Python builtin Functions: docs.python.org/3/library/fun...
🚀 Explore the core functions that every Python developer should master!
🔍 What's covered in this video:
1️⃣ any(): Checks if at least one element in an iterable is true.
2️⃣ all(): Verifies if all elements in an iterable are true.
3️⃣ enumerate(): Adds a counter to an iterable and returns it.
4️⃣ zip(): Combines multiple iterables element-wise.
5️⃣ abs(): Returns the absolute value of a number.
6️⃣ bool(): Converts a value to a Boolean.
7️⃣ next(): Retrieves the next item from an iterator.
8️⃣ iter(): Returns an iterator object.
9️⃣ globals(): Returns a dictionary representing the current global symbol table.
🔟 locals(): Updates and returns a dictionary representing the current local symbol table.
1️⃣1️⃣ sorted(): Returns a sorted list from the specified iterable.
1️⃣2️⃣ reversed(): Reverses the elements of a sequence.
1️⃣3️⃣ map(): Applies a function to all items in an input list.
1️⃣4️⃣ filter(): Constructs an iterator from elements of an iterable for which a function returns true.
1️⃣5️⃣ open(): Opens a file and returns a file object.
1️⃣6️⃣ super(): Returns a temporary object of the superclass.
1️⃣7️⃣ classmethod(): Returns a class method for a function.
1️⃣8️⃣ staticmethod(): Returns a static method for a function.
1️⃣9️⃣ callable(): Checks if the object appears callable.
2️⃣0️⃣ range(): Generates a sequence of numbers within a specified range.
2️⃣1️⃣ len(): Returns the number of items in an object.
2️⃣2️⃣ sum(): Returns the sum of all items in an iterable.
2️⃣3️⃣ min()/max(): Returns the minimum/maximum value in an iterable.
2️⃣4️⃣ getattr() / hasattr() / setattr(): Gets, checks existence, and sets attribute values of an object.
2️⃣5️⃣ isinstance(): Checks if an object is an instance of a specified type.
2️⃣6️⃣ issubclass(): Checks if a class is a subclass of a specified class.
2️⃣7️⃣ id(): Returns the identity of an object.
2️⃣8️⃣ round(): Rounds a number to the nearest integer or to the specified number of decimals.
2️⃣9️⃣ property(): Gets, sets, or deletes a property of an object.
3️⃣0️⃣ frozenset(): Returns an immutable frozenset.
👉 Timestamps:
0:00 Intro
0:19 enumerate()
1:44 zip() function
2:46 all()
3:25 any()
4:39 abs()
6:10 bool()
6:56 Iter() and next()
10:12 globals()
10:45 locals()
11:05 sorted()
11:46 reversed()
12:29 map()
13:11 filter()
14:00 open()
16:15 super()
18:14 classmethod()
19:13 staticmethod()
19:37 callable()
21:01 range()
22:38 len()
22:57 sum()
23:39 min() and max()
24:05 getattr() / hasattr()/ setattr()
25:57 isinstance()
26:52 issubclass()
27:33 id()
28:22 fronzenset()
29:07 round()
30:33 property()
🔗 Code Snippets:
Python Series: github.com/ridwanray/Learn-Py...
This lesson: github.com/ridwanray/Learn-Py...
⭐ Please LIKE and SUBSCRIBE for more educational content! ⭐
🌐 Connect with us:
Website: ridwanray.com
LinkedIn: github.com/ridwanray
Github: github.com/ridwanray
Medium: ridwanray.medium.com
#python #pythontutorial #pythonfunctions - วิทยาศาสตร์และเทคโนโลยี
Support Me and The Channel:
Don't forget to Like, Comment, and Subscribe.
► Recommended Books 📜
Books: ridwanray.com/books
- Python Crash Course: amzn.to/3vLYnP9
- Python Tricks: amzn.to/48KvSA2
- Automate the boring stuff : amzn.to/3SqJzhH
- Clean Code: amzn.to/3vG5Te9
- Clean Architecture: amzn.to/3vHu9wC
► Setups 💻
Camera: Sony ZV-E10 amzn.to/4257Vkn
Monitor: Sceptre 30-inch Curved Gaming amzn.to/491KeeP
Monitor: Dell UltraSharp U2719D amzn.to/3OdA7LY
Mic: Shure MV7 amzn.to/4b8i2J2
🌐 Connect:
Website: ridwanray.com
LinkedIn: linkedin.com/in/ridwanray
Github: github.com/ridwanray
Articles:
ridwanray.com/blog
Consider subscribing for more educational content.
Well explained and detailed
Great Content!
Glad you enjoyed it
Thank you. You just helped me replace my nested for loops in my project 😆
I'm glad you find it helpful. Kindly consider subscribing and sharing so that we can reach a wider audience. Thanks
Very detailed. Thanks for sharing. ❤
I'm glad you enjoyed it.
Thank you
You are welcome.
good work
I'm glad you liked it.
Thanks.
I have a question...
Concerning the @property
In a case where i need to populate the full name in the serializer for my Django project, i did source="user.fullname". It worked fine as a related field.
Here comes my blocker:
I decided to use full name to be part of filter fields.. i did "user__fullname" . I was getting error. I know the full name was a dynamic function annotated wjrb the @property and not really part of the user model fields.
How do i find my way out of this ?
The filtering won't work with what you decorate with at property because
1.it's a computed readonly attribute
2. It's not part of the model field as specified in the error.
Different ways to go about it depending on the requirements.
Create a custom method for fullname Filtering. It takes the fullname and use annotation to filter against queries retrieved.
@@ridwanray Thanks chief
You're welcome.