forked from Show-Me-the-Code/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0001.py
More file actions
38 lines (32 loc) · 881 Bytes
/
0001.py
File metadata and controls
38 lines (32 loc) · 881 Bytes
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
# coding:utf-8
# Python Requirement:3
# Made by EnderSodium ender@enderself.co
# 第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?
import random
# Generate alphabetical stuff
def gene_let(code):
randomnum = random.randint(65,90)
temp = chr(randomnum)
return code + temp
# Generate numerical stuff
def gene_num(code):
temp = str(random.randint(0,9))
return code + temp
def generate():
code = ''
code = gene_let(code)
code = gene_num(code)
code = gene_num(code)
code = gene_let(code)
code = gene_num(code)
code = gene_let(code)
code = gene_num(code)
code = gene_num(code)
code = gene_let(code)
code = gene_num(code)
print code
def main():
for i in range(199):
generate()
if __name__ == '__main__':
main()