- Basic types (
int
,float
,complex
,bool
) - Container types (
str
,list
,dict
) - Control flow:
for
/range
andif
/elif
/else
Some things to remember:
- Implicit type casting (
3 / 2 == 1
vs.3 / 2.0 == 1.5
) can happen! - Strings are wrapped in quotes, either double
"
or single'
- You can concatenate strings with
+
- You can add numbers with
+
Wait! What's happening here?
The +
operator is polymorphic.
For things of type int
or float
it is addition.
For things of type str
it concatenates them (i.e. "adds" them).
Back to things to remember:
for i in range(10):
i
is bound to the element for each looprange(x)
is a function that creates a listif(condition1 and condition2):
- Remember to add the
:
at the end - Indentation!
e.g.
for i in range(100):
if(i % 2 == 0 and i % 3 == 0):
print('FizzBuzz')
elif(i % 2 == 0):
print('Fizz')
elif(i % 3 == 0):
print('Buzz')
else:
print(i)
- SciPy lecture notes 1.2.3
- Maybe time for functions... SciPy lecture notes 1.2.4