Computing:
Introduction to Python
What Is Python?
Python is a programming language.
Guido van Rossum developed Python in 1991.
Python is used by:
Python is used in many universities to teach programming.
Starting Python
We can use Python IDE to create and run our
Python programs.
IDE is an acronym of Integrated
Development Environment.
An Integrated Development Environment
contains all the tools needed to write, test
and run computer programs.
Hello World
• Let’s stick with the Interactive mode window
for now,
and learn our first Python command: print
• print does exactly what it says: it prints
information onto the screen.
• It does not print anything onto a printer.
CODES:
OUTPUT:
Cool Calculations
• We can also use the Python print command to help us
do calculations.
• The important thing to remember here is that we are
dealing with numbers and not text, therefore we do
not use “quotes” as before.
• Try the following print instructions now and see what
happens:
Cool Calculations
Cool Calculations
Try these last examples, and see if you can figure out what
Python is doing with the numbers:
( “5 + 3” )
(5+3)
(5*3)
Cool Calculations
The double-slash // is rounding-down
(or “floored”) division. It divides two
values and rounds down the answer.
The double-asterisk ** here means 5 to
the power of 2.
These last ones are modulo-division.
% gives the remainder of a division
between two values.
E.g. 15 / 2 = 7
remainder 1.
a. print (7*9) output:
b. print (7//3) output:
c. print (87/6) output:
d. print (12 * 0.0) output:
e. print (7+4*8) output:
f. print (7//3) output:
g. print (2**3) output:
h. print (10%3) output:
i. print (14%7) output: