-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscratch.py
More file actions
179 lines (140 loc) · 2.83 KB
/
scratch.py
File metadata and controls
179 lines (140 loc) · 2.83 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
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
import re
x = 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
y = re.findall('\S+?@\S+' , x)
print y
# import re
# x = 'From: Using the : character'
# y = re.findall('^F.+:', x)
# print y
# import re
# hand = open('mbox-short.txt')
# for line in hand:
# line = line.rstrip()
# x = re.findall('@\S+[a-zA-Z]', line)
# if len(x) > 0 :
# print x
# x = [1, 2, 3]
# y = [4, 5, 6]
# def join_lists(x, y):
# return x + y
# def join_strings(words):
# result = ("")
# for i in range(len(words)):
# result = result + words[i]
# return result
# print join_strings(n)
# x = (5, 1, 3)
# if (6, 0, 0) > x :
# print "greater"
# else:
# print "nope"
# stuff = dict()
# print stuff.get('candy',-1)
# friends = [ 'Joseph', 'Glenn', 'Sally' ]
# friends.sort()
# print friends[0]
# t = [9, 41, 12, 3, 74, 15]
# print t[2:4]
# a = [1, 2, 3]
# b = [4, 5, 6]
# c = a + b
# print len(c)
# fruit = 'Banana'
# # fruit[0] = 'b'
# print len(fruit)
# friends = [ 'Joseph', 'Glenn', 'Sally' ]
# print friends[2]
# s = 'word'
# print('The full string is: ', s)
# n = len(s)
# for i in range(n):
# print()
# print('i =', i)
# print('The letter at index i:', s[i])
# print('The part before index i (if any):', s[:i])
# print('The part before index i+2:', s[:i+2])
#fhand = open('mbox-short.txt')
#inp = fhand.read()
#fhand = open('mbox.txt')
#x = 0
#for line in fhand:
# x = x + 1
#print x
# smallest_so_far = None
# for the_num in [9, 41, 12, 3, 74, 15] :
# if the_num < smallest_so_far :
# smallest_so_far = the_num
# print smallest_so_far
# zork = 0
# for thing in [9, 41, 12, 3, 74, 15] :
# zork = zork + thing
# print 'After', zork
# tot = 0
# for i in [5, 4, 3, 2, 1] :
# tot = tot + 1
# print tot
# n = 5
# while n > 0 :
# print n
# print 'All done'
# def stuff():
# print 'Hello'
# return
# print 'World'
# stuff()
# def addtwo(a, b):
# added = a + b
# return a
# x = addtwo(2, 7)
# print x
# def func(x) :
# print x
# func(10)
# func(20)
# x = 10.5 * 40 + (10.5 * 1.5 * (45 - 40))
# print x
# def computepay(h,r):
# return h + (r * 1.5 * (h - 40))
# h = 45
# r = 10.5
# pay = computepay(h,r)
# print pay
# x = (42 % 10)
# print x
# x = 1 + 2 * 3 - 8 / 4
# print x
# x = int(98.6)
# print x
# x = 4
# if x == 5 :
# print 'Is 5'
# print 'Is Still 5'
# print 'Third 5'
# x = 0
# if x < 2 :
# print 'Small'
# elif x < 10 :
# print 'Medium'
# else :
# print 'LARGE'
# print 'All done'
# x = -2.0
# if x < 2 :
# print 'Below 2'
# elif x >= 2 :
# print 'Two or more'
# else :
# print 'Something else'
# astr = 'Hello Bob'
# istr = int(astr)
# print 'First', istr
# astr = '123'
# istr = int(astr)
# print 'Second', istr
# astr = 'Hello Bob'
# istr = 0
# try:
# istr = int(astr)
# except:
# istr = -1
# print istr