-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrapCode
More file actions
96 lines (85 loc) · 2.4 KB
/
scrapCode
File metadata and controls
96 lines (85 loc) · 2.4 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
###Yes or no dialog box
##from tkinter import *
##
##class Window(Frame):
##
##
## def __init__(self, master=None):
## Frame.__init__(self, master)
## self.master = master
## self.init_window()
##
## #Creation of init_window
## def init_window(self):
## # Label question
## message = Label(self, text='Hello Carlos! Are you ready to work?',
## bg='white')
## message.pack()
## message.place(x=50, y=50)
## # changing the title of our master widget
## self.master.title('Ready to Work')
##
## # allowing the widget to take the full space of the root window
## self.pack(fill=BOTH, expand=1)
##
## # creating a button instance
## okButton = Button(self, text='Yes', height=1, width=5, command=self.ready)
## quitButton = Button(self, text='No', height=1, width=5,
## command=self.client_exit)
##
## # placing the button on my window
## okButton.place(x=100, y=100)
## quitButton.place(x=150, y=100)
##
## def client_exit(self):
## exit()
## def ready(self):
## print('It works!')
##
##root = Tk()
##
###size of the window
##root.geometry('300x150')
##
##app = Window(root)
##root.mainloop()
###Sorting example
##countries = [
## ('China', 1379000000, 3700000),
## ('Rusia', 144300000, 6612100),
## ('Mexico', 127500000, 760000)
## ]
##size = lambda country: country[2]
##countries.sort(key=size, reverse=True)
##print(countries)
##
##population = lambda country: country[1]
##countries.sort(key=population, reverse=True)
##print(countries)
###Lambda function example
##full_name = lambda fn, ln: fn.strip().title() + ' ' + ln.strip().title()
##print(full_name(' carlos', 'principe'))
##input_list = [1, 5, 10, 15, 4, 25, 50, 7]
##
##def div_by_five(num):
## if num % 5 == 0:
## return True
## else:
## return False
##
##xyz = (i for i in input_list if div_by_five(i))
##[print(i) for i in xyz]
###string formatting
##who = 'Manny'
##how_many = 10
##when = 'today'
##
##print('{} ate {} apples {}!'.format(who, how_many, when))
###List comprehension and generator
##import timeit
###comprehension
##xyz = [i for i in range(5000000)]
##print('Done in ' + str(timeit.default_timer()))
###generator
##xyz = (i for i in range(5000000))
##print('Done in ' + str(timeit.default_timer()))