1. +
Dr. Ramadan Babers
Faculty of Science - Helwan University
Spring – 2019
Python
LEC - 01
for
Biologists
https://www.linkedin.com/in/ramadan-babers-phd-78976345
4. 1. Introduction
4
Different ways that people use computers.
In school,
Students use computers
for tasks such as
writing papers,
searching for articles,
sending email, and
participating in online
classes.
5. 1. Introduction
5
Different ways that people use computers.
At work,
People use computers to
analyze data,
make presentations,
conduct business
transactions,
communicate with
customers,
control machines and
do many other things.
6. 1. Introduction
6
Different ways that people use computers.
At home,
People use computers for
tasks such as
paying bills,
shopping online,
communicating with
friends and family, and
playing computer
games.
7. 1. Introduction
7
Computers can do such a wide variety of
things because they can be programmed.
This means that computers are not designed
to do just one job, but to do any job that their
programs tell them to do.
A program is a set of instructions that a
computer follows to perform a task
8. 2. How a ProgramWorks
8
CONCEPT:
A computer’s CPU can
only understand
instructions that are
written in machine
language.
Because people find it
very difficult to write
entire programs in
machine language, other
programming languages
have been invented.
9. 2. How a ProgramWorks
9
CPU only understands
machine language, it is
difficult for people to
write programs in
machine language.
For this reason,
assembly language was
created as an
alternative to machine
language.
10. 2. How a ProgramWorks
10
Assembly language programs cannot be executed
by the CPU, however.
The CPU only understands machine language,so
a special program known as an assembler is used
to translate an assembly language program to a
machine language program.
11. 3. Compilers and Interpreters
11
Because the CPU understands only machine
language instructions, programs that are written
in a high-level language must be translated into
machine language.
Depending on the language that a program has
been written in, the programmer will use either a
compiler or an interpreter to make the translation.
13. 3.2 Interpreters
13
The Python language uses an interpreter, which is a program that both
translates and executes the instructions in a high-level language
program. As the interpreter reads each individual instruction in the
program, it converts it to machine language instructions and then
immediately executes them.
14. 3.3 Compiling and interpreting
14
Many languages require
you to compile (translate)
your program into a form
that the machine
understands.
Python is instead directly
interpreted into machine
instructions.
compile execute
outputsource code
Hello.java
byte code
Hello.class
interpret
outputsource code
Hello.py
15. 4. Ambiguity
15
Why Do We Need
Programming
Language
Can we use natural
languages like
English?
16. 4. Ambiguity (Quiz)
16
Would you rather be paid $100 weekly or
biweekly?
o Prefer to be paid $100 weekly.
o Prefer to be paid $100 biweekly.
o It depends.
o Prefer not to be paid at all.
18. 4. Ambiguity (Quiz)
18
Would you rather be paid $100 weekly or
biweekly?
o Prefer to be paid $100 weekly.
o Prefer to be paid $100 biweekly.
o It depends.
o Prefer not to be paid at all.
Different people understand different ways
20. 6. Derivation
20
Sentence Subject Verb Object
Subject
Object
Verb
Verb
Noun
Noun
Noun
Noun
like
eat
I
Python
Non-terminal
terminal
Noun cookies
21. 6. Derivation
21
Sentence Subject Verb Object
Non-terminal
terminal
Noun
like Noun
Verb
I
Object
Python
Subject
Object
Verb
Verb
Noun
Noun
Noun
Noun
like
eat
I
Python
Derivation:
Starting from some non-terminals,
follow the roles to derive the
sequence of terminals
22. 7. Quiz
22
Sentence Subject Verb Object
Which of these sentences can be produced from
the following grammar? Starting from Sentence
o Python eat cookies
o Python eat Python
o I like eat
o Eat python cookies