repl.it
@ysjht143/

pick up randomly, search and multiply coding

Python

pick up randomly, search and multiply coding

fork
loading
Files
  • main.py
  • cross.py
  • duplication
  • 育賢抽抽樂抽籤結果.txt
main.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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
num_chosen = 0
title_knowhow = '設計者:育賢國中 葉日宏 版權所有\n'
title1_guess = '想要跟葉老師一起玩育賢國中抽抽樂嗎?!'
import time
time.sleep(1)
print(title1_guess)
title2_guess = "好的~那我們就一起來玩個抽抽樂吧~"
print(title2_guess,'\t',title_knowhow)
time.sleep(1)
char1 = '\n本次自行開發之抽籤系統特色介紹:\n'
char2 = '1.籤號最小值(起始值)、最大值(最末值)可自訂。\n'
char3 = '2.籤號絕不重覆。並自動偵測輸入訊息之型態與正確與否,給與適當修正。\n'
char4 = '3.可於抽籤前、抽籤中,經由insert(單一籤號輸入)及section(連續籤號整段批次輸入)方式,將籤號排除(豁免)。\n'
char5 = '4.抽籤結果,將依抽出籤號之先後及大小依序呈現。\n'
char6 = '5.凡走過必留下痕跡,左方列上有「育賢抽抽樂抽籤結果」檔,凡抽籤過的籤號皆會在此匯入,以為記錄及MEMO。\n'
char7 = '\n*****凡對本系統有新的「功能」建議,敬請提供予本人,以為精進改善。*****\n'
char_all = [char1, char2, char3, char4, char5, char6, char7]
for good_for_all in char_all:
    print(good_for_all)
    time.sleep(1)     
