Refactoring a Boolean Function in Python🐍 #shorts

preview_player
Показать описание
In this video, we look at refactoring a 4-line function that returns True or False based upon a condition, into a single line of code.

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:

#python #programming #pythonprogramming #compsci #datascience #statistics
Рекомендации по теме
Комментарии
Автор

tha was the easiest refactor of the galaxy

haroldpepete
Автор

Create a video on implementations same on pandas, but when on True condition, the func will give value/2 of another columns with np.where method giving error, I don't want to use for loop iteration. Want vectorised func.
Like:
a b
10 6
12 7
4 6
.now when
a >10 func will return b*2,
Else b.

Can we use switch statement for pandas.

pyalgoGPT
Автор

In stead of doing print(gt_10(7)) why can't we do print (number > 10)
Edit : by can't I mean shouldn't

RajveerSingh-vfpr
Автор

generally speaking your refactoring is not correct. According to official documentation "Custom rich comparison methods may return non-boolean values." ;)

ihorkovryhin
Автор

Hi, but if you have a list of number? how you will do to return everything?

Elian_Amselem
welcome to shbcf.ru