filmov
tv
Top 5 Tips and Tricks to Write Better Python Code!
Показать описание
In this video I show you my top 5 tips and tricks that I consider unusual, or at least less common, python hacks that can lead to cleaner code written in simpler syntax and fewer total lines of code!!
*I know I use even divisible of three way too much when I should be saying multiple of three! It was late!*
If you love the content on the channel, consider becoming a Super Supporter! Check out the link to my Patreon below :)
There are a lot of scenarios where using these tips throughout a large program could greatly reduce the total processing time or number of lines of code required for your full project, so knowing a lot of these concepts will provide you a lot of use in your programming career!!
Tip 1 shows you how to use Python's Filter function to apply a filter condition to an entire list of data and get a new list out of that data!
Tip 2 shows how to use the unique ternary conditional to simplify if else statements that check against a Boolean operator
Tip 3 discusses how to use python sets to sort and pull unique values out of a list of numbers
Tip 4 shows a few handy hacks for formatting large numbers in your project so they're easier to read, as well as formatting string outputs to have commas in your numbers!
Tip 5 is a quick overview of how to write simple functions using the lambda statement instead of using def
All these tips come with the caveat that of course there are times where you would not want to use them and they could even complicate or slow down a project! But knowing these concepts and looking for opportunities to apply them is a great growth step in your journey as a python programmer!
Let me know what tips I missed in the comments below!!
TIMESTAMPS:
00:00 Intro
00:31 Apply Python's Filter Function to a List
02:26 Ternary Conditionals For Boolean If Else's
04:43 Unique Sorted Values Using Sets
07:17 Add Underscore Spacers and Formatted Numerical Outputs
09:56 Lambda Instead of Def for Defining Simple Functions
*I know I use even divisible of three way too much when I should be saying multiple of three! It was late!*
If you love the content on the channel, consider becoming a Super Supporter! Check out the link to my Patreon below :)
There are a lot of scenarios where using these tips throughout a large program could greatly reduce the total processing time or number of lines of code required for your full project, so knowing a lot of these concepts will provide you a lot of use in your programming career!!
Tip 1 shows you how to use Python's Filter function to apply a filter condition to an entire list of data and get a new list out of that data!
Tip 2 shows how to use the unique ternary conditional to simplify if else statements that check against a Boolean operator
Tip 3 discusses how to use python sets to sort and pull unique values out of a list of numbers
Tip 4 shows a few handy hacks for formatting large numbers in your project so they're easier to read, as well as formatting string outputs to have commas in your numbers!
Tip 5 is a quick overview of how to write simple functions using the lambda statement instead of using def
All these tips come with the caveat that of course there are times where you would not want to use them and they could even complicate or slow down a project! But knowing these concepts and looking for opportunities to apply them is a great growth step in your journey as a python programmer!
Let me know what tips I missed in the comments below!!
TIMESTAMPS:
00:00 Intro
00:31 Apply Python's Filter Function to a List
02:26 Ternary Conditionals For Boolean If Else's
04:43 Unique Sorted Values Using Sets
07:17 Add Underscore Spacers and Formatted Numerical Outputs
09:56 Lambda Instead of Def for Defining Simple Functions
Комментарии