-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPringlesCodeRandomizer.py
More file actions
100 lines (53 loc) · 2.59 KB
/
Copy pathPringlesCodeRandomizer.py
File metadata and controls
100 lines (53 loc) · 2.59 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
import random
import string
# Functions
# GetLote() is a function that generates the Lote serial number by parts, as shown below:
def getLote():
# First, we create a dynamic array to start pumping characters and numbers.
SerialLote = []
# The fist character in every Pringles can is always a letter "L", so its the first letter
# that is inserted
SerialLote.append("L")
# The next four characters are numbers that are randomly generated using the ranint(a,b)
# function, then toose numbers are converted to strings and placed in our initialy created
# array.
for i in range(4):
n = random.randint(0,9)
SerialLote.append(str(n))
# The next two caracters are uppercase lettes, also randomly generated. Don’t ask me about.
# the function that generates that because I stole that solution from StackOverflow.
for i in range(2):
character = string.ascii_uppercase
SerialLote.append( ''.join(random.choice(character) for i in range(1)))
# The next 6 characters are numbers, and as you thought, they are also randomly generated.
for i in range(6):
n = random.randint(0,9)
SerialLote.append(str(n))
# This portion of the code converts the previusly filled array into a string using the
# join() function.
separator = ""
finalCode = separator.join(SerialLote)
# Finally, it returns the string containing the Lote code.
return finalCode
# Similar to the previous function, this getExpirationDate() generates a randomly selected
# date between 2022 and 2023.
def getExpirationDate():
# We create the array that will store the date.
expirationDate = []
# Then we choose the expiration month, of course bewteen 01 and 12 because Undecimber does not exist.
monthDate = random.randint(1,12)
# This is important because if the month has only one digit. Then this code below places a 0 into the
# array to fullfill that space. Otherwise, the web will not accept the entered number.
if (monthDate <= 9):
expirationDate.append("0")
expirationDate.append(str(monthDate))
# Then we randomly generate the year. As I said, bewteen 2022 and 2023, you can change this is you want.
yearDate = random.randint(2022, 2023)
expirationDate.append(str(yearDate))
# And finally, this convert the array into a string to return it propely.
separator = ""
finalDate = separator.join(expirationDate)
return finalDate
# Just making sure the code works at this point.
print(getLote())
print(getExpirationDate())