-
Notifications
You must be signed in to change notification settings - Fork 2
/
Week 0 - Intro to python.py
73 lines (56 loc) · 1.09 KB
/
Week 0 - Intro to python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#varibles
i = 2
f = 2.4
st = 'haron'
st1 = 'your age in 5 years is '
age = '20'
haroonis20 = True
#functions
def add(x, y):
print(x+y)
#v = add(15, 20)
#lists
vec1 = [1, 2, 3]
vec2 = [4, 5, 6]
ls = [[1, 2, 3],
[4, 5, 6]]
ls.append([7, 8, 9])
sls = ['my', 2, 'is', 'haron']
#dictionaries
mdict = {'000':'John', '001':'Sally', '002':'Jermaine'}
#logical operators + if statements
x=5
y=10
bo = False
if bo:
print('bo is true')
else:
print('bo is false')
#loops
f = 0
while f<10:
#print(f)
f = f+1
mylist = ['this', 'is', 'a', 'list']
#for word in mylist:
#print(word)
#classes and objects
class car:
def __init__(self, brand, year):
self.brand = brand
self.year = year
self.state ='parked'
def start(self):
if self.year<=1990:
self.state = 'stalling'
else:
self.state= 'going'
print(self.state)
mycar = car('ford', 1980)
mysecondcar = car('tesla', 2016)
#mycar.start()
import numpy as np
vec = np.array([0, 0, 1])
mat = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])