-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.py
182 lines (182 loc) · 3.85 KB
/
demo.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
8 * 3.57
8 x 3.57
5+30*20
5 + 30 * 20
(5 + 30) * 20
((5 + 30) * 20) / 10
5 + 30 * 20 / 10
fred = 100
print(fred)
fred = 200
john = fred
print(fred)
print(john)
20 + 10 * 365
3 * 52
3670 - 156
20 + 10 * 365 - 3 * 52
found_coins = 20
magic_coins = 10
stolen_coins = 3
found_coins + magic_coins * 365 - stolen_coins * 52
stolen_coins = 2
found_coins + magic_coins * 365 - stolen_coins * 52
found_coins + magic_coins * 365 - stolen_coins * 52
found_coins + magic_coins * 365 - stolen_coins * 52
abcd123456789
x
x = 0
x
x = "abcd1234"
x
"i am hzg"
# “i am hzg“
"the name of this book is \"python\""
'the name of this book is \"python\"'
'the name of this book is "python"'
# "the name of this book is "python""
"the name of this book is 'python'"
fred = '''How do dinosaurs pay their bills?
with tyrannosaurus checks!'''
print(fred)
fred = """How do dinosaurs pay their bills?
with tyrannosaurus checks!"""
print(fred)
fred
fred = """How do dinosaurs pay their bills?
with tyrannosaurus checks!"""
fred = """
first
second
third
"""
fred
silly_string = 'He said, "Aren't can't shouldn't wouldn't.'
silly_string = 'He said, "Aren't can't shouldn't wouldn't."'
silly_string = 'He said, 'Aren't can't shouldn't wouldn't.''
silly_string = "He said, "Aren't can't shouldn't wouldn't.""
silly_string = 'He said, "Aren't can't shouldn't wouldn't."'
silly_string = 'He said, "Aren\'t can\'t shouldn\'t wouldn\'t."'
silly_string
print silly_string
# silly_string = "He said,"Aren't can't shouldn't wouldn't.""
silly_string = "He said,\"Aren't can't shouldn't wouldn't.\""
print(silly_string)
silly_string = "He said,'Aren't can't shouldn't wouldn't.'"
silly_string
silly_string = '''He said,"Aren't can't shouldn't wouldn't."'''
silly_string = He said,"Aren't can't shouldn't wouldn't."
silly_string = '''
He said,"Aren't can't shouldn't wouldn't."
'''
print silly_string
myscore = 1000
message = 'I scored %s points'
print(message % myscore)
'I scored %s points' % 1000
'I scored %s points' % myscore
message % 1000
message % myscore
'I scored %d points' % myscore
'I scored %d points' % "test"
'I scored %s points' % "test"
nums = 'What did the number %s say to the number %s? Nice belt!!'
print(nums % (0,8))
nums = 'What did the number %s say to the number %s? Nice belt!!'
print(nums % 5)
nums = 'What did the number %s say to the number %s? Nice belt!!'
print(nums % (5,5))
print(10 * 'a')
aaaaaaaaaa
'aaaaaaaaaa'
'a' * 10
'a ' * 10
'a_' * 10
'a_a' * 10
'a a' * 10
' ' * 10
'a' + 10
'a' + 'b'
b = 10
'a' + b
b = '10'
'a' + b
"hello world"
"hello" + "world"
"hello" + " " + "world"
"hello" + " "*10 + "world"
("hello" + " " + "world") * 2
a = "hello"
b = "world"
a + b
a = "hello"
c = ' '
b = "world"
a + b + c
a + c + b
wizard_list = 'spider legs,toe of frog,eye of newt,bat wing,slug butter,snake dandruff'
print(wizard_list)
wizard_list = ['spider legs','toe of frog','eye of newt','bat wing','slug butter','snake dandruff']
print(wizard_list)
len()
len(wizard_list)
print(wizard_list[2])
print(wizard_list[1])
print(wizard_list[0])
wizard_list[2] =
wizard_list[2]
wizard_list[2] = 'snail tongue'
print(wizard_list)
print(wizard_list[2:5])
print(wizard_list[2:6])
print(wizard_list[2:len(wizard_list)])
print(wizard_list[2:-1])
print(wizard_list[2:-2])
print(wizard_list[2:])
print(wizard_list[2:7])
print(wizard_list[2:8])
print(wizard_list[8])
numbers = [1,2,3,4]
numbers
numbers.append('5')
print(numbers)
numbers.append(5)
print(numbers)
numbers[4] = 5
print(numbers)
numbers[len(numbers)]
numbers[len(numbers)] = 6
numbers[len(numbers)-1] = 6
print(numbers)
del numbers[4]
print(numbers)
del numbers[4]
print(numbers)
del numbers[3]
print(numbers)
del numbers[2]
print(numbers)
n1 = [1,2]
n2 = [3,4]
print(n1 + n2)
n3 = n1 + n2
print(n3)
print(n1 * 5)
print(n1 + 5)
print(n1 + [5])
n1 / [5]
x = [[1,2], [3,4]]
x
x[0]
x[[0]]
x[0][0]
(x[0])0
(x[0])[0]
x[1][0]
fibs =
fibs = (0,1,1,2,3)
print(fibs[3])
fibs[3] = 4
x = 'hello'
x[0]
len(x)