Gurbanov Roman - Python Handbook For Beginners стр 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:

Конец ознакомительного фрагмента.

Python Handbook For Beginners

читать Python Handbook For Beginners
Gurbanov Roman
This book will provide you with basic knowledge and skills in Python programming, covering topics such as variables, numbers, strings, booleans, conditional statements, loops, lists, dictionaries, functions, classes and objects, modules, and packages.Every chapter is wrapped up with a small test. De
Можно купить 99.9Р
Купить полную версию

Ваша оценка очень важна

0
Шрифт
Фон

Помогите Вашим друзьям узнать о библиотеке

Скачать книгу

Если нет возможности читать онлайн, скачайте книгу файлом для электронной книжки и читайте офлайн.

fb2.zip txt txt.zip rtf.zip a4.pdf a6.pdf mobi.prc epub ios.epub fb3

Популярные книги автора