• Computers and programs (chapter 1 of the textbook)
• Python basics: variables, expressions, data types, comments, etc.
• Control flows: conditional, iteration, exceptions
• Functions: function definition and call, arguments, return values
• common build-in functions: print, len, int, float, str, bool, etc.
• standard library: string, file I/O, math, random
Data structures: list, tuple, set
• OOP (object-oriented programming): class, object, etc.
Algorithm: recursion, search, sort, efficiency, computability
Variables and Expressions
Variable 변수: named memory location, it contains a value
Assignment : ‘=’ symbol indicates assignment
r=10 → r is variable, the value of r is 10
r=10 → r is assigned the value of 10
Variable Name Rules
1. Must start with a letter or underscore _
2. Must consist of letters and numbers and underscores
3. Case Sensitive
• Good: spam eggs spam23 _speed
• Bad: 23spam #sign var.12
• Different: spam Spam SPAM
You cannot use reserved words as variable names / identifiers
reserved words: and del for is raise assert elif from lambda return break
else global not try class except if ...
expression and statement
Difference Expression will be evaluated to a value,
but a statement will not be evaluated to a value.
ex) expressions: 1+1, ‘a’*3, 1
ex) statements: x=1, y =2, z=3
Numeric expressions
+ – * / **(제곱) %(나머지)
계산순서
Parenthesis (괄호 삽입어구)
** (power)
*
+
Left to right
3data types
Int, float, str
Int → numbers as integers (정수) ex) 100, 0,89 * function : int()
Float → numbers as decimals (소수) ex) -2.1, 100.01, 12.34 * function : float()
Str → strings (문자열) “” 둘러싸여 있는 자들의 집합 * function : str()
“life is short, you need python”
“a”
“1,2,3”, “!:?”, “&^-+”
Spam → variable
‘spam’ → string