forked from PacktPublishing/Machine-Learning-and-Data-Science-with-Python-A-Complete-Beginners-Guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_tutorials_python.py
More file actions
105 lines (68 loc) · 1.36 KB
/
Copy pathquick_tutorials_python.py
File metadata and controls
105 lines (68 loc) · 1.36 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 10 04:02:33 2019
@author: abhilash
"""
# string assignment
data = 'hello world'
print(data[0])
print(len(data))
print(data)
#number assignment
value = 123.1
print(value)
value = 10
print(value)
#boolean assignment
a = True
b = False
print(a, b)
#multiple assignment
d, e, f = 1, 2, 3
print(d, e, f)
#none assignment
g = None
print(g)
#flow control statements
#if-then-else conditional statement
value = 205
if value == 199:
print ('That is fast')
elif value > 200:
print ('That is too fast')
else:
print ('That is safe')
#for loop
for i in range(10):
print (i)
#while loop
i = 0
while i<10:
print (i)
i += 1
#data structures
#tuples
a = (1, 2, 3)
print(a)
#list
mylist = [1, 2, 3]
print("zeroth value: %d" % mylist[0])
mylist.append(4)
print("List length: %d" % len(mylist))
for value in mylist:
print (value)
#dictionary
mydict = {'a': 1, 'b': 2, 'c': 3}
print("A value: %d" % mydict['a'])
mydict['a'] = 11
print("A value: %d" % mydict['a'])
print("keys: %s" % mydict.keys())
print("Values: %s" % mydict.values())
for key in mydict.keys():
print (mydict[key])
#function
def mysum(x, y):
return x + y
#call the function
result = mysum(5, 3)
print(result)