def maxmin():
    from random import random
    min_guess = "請輸入想要抽籤的最「小」值:"
    max_guess = "請輸入想要抽籤的最「大」值:"
    def catlog_input():
        global catlog1,catlog2
        catlog1 = input(min_guess)
        catlog2 = input(max_guess)           
        if catlog1.isdigit() != True or catlog2.isdigit() != True:
            time.sleep(0.8)
            print(' ***** 很抱歉~ 一定要輸入數值,不是文字喔~ 請重新輸入吧! *****\n')            
            catlog_input()
        else:
            pass        
        if int(catlog1) > int(catlog2) or int(catlog1) == int(catlog2):
            time.sleep(0.8)
            print(' ***** 很抱歉~ 您輸入的最「小」值比最「大」值還大喔~請重新輸入吧! *****\n')
            catlog_input()
        else:
            pass

    catlog_input()
       
    result_num = []
    sec_in = []
    def guess_again():        
        global num_chosen
        title_guess_result = '\n你抽的結果是:'
        title_guess_nextnum = '壓「Enter」抽下一個籤號吧~或不想抽下一個,請輸入「 n 」喔~\n(若需排除一些籤號,有外掛喔!!請輸入「insert」或「section」):'
        title_guess_over = '\n籤號都抽完囉~\n'
        title_guess_again = '還想再玩場抽抽樂嗎?' 
        import time
        time.sleep(0.5)
        import random
        import math

        random_result = str(random.randint(int(catlog1),int(catlog2)))
        response_result = title_guess_result + random_result
        if len(result_num) < (int(catlog2)-int(catlog1)+1):
            if str(random_result) in result_num:
                guess_again()
            else:
                no_nextnum = input(title_guess_nextnum)

                if no_nextnum == "era" or no_nextnum == "erase":
                    def erase_again():
                        while True:
                            erase_num = input('請輸入您想刪除之已排除(或豁免)、已抽中之籤號,若完成請輸入out:')
                            if erase_num == 'out':
                                break                                
                            if erase_num.isdigit() != True:
                                print('\n~~~~~ 請輸入數字而非文字或符號。 ~~~~~')
                            if erase_num not in result_num:
                                time.sleep(0.5)
                                print('******** 很抱歉,您從來沒排除(或豁免)、抽中過這個籤號。********\n')
                                time.sleep(0.5)
                            else:
                                result_num.remove(str(erase_num))
                                print(' YES! Good Job. 已刪除該籤號囉~')
                    erase_again()
                else:
                    pass




                
                if no_nextnum == "insert" or no_nextnum == "in":
                    while True:
                        insert = input('please insert a number you wanna exclude from or type 「out」:')
                        if insert.isdigit() == False:
                            pass
                        else:
                            if int(insert) >= int(catlog1) and int(insert) <= int(catlog2):
                                if str(insert) not in result_num:
                                    sec_in.append(int(insert))
                                    result_num.append(str(insert))
                                else:
                                    sec_in.append(int(insert))
                            else:
                                pass
                        if insert == 'out':
                            break
                        else:
                            pass
                
                else:
                    pass



                if no_nextnum == "sec" or no_nextnum == "section":
                    while True:
                        section_again = input("please press 「Enter」to define the initial and final numbers of the section \n you'd like to exclude from...(or type 「out」)...")
                        time.sleep(0.5)
                        if section_again == 'out':
                            break
                        else:
                            def sec_repeat():
                                insert1 = input('please input the initial number of the section:')
                                insert2 = input('please input the final number of the section:')
                                
                                if insert1.isdigit() == True and insert2.isdigit() == True:
                                    if int(insert2) > int(insert1):                                        
                                        if int(insert2) > int(catlog2) or int(insert1) < int(catlog1):
                                            time.sleep(0.5)
                                            print('很抱歉,你的非除籤號區段範圍超過囉~請重新輸入。\n')
                                            time.sleep(0.5)
                                            sec_repeat()
                                        else:                                            
                                            for sec_insert in range (int(insert1), int(insert2)+1,1):
                                                literal = str(sec_insert)
                                                if literal not in result_num:
                                                    sec_in.append(int(sec_insert))
                                                    result_num.append(literal)
                                                else:
                                                    sec_in.append(int(sec_insert))
                                    else:
                                        sec_repeat()
                
                                else:
                                    pass
                            sec_repeat()
                              
                        
                if (no_nextnum == "n" or no_nextnum == "N") or no_nextnum == "no":
                    print(title_guess_over)
                    no_ans2 = '印出你剛剛的排除(即豁免)的籤號囉~'
                    print(no_ans2)
                    time.sleep(1)
                    print(sec_in)
                    print('\n')
                    time.sleep(1)
                    
                    file_result_num = open ('育賢抽抽樂抽籤結果.txt', 'a')
                    localtime = time.asctime(time.localtime(time.time()))
                    file_result_num.write(str(localtime))                    
                    file_result_num.write(str(result_num))                    
                    file_result_num.close()
                    
                    title_sort = '將所有早先已抽出、已排除及現在才抽出之籤號依大小排列一下吧:'
                    print(title_sort)
                    time.sleep(0.5)
                    
                    result_revised = []

                    len_result_num = len(result_num)
                    for new_result_num in result_num:
                        result_revised.append(int(new_result_num))

                    print(sorted(result_revised))


                    if len(sec_in) == 0:
                        print('\n依抽到籤號的先後,依序列出:\n', result_num)
                        print('\n')
                        time.sleep(0.5)
                    else:
                        print('\n依抽到籤號的先後,依序列出:')
                        for remove_sec_in in sec_in:
                            if str(remove_sec_in) in result_num:
                                result_num.remove(str(remove_sec_in))
                        print(result_num)
                        print('\n')

                    for revised_remove in sec_in:
                        if revised_remove in result_revised:
                            result_revised.remove(revised_remove)
                        else:
                            pass
                    print('【抽籤結果】僅就本次抽出之籤號依大小排序:\n',sorted(result_revised))
                            

                   
##                    for num_check in result_sort:
##                        if int(num_check) < 10:
##                            num_checked = '0' + str(num_check)
##                            result_revised.append(num_checked)
##                        else:
##                            result_revised.append(num_check)                            
##                            
##                    print(sorted(result_revised))

            
                    file_result_revised = open('育賢抽抽樂抽籤結果.txt', 'a')
                    localtime = time.asctime(time.localtime(time.time()))
                    file_result_revised.write(str(localtime))
                    file_result_revised.write(str(result_revised))
                    file_result_revised.close()
             
                    
                else:
                    if random_result in result_num:
                        guess_again()
                    else:                  
                        result_num.append(random_result)             
                        print (response_result)
                        time.sleep(0.5)
                        guess_again()

                    
        else:
            time.sleep(0.5)
            print(title_guess_over)
            time.sleep(0.5)
            no_ans2 = '印出你剛剛已排除(即豁免)的籤號囉~'
            print(no_ans2)
            time.sleep(0.5)
            print(sec_in)
            print('\n')
            time.sleep(0.5)
