Hacking Secret Ciphers with Python

(Ann) #1

26 http://inventwithpython.com/hacking


Email questions to the author: [email protected]


THE INTERACTIVE SHELL


Topics Covered In This Chapter:
 Integers and floating point numbers
 Expressions
 Values
 Operators
 Evaluating expressions
 Storing values in variables
 Overwriting variables


Before we start writing encryption programs we should first learn some basic programming
concepts. These concepts are values, operators, expressions, and variables. If you’ve read the
Invent Your Own Computer Games with Python book (which can be downloaded for free from
http://inventwithpython.com)) or already know Python, you can skip directly to chapter 5.


Let’s start by learning how to use Python’s interactive shell. You should read this book while
near your computer, so you can type in the short code examples and see for yourself what they
do.


Some Simple Math Stuff


Start by opening IDLE. You will see the interactive shell and the cursor blinking next to the >>>


(which is called the prompt). The interactive shell can work just like a calculator. Type 2 + 2
into the shell and press the Enter key on your keyboard. (On some keyboards, this is the Return
key.) As you can see in Figure 3-1, the computer should respond with the number 4.

Free download pdf