Python Programming: Lesson 46 - Tuple Unpacking, The Ternary Operator, and Else Blocks in Exception
PLEASE SUBSCRIBE!!!
In the previous lesson (https://youtu.be/f1lTzFauG8I), we wrapped up our investigation of regular expressions by considering named groups and non-capture groups. In this final tutorial, we will take a look at several new topics, all of which are fairly straightforward: tuple unpacking, the ternary operator, and else blocks in exceptions. Hopefully you enjoyed exploring Python fundamentals, whether you needed a refresher for a better grade or whether you just wanted to learn for the first time as a hobby.
Tuple unpacking is when we use commas to assign multiple variables to the elements of a tuple
a, b, c = 10 , 15, 12 # assigns a to 10, b to 15, and c to 12 at the same time
The ternary operator allows us to compress an if/else statement into one line if we're doing something simple like assigning a variable.
q = 5 if False else 9
print( q ) # 9
The else block in a try/except/finally block allows us to execute code if and only if the try block was completely successful (runs if and only if none of the except blocks run). In this case, we'd run all of the try code, then all of the else code, then all of the finally code. Put the else block in between the except blocks and the finally block, far underneath the try block.
0:50 Review of Keywords Arguments
4:39 NEW: Tuple Unpacking
6:34 NEW: Ternary Operator
9:15 NEW: Else in Exceptions
Have more ideas for videos? Feel free to reach out to be my direct message, or you can leave comments below this video or any other.
Well I didn't think that there would be a next video, but you can keep going and learn about the walrus operator here: https://youtu.be/GiimhyjZ6DQ
Thanks for watching, and PLEASE SUBSCRIBE!!!
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Python Programming: Lesson 46 - Tuple Unpacking, The Ternary Operator, and Else Blocks in Exception», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.