-
Notifications
You must be signed in to change notification settings - Fork 1
/
fun.py
432 lines (369 loc) · 13.5 KB
/
fun.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# -*- coding: utf-8 -*-
from Alphas import core
import time
def braille(start=0, end=26):
"""
fun.braille([start, [end]]) -> dict
Returns a dictionary of alphabets (key is alphabet) and value is its braille
Note: Braille of uppercase and lowercase alphabets is same.
"""
letters = {
'a': [[1, 0], [0, 0], [0, 0]],
'b': [[1, 0], [1, 0], [0, 0]],
'c': [[1, 1], [0, 0], [0, 0]],
'd': [[1, 1], [0, 1], [0, 0]],
'e': [[1, 0], [0, 1], [0, 0]],
'f': [[1, 1], [1, 0], [0, 0]],
'g': [[1, 1], [1, 1], [0, 0]],
'h': [[1, 0], [1, 1], [0, 0]],
'i': [[0, 1], [1, 0], [0, 0]],
'j': [[0, 1], [1, 1], [0, 0]],
'k': [[1, 0], [0, 0], [1, 0]],
'l': [[1, 0], [1, 0], [1, 0]],
'm': [[1, 1], [0, 0], [1, 0]],
'n': [[1, 1], [0, 1], [1, 0]],
'o': [[1, 0], [0, 1], [1, 0]],
'p': [[1, 1], [1, 0], [1, 0]],
'q': [[1, 1], [1, 1], [1, 0]],
'r': [[1, 0], [1, 1], [1, 0]],
's': [[0, 1], [1, 0], [1, 0]],
't': [[0, 1], [1, 1], [1, 0]],
'u': [[1, 0], [0, 0], [1, 1]],
'v': [[1, 0], [1, 0], [1, 1]],
'w': [[0, 1], [1, 1], [0, 1]],
'x': [[1, 1], [0, 0], [1, 1]],
'y': [[1, 1], [0, 1], [1, 1]],
'z': [[1, 0], [0, 1], [1, 1]]
}
d = core.dic(0, start, end)
for i in d:
d[i] = letters[i]
return d
def lipsum():
"""
Returns filler text, lorem ipsum.
"""
lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed \
do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim \
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip \
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate \
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat \
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id \
est laborum."
return lorem
def morse(char):
"""
fun.morse(char) -> list
input is a single alphabet.
Returns morse notation of the alphabet in "dots and dashes" and
"dits and dahs" forms, in a list.
"""
if not char.isalpha() or len(char) > 1:
raise Exception("Not a valid input!! Give in a single character.")
letters = {
'a': ['._', 'dit-dah'],
'b': ['_...', 'dah-di-di-dit'],
'c': ['_._.', 'dah-di-dah-dit'],
'd': ['_..', 'dah-di-dit'],
'e': ['.', 'dit'],
'f': ['.._.', 'di-di-dah-dit'],
'g': ['__.', 'dah-dah-dit'],
'h': ['....', 'di-di-di-dit'],
'i': ['..', 'di-dit'],
'j': ['.___', 'di-dah-dah-dah'],
'k': ['_._', 'dah-di-dah'],
'l': ['._..', 'di-dah-di-dit'],
'm': ['__', 'dah-dah'],
'n': ['_.', 'dah-dit'],
'o': ['___', 'dah-dah-dah'],
'p': ['.__.', 'di-dah-dah-dit'],
'q': ['__._', 'dah-dah-di-dah'],
'r': ['._.', 'di-dah-dit'],
's': ['...', 'di-di-dit'],
't': ['-', 'dah'],
'u': ['.._', 'di-di-dah'],
'v': ['..._', 'di-di-di-dah'],
'w': ['.__', 'di-dah-dah'],
'x': ['_.._', 'dah-di-di-dah'],
'y': ['_.__', 'dah-di-dah-dah'],
'z': ['__..', 'dah-dah-di-dit']
}
return letters[char.lower()]
def nato(char):
"""
fun.nato(char) -> list
input is a single alphabet.
Returns NATO notation of the alphabet.`
"""
if not char.isalpha() or len(char) != 1:
raise Exception("Not a valid input!! Give in a single character.")
letters = {
'a': 'Alfa',
'b': 'Bravo',
'c': 'Charlie',
'd': 'Delta',
'e': 'Echo',
'f': 'Foxtrot',
'g': 'Golf',
'h': 'Hotel',
'i': 'India',
'j': 'Juliett',
'k': 'Kilo',
'l': 'Lima',
'm': 'Mike',
'n': 'November',
'o': 'Oscar',
'p': 'Papa',
'q': 'Ouebec',
'r': 'Romeo',
's': 'Sierra',
't': 'Tango',
'u': 'Uniform',
'v': 'Victor',
'w': 'Whiskey',
'x': 'X-ray',
'y': 'Yankee',
'z': 'Zulu'
}
return letters[char.lower()]
def pronun(char):
"""
fun.pronun(char) -> dict
input is a single alphabet.
Returns the letter name to pronunciation dictionary of the alphabet.
"""
if not char.isalpha() or len(char) != 1:
raise Exception("Not a valid input!! Give in a single character.")
letters = {
'a': {
'a': '/ˈeɪ/'
},
'b': {
'bee': '/ˈbiː/'
},
'c': {
'cee': '/ˈsiː/'
},
'd': {
'dee': '/ˈdiː/'
},
'e': {
'e': '/ˈiː/'
},
'f': {
'ef': '/ˈɛf/'
},
'g': {
'gee': '/ˈdʒiː/'
},
'h': {
'aitch': '/ˈeɪtʃ/',
'haitch': '/ˈheɪtʃ/',
'hetch': '/ˈhetʃ/'
},
'i': {
'i': '/ˈaɪ/'
},
'j': {
'jay': '/ˈdʒeɪ/',
'jy': '/ˈdʒaɪ/'
},
'k': {
'kay': '/ˈkeɪ/'
},
'l': {
'el': '/ˈɛl/'
},
'm': {
'em': '/ˈɛm/'
},
'n': {
'en': '/ˈɛn/'
},
'o': {
'o': '/ˈəʊ/'
},
'p': {
'pee': '/ˈpiː/'
},
'q': {
'cue': '/ˈkjuː/'
},
'r': {
'ar': '/ˈɑː/'
},
's': {
'ess': '/ˈɛs/',
'es': '/ˈɛs/'
},
't': {
'tee': '/ˈtiː/'
},
'u': {
'u': '/ˈjuː/'
},
'v': {
'vee': '/ˈviː/'
},
'w': {
'double-u': '/ˈdʌbəl.juː/'
},
'x': {
'ex': '/ˈɛks/'
},
'y': {
'wy': '/ˈwaɪ/',
'wye': '/ˈwaɪ/'
},
'z': {
'zed': '/ˈzɛd/',
'zee': '/ˈziː/',
'izzard': '/ˈɪzərd/'
}
}
return letters[char.lower()]
def song():
"""
Prints the lyrics of The Alphabet Song, with the proper time gap.
"""
lyrics = [['A', 'B', 'C', 'D', 'E', 'F', 'G'],
['H', 'I', 'J', 'K', 'LMNO', 'P'],
['Q', 'R', 'S'],
['T', 'U', 'V'],
['W'],
['X'],
['Y'],
['and', 'Z'],
['Now I know my ABCs'],
['Next time, won\'t you sing with me?']]
for line in lyrics:
for l in line:
print(l)
time.sleep(.2)
time.sleep(1)
def lovesong():
"""
Prints the lyrics of The Alphabet Love Song, with the proper time gap.
"""
lyrics = ["A, you're adorable",
"B, you're so beautiful",
"C, you're a cutie full of charms",
"D, you're a darling",
"And E, you're exciting",
"And F, you're a feather in my arms",
"G, you look good to me",
"H, you're so heavenly",
"I, you're the one I idolize",
"J, we're like Jack and Jill",
"K, you're so kissable",
"L, is the love light in your eyes",
"M, N, O, P",
"I could go on all day",
"Q, R, S, T",
"Alphabetically speaking: \"You're OK\"",
"U, made my life complete",
"V, means you're very sweet",
"W, X, Y, Z",
"It's fun to wander through the alphabet with you to tell you what you mean to me."]
for line in lyrics:
print(line)
time.sleep(2)
def country(char):
"""
fun.country(char) -> list
input is a single alphabet.
Returns a list of country names starting from alphabet char.
"""
if not char.isalpha() or len(char) != 1:
raise Exception("Not a valid input!! Give in a single character.")
countries = {
'a': ['Abkhazia', 'Afghanistan',
'Akrotiri and Dhekelia(United Kingdom)', 'Albania', 'Algeria',
'American Samoa(United States)', 'Andorra', 'Angola',
'Anguilla(United Kingdom)', 'Antarctica', 'Antigua and Barbuda',
'Argentina', 'Armenia', 'Aruba(Netherlands)',
'Ashmore and Cartier Islands(Australia)', 'Australia',
'Austria', 'Azerbaijan'],
'b': ['Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus',
'Belgium', 'Belize', 'Benin', 'Bermuda(United Kingdom)',
'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana',
'Bouvet Island(Norway)', 'Brazil',
'British Indian Ocean Territory(United Kingdom)',
'British Virgin Islands(United Kingdom)', 'Brunei', 'Bulgaria',
'Burkina Faso', 'Burundi'],
'c': ['Cambodia', 'Cameroon', 'CanadaChina', 'Cape Verde',
'Cayman Islands(United Kingdom)', 'Central African Republic',
'Chad', 'Chile', 'Christmas Island(Australia)',
'Clipperton Island(France)', 'Cocos (Keeling) Islands(Australia)',
'Colombia', 'Comoros', 'Cook Islands(New Zealand)',
'Coral Sea Islands(Australia)', 'Costa Rica', 'Cote d Ivoire',
'Croatia', 'Cuba', 'Curacao(Netherlands)', 'Cyprus',
'Czech Republic'],
'd': ['Democratic Republic of the Congo', 'Denmark', 'Djibouti',
'Dominica', 'Dominican Republic'],
'e': ['East Timor', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea',
'Eritrea', 'Estonia', 'Ethiopia'],
'f': ['Falkland Islands(United Kingdom)', 'Faroe Islands(Denmark)',
'Federated States of Micronesia', 'Fiji', 'Finland',
'French Polynesia(France)',
'French Southern and Antarctic Lands(France)'],
'g': ['Gabon', 'Gambia', 'Georgia', 'Germany', 'Ghana',
'Gibraltar(United Kingdom)', 'Greece', 'Greenland', 'Grenada',
'Guam(United States)', 'Guatemala', 'Guernsey(United Kingdom)',
'Guinea', 'Guinea-Bissau', 'Guyana'],
'h': ['Haiti', 'Heard Island and McDonald Islands(Australia)',
'Honduras', 'Hong Kong(China)', 'Hungary'],
'i': ['Iceland', 'India', 'Indonesia', 'Iran', 'Iraq',
'Isle of Man(British Crown Dependency)', 'Israel', 'Italy'],
'j': ['Jamaica', 'Jan Mayen(Norway)', 'Japan',
'Jersey(United Kingdom)', 'Jordan'],
'k': ['Kazakhstan', 'Kenya', 'Kiribati', 'Kosovo', 'Kuwait',
'Kyrgyzstan'],
'l': ['Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libya',
'Liechtenstein', 'Lithuania', 'Luxembourg'],
'm': ['Macau(China)', 'Macedonia', 'Madagascar', 'Malawi',
'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands',
'Mauritania', 'Mauritius', 'Mexico', 'Moldova', 'Monaco',
'Metropolitan France&overseas regions(France)',
'Mongolia', 'Montenegro', 'Montserrat(United Kingdom)',
'Morocco', 'Mozambique', 'Myanmar'],
'n': ['Nagorno-Karabakh', 'Namibia', 'Nauru', 'Niger', 'Nigeria',
'Navassa Island(disputed)', 'Nepal', 'Netherlands',
'New Caledonia(France)', 'New Zealand', 'Nicaragua',
'Niue(New Zealand)', 'Norfolk Island(Australia)', 'North Korea',
'Northern Cyprus', 'Northern Mariana Islands(United States)',
'Norway'],
'o': ['Oman'],
'p': ['Pakistan', 'Palau', 'Panama', 'Papua New Guinea', 'Paraguay',
'Peru', 'Philippines', 'Pitcairn Islands(United Kingdom)',
'Poland', 'Portugal', 'Puerto Rico(United States)'],
'q': ['Qatar'],
'r': ['Republic of Ireland', 'Republic of the Congo', 'Romania',
'Russia', 'Rwanda'],
's': ['Saint Barthelemy(France)', 'Saint Kitts and Nevis',
'Saint Helena, Ascension and Tristan da Cunha(United Kingdom)',
'Saint Lucia', 'Saint Martin(France)', 'Samoa', 'San Marino',
'Saint Pierre and Miquelon(France)', 'Sao Tome and Principe',
'Saint Vincent and the Grenadines', 'Saudi Arabia',
'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone', 'Singapore',
'Sint Maarten(Netherlands)', 'Slovakia', 'Slovenia', 'Somalia',
'Solomon Islands', 'Somaliland', 'South Africa', 'South Korea',
'South Georgia and the South Sandwich Islands(United Kingdom)',
'South Ossetia', 'South Sudan', 'Spain', 'Spratly Islands(disputed)',
'Sri Lanka', 'State of Palestine', 'Sudan', 'Suriname',
'Svalbard(Norway)', 'Swaziland', 'Sweden', 'Switzerland', 'Syria'],
't': ['Taiwan', 'Tajikistan', 'Tanzania', 'Thailand', 'Togo',
'Tokelau(New Zealand)', 'Tonga', 'Transnistria',
'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan',
'Turks and Caicos Islands(United Kingdom)', 'Tuvalu'],
'u': ['U.S. Virgin Islands(United States)', 'Uganda', 'Ukraine',
'United Arab Emirates', 'United Kingdom', 'United States',
'United States Pacific Island Wildlife Refuges', 'Uruguay',
'Uzbekistan'],
'v': ['Vanuatu', 'Vatican City', 'Venezuela', 'Vietnam'],
'w': ['Wake Island(United States)', 'Wallis and Futuna(France)',
'Western Sahara'],
'y': ['Yemen'],
'z': ['Zambia', 'Zimbabwe']
}
return countries[char.lower()]