RUVIDEO
Поделитесь видео 🙏

Python: Chapter 4 Conditional Statements(if else, if elif, multiple elifs)

Chapter 4: If statements

If statement allows you to examine the current state of a program and respond appropriately to that state.

cars = ['audi', 'bmw', 'subaru', 'toyota']
for car in cars:
if car == 'bmw':
print(car.upper())
else:
print(car.title())


Checking for Equality

Most conditional tests compare the current value of a variable to a specific
value of interest. The simplest conditional test checks whether the value of a variable is equal to the value of interest:
u car = 'bmw'
v car == 'bmw'
True

Ignoring Case When Checking for Equality

Testing for equality is case sensitive in Python. For example, two values with different capitalization are not considered equal:
car = 'Audi' car == 'audi'
False

Checking for Inequality

When you want to determine whether two values are not equal, you can
combine an exclamation point and an equal sign (!=).

toppings.py requested_topping = 'mushrooms'
u if requested_topping != 'anchovies':
print("Hold the anchovies!")Using Multiple elif Blocks
You can use as many elif blocks in your code as you like.
Omitting the else Block

Python does not require an else block at the end of an if-elif chain. Sometimes an else block is useful; sometimes it is clearer to use an additional elif statement that catches the specific condition of interest:

Testing Multiple Conditions

The if-elif-else chain is powerful, but it’s only appropriate to use when you
just need one test to pass.
However, sometimes it’s important to check all of the conditions of
interest. In this case, you should use a series of simple if statements with no
elif or else blocks. This technique makes sense when more than one condition
could be True, and you want to act on every condition that is True.

Let’s reconsider the pizzeria example. If someone requests a two-topping
pizza, you’ll need to be sure to include both toppings on their pizza:
requested_toppings = ['mushrooms', 'extra cheese']
if 'mushrooms' in requested_toppings:
print("Adding mushrooms.")
if 'pepperoni' in requested_toppings:
print("Adding pepperoni.")
if 'extra cheese' in requested_toppings:
print("Adding extra cheese.")
print("\nFinished making your pizza!")

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Python: Chapter 4 Conditional Statements(if else, if elif, multiple elifs)», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.