Recap#
In the first section we learned the very basics of python
Integer = 5
string = "String"
Float = 5.5
Common Pitfalls:
MyVariable = True
My_Variable = True
My Variable = True
Input In [1]
My Variable = True
^
SyntaxError: invalid syntax
Then we talked about if/else statements
if Integer <= 5:
print("This integer is equal or less than 5")
else:
print("The above statement is false")
This integer is equal or less than 5
Next were loops, especially for loops
. For loops can be used to repeat an operation, examine lists, and, in general, speed up our programs.
for i in range(5):
print(i)
0
1
2
3
4
Common pitfalls:
for i in range(5)
print(i)
Input In [7]
for i in range(5)
^
SyntaxError: invalid syntax
for i in range(5):
print(i)
Input In [8]
print(i)
^
IndentationError: expected an indented block
We extended this idea to the list datatype. Lists can be used to store variables of different datatypes.
MyList = [Integer,Float,string]
And we can also loop through these lists
for item in MyList:
if item != 5:
print(item)
else:
print(f"The value: {item} is equal to 5")
The value: 5 is equal to 5
5.5
String
We also saw that we can create a “list of lists”
fruits = ["Apple","Banana"]
overall_list = [fruits,MyList]
overall_list
[['Apple', 'Banana'], [5, 5.5, 'String']]
for list in overall_list:
print(type(list),list)
print(type(overall_list))
<class 'list'> ['Apple', 'Banana']
<class 'list'> [5, 5.5, 'String']
<class 'list'>
And we stopped at a section where we defined functions
. Functions can be used to prevent ourselves from repeating code snippets over and over again.
The overall syntax for functions goes like this
def MyFunction (List):
'''
This function takes a list as its input, repeats the list 5 times and returns it
'''
operation = List * 5
return operation
MyFunction(overall_list)
[['Apple', 'Banana'],
[5, 5.5, 'String'],
['Apple', 'Banana'],
[5, 5.5, 'String'],
['Apple', 'Banana'],
[5, 5.5, 'String'],
['Apple', 'Banana'],
[5, 5.5, 'String'],
['Apple', 'Banana'],
[5, 5.5, 'String']]
Schedule#
Today:
Functions and Modules notebook
DataStructures notebook
Maybe
Intro to Machine Learning
presentation
Tomorrow:
Intro to Machine Learning Presentation
Machine Learning Notebook
Course Evaluation
Any questions? Anything you would like to emphasize or learn about in the remaining two days?