python1
python1
in three hours
Supasses Everyone
What is what?
What is a Computer Program?
What is a Programming language?
Compiled vs Interpreted
Compiled Language
• Interpreted Language
Question?
“Python is an experiment in
how much freedom program-
mers need. Too much
freedom and nobody can read
another's code; too little and
expressive-ness is
endangered.”
- Guido van Rossum
How Python got it’s name?
The name Python is inspired
from Guido’s favorite comedy
TV show called “Monty
Python’s Flying Circus”.
He wanted a name that was
short, unique and slightly
mysterious so he decided to
called the language Python
Why was Python Created?
“My original motivation for creating Python was the
perceived need for a higher level language in the Amoeba
[Operating Systems] project.
I realized that the development of system
administration utilities in C was taking too long.
Moreover, doing these things in the Bourne shell wouldn't
work for a variety of reasons. ...
So, there was a need for a language
that would bridge the gap between C and the
shell”
- Guido Van Rossum
What Python can do?
GUI Applications
Web Applications
Data Analysis
AI/ML
Hacking
Gaming
Android Development
What is our goal after 3 hour
Read Python
Write Python
>>> [1, 2, 3] * 3
[1, 2, 3, 1, 2, 3, 1, 2, 3]
>>> “Hello” * 3
‘HelloHelloHello’
Mutability:
Tuples vs. Lists
Lists are mutable
>>> li.sort(some_function)
# sort in place using user-defined comparison
Tuple details
The comma is the tuple creation operator, not parens
>>> 1,
(1,)
Python shows parens for clarity (best practice)
>>> (1,)
(1,)
Don't forget the comma!
>>> (1)
1
Trailing comma only required for singletons others
Empty tuples have a special syntactic form
>>> ()
()
>>> tuple()
()
Summary: Tuples vs. Lists
Lists slower but more powerful than tuples
• Lists can be modified, and they have lots of
handy operations and mehtods
• Tuples are immutable and have fewer
features
To convert between tuples and lists use the
list() and tuple() functions:
li = list(tu)
tu = tuple(li)