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

Python Tutorial for Absolute Beginners - #6 If statement

📁 Обучение 👁️ 16 📅 02.12.2023

Learn programming in Python 100 seconds at a time in this video for beginners. This is video number 6: IF statements

I know im going fast in this video, please use timestamps below to navigate the video.
Timestamps:
00:00 - Start
00:09 - IF, Input and Else statement
00:29 - Condition validation
01:02 - For Loop combined with IF’s
01:36 - Operators
01:45 - Multiple conditions

—————————————————————
IF STATEMENT
—————————————————————

The if statement is used in python when the program has to consider conditions
Here’s an example

Hungry = ‘yes’

If Hungry == ‘yes’:
print(“go eat”)

The answer to hungry is hard coded in the variable ‘hungry’
But python can ask the user for input like this
We can also add a response if the user is not hungry by using the ‘else’ statement

Hungry = input(“Are you hungry?”)

If hungry==‘yes’:
print(“go eat”)
Else:
print(“go work”)

When an if statement is executed
Python checks if the condition is false or true
Here’s an example
Color = ‘red’
Color == ‘blue’
Here the variable stored the color red
The second line checks what the color is
The result is false, because the values don’t match
Change it to red and Python returns True
Color == ‘red’
Remember variables and values are case sensitive
So this code will also return false
Because red is written written without a capital letter in the second line
Color = ‘Red’
Color == ‘red’


If statements can be combined with for loops
Colors = [‘blue’,’red’,’purple’]
For color in colors:
if color==‘red’:
print(“I love ” + color)
else:
print(“I don’t like “ + color)


Here the loop goes through a list
Remember the for loop stores one item in the variable per iteration
First the value blue is stored in the variable color
Then the if statement is executed to check whether the value of that color is red
In the first case it isn’t
So the ‘else’ part is executed
And prints out “I don’t like blue”
The second iteration, the value red is passed through the code
And the first part of the if statement is executed

If statements can be used with the different ‘operators’ of python
These are ‘operators’(one column) with their meaning (second column)
And this is how they can be used with if statements
Keynote examples if statements with different operators
Finally an if statement can also use check multiple conditions like this

NOTE- in a youtube description you cannot include angled brackets, that's why you can't see them below

age_0 = 21 or age_1 = 21
Or use multiple conditions with the elif statement
If age 21:
print(“you old”)
Elif age 31:
print(“you really old”)


————————————————————————



? Who are you?
My name is Raza. I am 30. I am a manager within IT for a year, but I’ve been an accountant for the majority of my career.
I’m in love with #Python :)

You can find me here:
? Instagram: https://www.instagram.com/razacodes/
? Twitter: https://twitter.com/razacodes
—————————————————————————————

Goals for 2021
Training Python hours: 35/1000
Python/Django Projects: 1/30
Subscribers: 1349/10,000

—————————————————————————————-
#100SecondsOfCode
#pythonforbeginners #programming

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

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

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

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