Capitol Tech U Doctoral Presentation - April 2024.pptx
Python lec 1002_for_biologists
1. +
Dr. Ramadan Babers
Faculty of Science - Helwan University
Spring – 2019
Python
LEC - 02
for
Biologists
https://www.linkedin.com/in/ramadan-babers-phd-78976345
3. Chapter 1 Outlines
What Is Python?
General Examples
Flowcharts Examples (area)
3
4. 1. What Is Python?
4
• Python is a general-purpose
programming language.
• It was designed and developed
to write software for a wide
variety of disciplines.
• Python has been used to write
applications to solve problems in
- biology,
- chemistry,
- financial analysis,
- numerical analysis,
- robotics, and many other fields.
5. 1.1 History
5
• Invented in the Netherlands,early
90s by Guido van Rossum
• Named after Monty Python
• Open sourced from the beginning
• Considered a scripting language,
but is much more
• Scalable, object oriented and
functional from the beginning
• Used by Google from the
beginning
• Increasingly popular
10. 1. Flowcharts Examples (area)
10
Example (1)
Calculate the area of a
rectangle, given the length
(L) and width (w).
11. 11
Algorithm:
Step 1 : input first number
Step 2 : input second number
Step 3 : multiply two numbers and
store result in Area
Step 4 : print Area
12
1. Flowcharts Examples (area)
15. 15
Why have a programming book for biologists?
A biology-specific programming book allows us to
use examples and exercises that use biological
problems.
This serves two important purposes:
firstly, it provides motivation and demonstrates the
types of problems that programming can help to
solve.
Secondly, by using biological examples, the code and
exercises throughout the book can form a library of
useful code snippets, which we can refer back to
when we want to solve real-life problems.
16. 16
Why Python?
The choice of programming language does
matter, of course.To put it another ways, choosing
the "wrong" programming language is very
unlikely to mean the difference between failure
and success when learning.
learning a first programming language gets you
90% of the way towards learning a second, third,
and fourth one. Learning to think like a
programmer in the way that you break down
complex tasks into simple ones is a skill that cuts
across all languages
18. 18
Why are we so interested in working with text?
String is the word we use to refer to a bit of text
in a computer program (it just means a string of
characters).
From this point on we'll use the word string
when we're talking about computer code, and
we'll reserve the word sequence for when we're
discussing biological sequences like DNA and
protein.
19. 19
Printing a message to the screen
Name of a function
parentheses
arguments
• The whole line is called a
statement.
• print is the name of a function.
The function tells Python, in
vague terms, what we want to do
– in this case, we want to print
some text. The function name is
alwaysfollowed by parentheses.
• The bits of text inside the
parentheses are called the
arguments to the function.
20. 20
Quotes are important
strings are always surrounded by quotes.That is how
Python is able to tell the difference between:
o the instructions (like the function name) and
o the data (the thing we want to print).
We can use either
single or double
quotes for strings
21. 21
Quotes are important
You'll notice that the pervious output doesn't contain
quotes – they are part of the code, not part of the string
itself.
If we do want to include quotes in the output,
23. 23
Use comments to annotate your code
Comments are a very useful way to document your
code,You can put the explanation of what a particular
bit of code does right next to the code itself.
24. 24
Error messages and debugging
Forgetting quotes Spelling mistakes
Programming languages are not like
natural languages – they have a very
strict set of rules, and if you break any
of them, the computer will not attempt
to guess what you intended, but
instead will stop running and present
you with an error message.
26. 26
Python got confused
about whether the new
line was
part of the string
(which is what we wanted) or
part of the source code
(which is how it was actually
interpreted).
Printing special characters