Try this optimization trick in python 🔥🐍#python

preview_player
Показать описание
#python
#pythontutorial #pythonforbegginers #pythontutorial #coding
Рекомендации по теме
Комментарии
Автор

Please review the "PROBLEMS" tab. It would be also good to learn about PEP8 & linters. In the video you actually address readability, not optimization. You used the "guard block" statements, which are powerful. Though the second check could be just "number > 60". And the third "if" could be removed completely since no other way we could get to the last return other than havin a proper value for the "C" grade.

Voronza
Автор

this isn't optimization it's simplification

bhbr-xbpo
Автор

You can also use the elif function instead of a nested if. The example here is obviously better but the elif function also has its own uses

Zevil
Автор

why do you use "x < A and x > B" and not "B < x < A"?

PeterZaitcev
Автор

May formatter hates this 'trick'

steff
visit shbcf.ru