##            print(result_num)


            file_result_num = open ('育賢抽抽樂抽籤結果.txt', 'a')
            localtime = time.asctime(time.localtime(time.time()))
            file_result_num.write(str(localtime))                    
            file_result_num.write(str(result_num))                    
            file_result_num.close()
            
            time.sleep(0.5)            
            title_sort = '將所有早先已抽出、已排除及現在才抽出之籤號依大小排列一下吧:'
            print(title_sort)
            time.sleep(0.5)
            result_sort = sorted(result_num)
            
            result_revised = []

            len_result_num = len(result_num)
            for new_result_num in result_num:
                result_revised.append(int(new_result_num))

            print(sorted(result_revised))


            if len(sec_in) == 0:
                print('\n依抽到籤號的先後,依序列出:\n', result_num)
                print('\n')
                time.sleep(0.5)
            else:
                print('\n依抽到籤號的先後,依序列出:')
                for remove_sec_in in sec_in:
                    if str(remove_sec_in) in result_num:
                        result_num.remove(str(remove_sec_in))
                print(result_num)
                print('\n')
    

            

            for revised_remove in sec_in:
                if revised_remove in result_revised:
                    result_revised.remove(revised_remove)
                else:
                    pass
            print('【抽籤結果】僅就本次抽出之籤號依大小排序:\n',sorted(result_revised))
                            

            
##            result_revised = []
##            for num_check in result_sort:
##                if int(num_check) < 10:
##                    num_checked = '0' + str(num_check)
##                    result_revised.append(num_checked)
##                else:
##                    result_revised.append(num_check)
##            time.sleep(0.5)
##            print(sorted(result_revised), '\n')
            
            file_result_revised = open('育賢抽抽樂抽籤結果.txt', 'a')
            localtime = time.asctime(time.localtime(time.time()))
            file_result_revised.write(str(localtime))
            file_result_revised.write(str(result_revised))
            file_result_revised.close()
             

##        time.sleep(0.5)
##        print(title_guess_again)
##        time.sleep(0.5)      
##        title_again ='還想再抽抽樂一下嗎?'        
##        time.sleep(0.5)
##        title_askagain = "若是還想請鍵入y(預設),若不想,就請鍵入n(或N):"       
##        ans_askagain = str(input(title_askagain))
##        
##        if ans_askagain == 'n' or  ans_askagain == 'N':
##            no_ans1 = '好的,沒問題,那就就結束囉'
##            print(no_ans1)
##            time.sleep(1)                
##        elif ans_askagain == 'y' or  ans_askagain == 'Y':
##            yes_ans = '開始再抽囉~'
##            print(yes_ans)
##            maxmin()
##        else:
##            yes_ans = '謝謝再次光臨囉~'
##            print(yes_ans)

    guess_again()
    
maxmin()

print('\n')
import time
time.sleep(0.5)
def cross_head():
    print('\n來吧~一起玩玩不一樣的~\n請問你準備好製作多少乘多少的乘法表了嗎?!')
    import time
    time.sleep(1)
    text_start = '\n好的,準備開始囉~\n'
    time.sleep(0.5)
    print(text_start)
    time.sleep(0.5)
    text_input1 = '請輸入多少乘多少的第一個數字:'
    text_input2 = '請輸入多少乘多少的第二個數字:'
    text_space = '   '
    def cross(input1,input2):
      if input1.isdigit() == True or input2.isdigit() == True: 
        for i in range(1,int(input1)+1):
            text_sum = ''
            for j in range(1,int(input2)+1):         
                text_cross = str(i) + '*' + str(j) + '=' + str(i*j) + text_space
                
                text_sum = text_sum + text_cross
            import time
            time.sleep(0.1)
            print(text_sum,'\n')
        def again():
          choice = input("想要再玩一次嗎?y(yes) or n(no):")
          if choice == ("n" or "no"):
            print('~ bye ~')    
          else:
            cross(input(text_input1),input(text_input2))
        again()
      else:
        import time
        time.sleep(0.5)
        print('\n【警告】請務必輸入數字喔~')
        import time
        time.sleep(0.5)
        cross(input(text_input1),input(text_input2)) 

    cross(input(text_input1),input(text_input2))
    
    def again2():
      choice = input('再確認一次~想要再玩一次嗎?y(yes) or n(no):')
      if choice == ("n" or "no"):
        print('~ bye ~')    
      else:
        cross(input(text_input1),input(text_input2))
    again2()

