Professional Documents
Culture Documents
Web Application
Development Tips
Jiannan Liu (Johnny)
Outline
Why python
Basic expressions
Data types
Build-in functions
Loop and condition
--Dan Sahfer
Basic Expressions
+ - * / addition, subtraction/negation, multiplication, division
** exponential
Eamples:
1. 1+3*5=16
2. 2**3=8
3. a=3
a+=a
By using from math import *, you can use methods like:
Example:
a=2.0
a=int(a)
b=2
b=float(b)
type(a)
type(a)
type(b)
type(b)
Data Types
Sequences
1. str: String; represented as a sequence of 8-bit characters
in Python 2.x, but as a sequence of Unicode charactersin
Python 3.x (Immutable)
2. bytes: a sequence of integers in the range of 0-255; only
available in Python 3.x(Immutable)
3. byte array: like bytes, but mutable; only available in
Python 3.x
4. list
5. tuple(Immutable) a=‘This is DB class’
b=b‘This is DB class’
c=[‘This is DB class’]
d=(‘This is DB class’)
Data Types
Mappings
1. dict: Python dictionaries, also called hashmaps or
associative arrays, which means that an element of
the list is associated with a definition, rather like a
Map in Java
fruit_numb={'apple': 3, 'banana': 0}
Build-in functions
Functions that are always available in Python.
max(), min(), sorted(), list(), tuple(),
print(), range(), len()…
More build in functions:
https://docs.python.org/3/library/functions.html#func-set
a=[5,3,2,4,1,0] a=‘database’
a=sorted(a) a=list(a)
print(a) a_length=len(a)
[0, 1, 2, 3, 4, 5]
Loop and Condition
Indentation(for space or one tab) is used to keep
code structure.
If/else:
if condition:
if condition:
statement
statement
else: or elif condition:
statement
statement
elif condition:
statement
Loop and Condition
Examples:
Web Application
Development Tips
Develop tools available in most of browsers
Be familiar with command line commands
Mac:
ls, cd, mkdir, touch, open, rm…
Windows:
ls, dir, cmd, mkdir, rmdir…
Thank you!