Страница 5 из 5
print(result)
Run the above code in the console and see what it returns. Let's break it down.
I've created a variable named result in this code and assigned it a Boolean value from comparing the two strings "apples" and "oranges ".
Then I went down one line and printed the value of the "result" variable on the screen, passing the variable name in parentheses to the print function.
Does it make sense?) Now, alter the code by indicating that apples and oranges are not equal. What does the program return?
4 Comparing Variables
Not only can we compare numbers and strings, but the entire variables too! See how we can do it:
fruit = "Kiwi"
result = fruit == "Apple"
print(result)
Before you write the code into the console and hit enter, think of what output it will return? Let's break it down:
Конец ознакомительного фрагмента.
Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.