text_welcome = '~ 歡迎光臨 新竹市立育賢國民中學 ~'
text_design = '設計者:教務處資訊教育組葉日宏'
text_empty0 = '  '

text_empty = '      '
copy_right = '版權所有'
text_sayby = '再見,下次再查囉~ 來玩玩其他程式吧~'
text_title = text_welcome + text_empty  + text_design + text_empty0 + copy_right
text_search_item = '請問您要開始查詢育賢gmail帳號了嗎?'
text_choice = "\n請輸入您要查詢的項目數字:\n 1、育賢學生gmail帳號\t2、育賢教職員…\t      3、育賢校友…\t\n 4、再回到「育賢抽抽樂」吧…  5、我要去玩「最新數學程式---多少乘多少的乘法表」了\n 您的選項是:"
text_choice_1 = '1、育賢學生gamil帳號 查詢系統: '
text_input_error = '輸入錯誤,請再輸入一次好嗎,有勞囉~例如 J201或j201 \n'
text_input2_id = '請輸入您的身分證字號例如 J201或j201:'
text_input2_nonexist = '很抱歉,您輸入的身份證字號是錯的,請再輸入一次 例如 J201或j201...'
text_welcom_wait = '系統資料擴建增置中,請耐心等待\n'
text_searchagain = '\n請問還想再查詢其他資料嗎?\n若是,請按Y,若否請按N:'
text_entermany = '*********\t大德呀~您嘛幫幫忙,Enter鍵壓這麼多次,你累了嗎?!\t***********'
text_enter_2nd = '*********\t你(妳)已按Enter鍵兩次囉,吾佛心來著提醒您,回頭是岸啊~\t*********'
text_enter_warn = '【請按Enter鍵開始~但別按太多次喔~否則…呵呵呵…】\n'
text_enter_morethan2 = '*******哩來~哩來~你(妳)知道你(妳)按幾次Enter鍵了嗎:'
text_enter_time = '次了 |>.<| *******'

id_1_studentgmail = {'J201':'[email protected]', 'j201':'[email protected]'}
id_2_faculty = {'J201':'[email protected]', 'j201':'[email protected]'}
id_3_alumni = {'J201':'[email protected]', 'j201':'[email protected]'}
id_4_etc = {'J201':'[email protected]', 'j201':'[email protected]'}

search_result = '\n育賢gmail查詢結果:'

print(text_title)
print(text_search_item)
input(text_enter_warn)

num = 0

def count(num):        
    import time
    if num == 1:
        for wait in range(145,346546+122*2):
          wait += 1
        print(text_enter_2nd)
        input()
    elif num == 2:
        for wait in range(145,346546+122*2):
          wait += 1
        print(text_entermany)
        input()
    else:
        for wait in range(145,346546+122*2):
          wait += 1
        print(text_enter_morethan2,num,text_enter_time)
        input()

def choice(input_1):    
    if input_1 == "":
        print(text_input_error)
        global num
        num = int(num)
        num += 1
        count(num)
        return choice(str(input(text_choice)))  
    elif input_1 == "1":        
        return search_gmail.searchgmail(str(input(text_input2_id)))
    elif input_1 == "2":
        input(text_welcom_wait)
        return choice(str(input(text_choice)))
    elif input_1 == "3":
        input(text_welcom_wait)
        return choice(str(input(text_choice)))            
    elif input_1 == "4":
        maxmin()
        choice(str(input(text_choice)))
    elif input_1 == "5":
        cross_head()
##        input(text_welcom_wait)
##        return choice(str(input(text_choice)))   
    else:
        input(text_sayby)
        cross_head()

def search_again(input_3):
    yesno = input_3
    if yesno == "Y" or yesno=="y":
        search_gmail.searchgmail(str(input(text_input2_id)))
    print(text_sayby)

class search_gmail:
    id_gmail = id_1_studentgmail
    def searchgmail(input_2):
        if input_2 not in search_gmail.id_gmail:
            print(text_input2_nonexist)
            search_gmail.searchgmail(str(input(text_input2_id)))
        else:
            print(search_result)
            for wait in range(1,122*2):
                wait += 1
            import time
            time.sleep(1)
            print(search_gmail.id_gmail[input_2])
            for wait in range(656,2333*3):
                wait += 1
            time.sleep(1)
            search_again(str(input(text_searchagain)))         



choice(str(input(text_choice)))