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

If Else & Elif Conditionals In Python | Python Tutorial for Beginners | Python Programming Language

My full course is on Udemy. Here is a link to Enroll - https://www.udemy.com/course/python-basics-2023-bootcamp/?referralCode=F55B010FCFBE0D242300

If Statements
As shown in the earlier example, conditional statements are run by using the If statement.
A condition is checked in the if section. If it is true, the code runs. But when the code is run otherwise, nothing happens.
See the example given on the screen to understand how to use the if statement. It shows that if the value of x is greater than zero, python will print “x is positive”; otherwise, nothing will happen.

If…Else Statements
A second form of the IF statement is an alternative execution in which there are two possibilities in the condition that determines which one gets executed. This is called the IF…ELSE statement.

In the given example, a value of twenty is assigned to the age variable. Now in the if statement, it’s being checked whether the age is equal to the given value of twenty or not. If this condition is true, then python will print “age is 20 years” else python will print “age is not 20”.

You can also use greater than and greater than equal to operators with the if…else statements. In the given example, you can check if the age is greater than eighteen. In case it’s true, python will print “person is adult”, otherwise, it will print “person is not adult”.

If…Else If Statements
Sometimes, there are more than two possibilities and you will need more than two branches. One way to express such computation is a chained conditional. This is also called the if..elif statements. Elif is an abbreviation of else…if.

Again, exactly one branch will be executed. There is no limit on the number of elif statements.

To understand it better, consider the given example
Create variable named marks and assigned a value of ninety-five. Now, for different grades, the result will depend on a value stored in the marks variable. In the highlighted example, if the mark is greater than ninety, then the grade is A. Now if the mark is not greater than ninety, then the second if condition which is elif marks greater than or equal to eighty will be evaluated. In this case, python will print a B grade. Similarly, if marks are less than eighty, the next elif condition will be evaluated to check if the marks are greater than or equal to sixty.
As mentioned earlier, there can be any number of elif statements.

If…Else If…Else Statements
The next type of conditional statement is if…elif and else combined. If none of the conditions is met, then else block is executed.
Notice the same example of marks. If marks are less than sixty, then the else statement will be executed.

#python #pythonprogramming #pythontutorial

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «If Else & Elif Conditionals In Python | Python Tutorial for Beginners | Python Programming Language», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

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

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

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