Hacking Secret Ciphers with Python

(Ann) #1

28 http://inventwithpython.com/hacking


Email questions to the author: [email protected]


Figure 3-2 is what the interactive shell will look like after you type in the previous instructions.


Figure 3 - 2. What the IDLE window looks like after entering instructions.

These math problems are called expressions. Computers can solve millions of these problems in
seconds. Expressions are made up of values (the numbers) connected by operators (the math
signs). There can be any amount of spaces in between the integers and these operators. But be
sure to always start at the very beginning of the line though, with no spaces in front.


Figure 3-3. An expression is made up of values (like 2 ) and operators (like +).

Order of Operations


You might remember “order of operations” from your math class. For example, multiplication
has a higher priority than addition. Python copies this for the and + operators. If an expression
has both
and + operators, the * operator is evaluated first. Type the following into the
interactive shell:





2 + 4 * 3 + 1
15




Free download pdf