Python Tutorial : CHAPTER 4 Making decisions and performing statements
Now we are going to talk about making decisions in Python. As
programmers our work will consists in make decisions. The software and
applications we develop in Python should make decisions automatically
and efficiently. It is the core of programming. In this chapter you
will learn how to make decisions in Python using “True”, “False”. Also
you will learn how to make more complex decisions using “If”, “while”
and others.
Making decisions with True and False:
Python can compare immediately whether two values are true and false
through the use of “==”. For example you can type in the Python Shell:
>>> 500==500
True
>>> 500==501
False
Also you can compare with different type of numbers such as:
>>> 1.25==1.25
True
>>> 10.14==10
False
On the other hand, if you have two or more string you can use the
double equal to compare if two strings have the same content. I could
be a wonderful tool for programming.
When you are taking decision in Python using the double equal to
compare if two or more values or strings are the same you can also do
the contrary and if the number is minor or major. Let’s see a simple
example of this.
>>> 500 < 300
False
>>> 850 > 250
True
Also you can test if a number it isn’t equal:
>>> 1000 != 1000
False
>>> 800 != 400
True
Also you can compare two or more strings and determine if they are
equal, shorter or longer. Let’s see how it works.
>>> “Bush” > “Clinton”
False
>>> “Clinton” > “Bush”
True

