From 9d616c1bc80de6f5302d9918fee3f158fc91da80 Mon Sep 17 00:00:00 2001 From: ziad-jradeh Date: Mon, 30 Jan 2023 01:52:33 +0100 Subject: [PATCH 1/3] solved --- .idea/.gitignore | 0 .idea/Class8-Python-Module-Week3.iml | 12 +++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 38 +++++++ answer-1.py | 28 +++++ answer-2.py | 15 +++ answer-3.py | 30 ++++++ answer-4/GUI.py | 65 ++++++++++++ .../password_generator.cpython-310.pyc | Bin 0 -> 1072 bytes answer-4/password_generator.py | 37 +++++++ answer-4/psw.png | Bin 0 -> 10687 bytes bonus.ipynb | 99 ++++++++++++++++++ 15 files changed, 348 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Class8-Python-Module-Week3.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 answer-1.py create mode 100644 answer-2.py create mode 100644 answer-3.py create mode 100644 answer-4/GUI.py create mode 100644 answer-4/__pycache__/password_generator.cpython-310.pyc create mode 100644 answer-4/password_generator.py create mode 100644 answer-4/psw.png create mode 100644 bonus.ipynb diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.idea/Class8-Python-Module-Week3.iml b/.idea/Class8-Python-Module-Week3.iml new file mode 100644 index 0000000..8b8c395 --- /dev/null +++ b/.idea/Class8-Python-Module-Week3.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8432ad0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5414e14 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..43f2988 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + 1675035392263 + + + + \ No newline at end of file diff --git a/answer-1.py b/answer-1.py new file mode 100644 index 0000000..2fc0422 --- /dev/null +++ b/answer-1.py @@ -0,0 +1,28 @@ + +row_number = 0 + +def print_pascal_triangle(n): + ''' A recursive function to print the first n rows of Pascal triangle. + + Returns the the nth row as a list of integers. ''' + + # initialize the first row as a list of 1s of size n. + row = [1] * n + + # The base condition of the recursion, when n is 1. + if n == 0: + return [1] + else: + previous_row = print_pascal_triangle(n - 1) + + # calculate the row valuse except the first and last values as they are always 1. + for i in range(1, n - 1): + row[i] = previous_row[i-1] + previous_row[i] + + # print the current row. + print(" " * (row_number - n), end="") + print(row) + return row + +row_number = int(input('Enter the numbers of rows from Pascal triangle you want to print: ')) +print_pascal_triangle(row_number) diff --git a/answer-2.py b/answer-2.py new file mode 100644 index 0000000..5b864e7 --- /dev/null +++ b/answer-2.py @@ -0,0 +1,15 @@ + +# Allow the user to input the sequence. +input_sequence = input("Enter the input sequence as words seperated by a hyphen: ") + +# Make a list of the words in the input sequence. +list_sequence = input_sequence.split("-") + +# Sort the words in the list. +list_sequence.sort() + +# Join the words in the list with a hyphen. +output_sequence = "-".join(list_sequence) + +# Print the output sequence. +print(output_sequence) diff --git a/answer-3.py b/answer-3.py new file mode 100644 index 0000000..01e606f --- /dev/null +++ b/answer-3.py @@ -0,0 +1,30 @@ + +def is_perfect_number(number): + ''' A function to check if a number is a perfect number. + + Returns True or False. ''' + + # If the number is negative or 0, return False. + if number <= 0: + return False + + # Calculating the divisors of the number. + divisors = [1] + for i in range(2, number): + if number % i == 0: + divisors.append(i) + + # Calculating the sum of the divisors and checking if the number is equal to the sum of its divisors. + sum_of_divisors = sum(divisors) + if number == sum_of_divisors: + return True + else: + return False + + +number = int(input("Enter a number to check if it's a perect number: ")) + +if is_perfect_number(number): + print (f"Number {number} is a perfect number") +else: + print (f"Number {number} is not a perfect number") \ No newline at end of file diff --git a/answer-4/GUI.py b/answer-4/GUI.py new file mode 100644 index 0000000..fa966e2 --- /dev/null +++ b/answer-4/GUI.py @@ -0,0 +1,65 @@ + +import password_generator +import tkinter as tk +import os + +current_path = os.path.dirname(os.path.realpath(__file__)) + +def generate_btn_handler(): + """ A function to handle the press event of the generate button """ + + # Getting the values entered by the user + lower_case_letters = int(lower_case_entry.get()) + upper_case_letters = int(upper_case_entry.get()) + numbers = int(numbers_entry.get()) + special_chars = int(special_chars_entry.get()) + + # Creating the password from the values entered by the user using the password_generator module from password_generator.py + password = password_generator.Generate_random_password(lower_case_letters, upper_case_letters, numbers, special_chars) + + # Clearing the password field and displaying the generated password + password_field.config(state="normal") + password_field.delete(0, tk.END) + password_field.insert(0, password) + password_field.config(state="readonly") + + +# Creating the main window +screen = tk.Tk() +screen.title("Password Generator") +canvas = tk.Canvas(screen, width=500, height=450) +canvas.pack() + +# Displaying the logo image +logo = tk.PhotoImage(file = current_path + "\psw.png") +logo = logo.subsample(3, 3) +canvas.create_image(250, 90, image = logo) +canvas.create_text(250, 200, text = "How would you like your password?", font=("Arial", 17, "bold"), fill= "#556080") + +canvas.create_text(250, 250, text = "Lower-case Letters: ", font = ("Arial", 11, "bold"), anchor="e", fill= "#556080") +canvas.create_text(250, 270, text = "Upper-case Letters: ", font = ("Arial", 11, "bold"), anchor="e", fill= "#556080") +canvas.create_text(250, 290, text = "Numbers: ", font = ("Arial", 11, "bold"), anchor="e", fill= "#556080") +canvas.create_text(250, 310, text = "Special Letters: ", font = ("Arial", 11, "bold"), anchor="e", fill= "#556080") + +# Entry boxes for the password generation options with default values of 3 +lower_case_entry, upper_case_entry, numbers_entry, special_chars_entry = tk.Entry(screen), tk.Entry(screen), tk.Entry(screen), tk.Entry(screen) +lower_case_entry.insert(0, 3) +canvas.create_window(250, 250, window = lower_case_entry, anchor="w") +upper_case_entry.insert(0, 3) +canvas.create_window(250, 270, window = upper_case_entry, anchor="w") +numbers_entry.insert(0, 3) +canvas.create_window(250, 290, window = numbers_entry, anchor="w") +special_chars_entry.insert(0, 3) +canvas.create_window(250, 310, window = special_chars_entry, anchor="w") + +# Create the generate button handler function and assignment to it to gen +generate_btn = tk.Button(screen, text = "Generate Password", command = generate_btn_handler, relief="groove") +generate_btn.config(fg="#556080", font=("Arial", 15)) +canvas.create_window(250, 350, window = generate_btn) + +# creating the password field to display the generated password +password_field = tk.Entry(screen, font=("Arial", 20, "bold"), fg="#e4c05c", justify="center", relief="flat", state="readonly") +canvas.create_window(250, 410, window = password_field) + +screen.mainloop() + diff --git a/answer-4/__pycache__/password_generator.cpython-310.pyc b/answer-4/__pycache__/password_generator.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f5f4005224e7c732a35e4f67caa2446e4a98dddf GIT binary patch literal 1072 zcmZWo-BQy)6y9ypv~(yA%s4WP7mFfVrS%6?L_|udfEKJR6^y|cvfDP0CS^CVf~`0D z2tEK@`V2mZGr9H3SMbVBnog^n%=tEZzCC;PoZVw5lL^4Z8vChRQ2>7VlR**qWSJ|Q z=70f)CXfM+$Pf#11dFnOqq2zOSi-TdP>y0)2C1Rnd@a~InM9LUu1;N>zJ4Qh^VUo{ zb9>?O;*+JP%Wsvvck263?apU8ap&&6*}3}<9?n0KC$cNK)%>%y^^NB*3Y%Lmi?2%M z?aJ$&-8Zs4q3!FKRBLtP;LvPXcJqib$NkXyczmLZezZ_xe3ZE6xUz2?YM>)Jpbfsj zRj`-nMBCyibRwsMBc8!C2*HuWS$K|(hU`VoM$WNP$WC!qILF39c9zG9w|N}M%XT{C z|8=Cc#0wNT`GK;i>RP&E*cNhZR3jFlnnRF=sAgfiftng)Et}#@0&xi-tLvocFyzz; zvfRc#p~$Wxx7j2#t!s=RlQ<5cYzCQjt7~iZZP=(8+?nr=Sd-|6W+J_=QBC(<2BMUR z<5H^|rFRIVaYw`)YFM?52T}sbxv8+lEfOWZ~sbzN8lN+uQk4 z*-KW6#er#TtFpNg*vrLyZX;VzbL-hsS&p%~TdkVJ6Ax^|O2y>M-85CZss<^kewu2S z<{%ps;a_&N@7w)j@}<5hEP?8mfXSo1L{(yv2C*FGLBosptlt4m^0)M7S6@&njF(H1 z4Gk-+w(bUtl{LdzclVW?$uDg_T|9Q`ww2zrv1^j_4k3rLie@qYO6HW_o@#jIHqA7T zz45j10jS+Vs=Z}?cd~H~VtiN_gTt_|2_YefkY3?@[\]^_`{|}~""" +NUMBERS = """0123456789""" +UPPER_LETTERS = """ABCDEFGHIJKLMNOPQRSTUVWXYZ""" +LOWER_LETTERS = """abcdefghijklmnopqrstuvwxyz""" + + +def Generate_random_password(number_of_lower_case_letters = 0, number_of_upper_case_letters = 0, number_of_numbers = 0, number_of_special_chars = 0): + """ A function to generate a random password. + + Accepts the number of upper-case letters, lower-casw letters, digits and special characters. + + Returns the password as a string.""" + + # Initialize a list to store the password characters. + password_elements = [] + + # Adding the password characters to the list. + for i in range(number_of_lower_case_letters): + password_elements.append(random.choice(LOWER_LETTERS)) + for i in range(number_of_upper_case_letters): + password_elements.append(random.choice(UPPER_LETTERS)) + for i in range(number_of_numbers): + password_elements.append(random.choice(NUMBERS)) + for i in range(number_of_special_chars): + password_elements.append(random.choice(SPECIAL_CHARS)) + + # Shuffle the elements of the list. + random.shuffle(password_elements) + + # Convert the list to a string and return the final password string. + password = ''.join(password_elements) + return password + + \ No newline at end of file diff --git a/answer-4/psw.png b/answer-4/psw.png new file mode 100644 index 0000000000000000000000000000000000000000..e44f6f9e04602e0a3d13d931da2cf1b3e87202d5 GIT binary patch literal 10687 zcmcI}2{_bk+xInNEqfcXSJEQ1*%>WVcimC62oa%@>|28wDU_m!WG{uv64|#QTf!hR zma$};7>2RT472>-|8(E?bHCqve8>Ad&-WdV;~4+zIkr~)NbB!@p8E4?x^PG>6}E--wMEP{Zq$}Sojaj4WT=Sd{X*6 zl%&Mfi+G)S_rw*{Yh*Zd`N*v&mvrMPquRcDzHLYM6e`_!KUK!JVZ-NrN(kgS@w{H+ zAx>{wXmA4ZJe z(m%A{a^-xEr2jUhETA%fD(Yk~YSqs3@*;ks_Ilnp9}?V{`UsI)*0sd7&?eksZIx5x zSvvzXSML@o>%5f_LhF_&0_+;w2g;9iiGha4)8`4$DZ>=jwMG7BIbLAa-ia|^EST_W zF%{an*1gKSZdJG|UL;ve92gZG!$eQ~oZw8njS1&?2dC(#s-C9#ro!L?!Xex#PSwt1 z7+utvs3&F~c$io(!s#o3jM@bt3TN9Y4@ry{bV8#T^x{j3)oe=GBhwACQ-SvYa8h6~ zm0$R14ftG9L{61Vr0L>di0{Io`5mZREu$kt>SN|Y_=AGLj_?C>CXzFgHhnrwt?-mM zFOXu5E6iDqEY{&FD`SIFFycVteLeJ~rFy$2O9gX&bS{qvCf%xsaU6H%|C9)SQ?wJBrN9 z3yNGB^C|i_J3D?hx1c<#VIEDsTG!2@y)P=~_4S9?J#`{2t1U4T#OtT&83EJ}!Kjm* zSD%|Jw)Zz5=0So14c4WL8YeM5a?6;fRl(T#o!V8*xCV@Qodd4k2WCh#WTDQFiLJ3* z3zb%l@NR>rq25<5?O=@ou#00^OnFWmBBJ|su3v~bb*>xS$BRerR-w6DW9zg5dR}ly3E=nMkZL-y8eEy#u{y_h zX9MdVx1lG9q0nhli8tU)d*rs^cCDU*-{ztTYA``k5M(cjSCwE9W!0x_qhjUBaeT6& zZe=yFB^!Ye6gkh5BpV3n1en)H9S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*@;AsOzwKX)i<1=KX)BzWNPnJQ}A=u+8>-*Ysb!OzXKW>32{qb6WZVMa=DWAXD5)g z&+ScW%5%!CuW(IsABcqicpz$fX?=@J>X1FY|YGwVYllf8in(fC69 zkFQ8LbE&A{d=Wsy-kz3XJt>@b2u9^@vA9u^2W;QwG<@zt$H-T1f^$19?{f}*%GysJ zz8Kzb70C@(^2E0ZEj4j)WlC#ES}RMF`Q;ihi!4G*}B_&)*(celc62Og!1WSSMK{dUGVCRF{ z@Ywmvk0AS9!a0RIU#(rwaC?<@-3ERdgdgzy-{~dMZhkxCYQgQTtQnYAXB~i3rNqJ3TzmWZC}}^zGx1I%D{f z)z&Cns~X&!B7LGH$gt!W=;4;;7-q~1n+f1uO-vElznvx@SFU{k@zF|HHbM0_%E?qO zD$nC&QpG_ax0@UTPP5w3L`I@(A^=R~3s#7wMIwUN5GPsoK+toxVMH$4hGy>{skl1g%WZR#^ z=(OqKNG;#_c8@<^doQpr9+_45cU~NxpvPpyh#@*(WK_^Q>Av&tJluwwb0q%fQ#i8r q$Ul2Q|6ks-kpO-O__rU|9XP0rV$g-xH|PQI-znp>$McTb-TN Date: Mon, 30 Jan 2023 01:53:21 +0100 Subject: [PATCH 2/3] cleanup --- .idea/.gitignore | 0 .idea/Class8-Python-Module-Week3.iml | 12 ------ .../inspectionProfiles/profiles_settings.xml | 6 --- .idea/misc.xml | 4 -- .idea/modules.xml | 8 ---- .idea/vcs.xml | 6 --- .idea/workspace.xml | 38 ------------------- 7 files changed, 74 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/Class8-Python-Module-Week3.iml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/.idea/Class8-Python-Module-Week3.iml b/.idea/Class8-Python-Module-Week3.iml deleted file mode 100644 index 8b8c395..0000000 --- a/.idea/Class8-Python-Module-Week3.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 8432ad0..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 5414e14..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 43f2988..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - 1675035392263 - - - - \ No newline at end of file From 66a3c9a6a84e2ac255ebd4687710d69de1549156 Mon Sep 17 00:00:00 2001 From: ziad-jradeh Date: Mon, 30 Jan 2023 12:52:34 +0100 Subject: [PATCH 3/3] update and cleanup --- answer-1.py | 4 ++-- answer-3.py | 4 ++-- answer-4/GUI.py | 4 ++-- .../password_generator.cpython-310.pyc | Bin 1072 -> 0 bytes answer-4/password_generator.py | 6 +++--- bonus.ipynb | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 answer-4/__pycache__/password_generator.cpython-310.pyc diff --git a/answer-1.py b/answer-1.py index 2fc0422..377842c 100644 --- a/answer-1.py +++ b/answer-1.py @@ -6,7 +6,7 @@ def print_pascal_triangle(n): Returns the the nth row as a list of integers. ''' - # initialize the first row as a list of 1s of size n. + # initialize the row as a list of 1s of size n. row = [1] * n # The base condition of the recursion, when n is 1. @@ -20,7 +20,7 @@ def print_pascal_triangle(n): row[i] = previous_row[i-1] + previous_row[i] # print the current row. - print(" " * (row_number - n), end="") + print(" " * (row_number - n), end="") # padding print(row) return row diff --git a/answer-3.py b/answer-3.py index 01e606f..b0bd410 100644 --- a/answer-3.py +++ b/answer-3.py @@ -7,7 +7,7 @@ def is_perfect_number(number): # If the number is negative or 0, return False. if number <= 0: return False - + # Calculating the divisors of the number. divisors = [1] for i in range(2, number): @@ -27,4 +27,4 @@ def is_perfect_number(number): if is_perfect_number(number): print (f"Number {number} is a perfect number") else: - print (f"Number {number} is not a perfect number") \ No newline at end of file + print (f"Number {number} is NOT a perfect number") \ No newline at end of file diff --git a/answer-4/GUI.py b/answer-4/GUI.py index fa966e2..da2ec0e 100644 --- a/answer-4/GUI.py +++ b/answer-4/GUI.py @@ -39,7 +39,7 @@ def generate_btn_handler(): canvas.create_text(250, 250, text = "Lower-case Letters: ", font = ("Arial", 11, "bold"), anchor="e", fill= "#556080") canvas.create_text(250, 270, text = "Upper-case Letters: ", font = ("Arial", 11, "bold"), anchor="e", fill= "#556080") canvas.create_text(250, 290, text = "Numbers: ", font = ("Arial", 11, "bold"), anchor="e", fill= "#556080") -canvas.create_text(250, 310, text = "Special Letters: ", font = ("Arial", 11, "bold"), anchor="e", fill= "#556080") +canvas.create_text(250, 310, text = "Special Characters: ", font = ("Arial", 11, "bold"), anchor="e", fill= "#556080") # Entry boxes for the password generation options with default values of 3 lower_case_entry, upper_case_entry, numbers_entry, special_chars_entry = tk.Entry(screen), tk.Entry(screen), tk.Entry(screen), tk.Entry(screen) @@ -59,7 +59,7 @@ def generate_btn_handler(): # creating the password field to display the generated password password_field = tk.Entry(screen, font=("Arial", 20, "bold"), fg="#e4c05c", justify="center", relief="flat", state="readonly") -canvas.create_window(250, 410, window = password_field) +canvas.create_window(250, 400, window = password_field) screen.mainloop() diff --git a/answer-4/__pycache__/password_generator.cpython-310.pyc b/answer-4/__pycache__/password_generator.cpython-310.pyc deleted file mode 100644 index f5f4005224e7c732a35e4f67caa2446e4a98dddf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1072 zcmZWo-BQy)6y9ypv~(yA%s4WP7mFfVrS%6?L_|udfEKJR6^y|cvfDP0CS^CVf~`0D z2tEK@`V2mZGr9H3SMbVBnog^n%=tEZzCC;PoZVw5lL^4Z8vChRQ2>7VlR**qWSJ|Q z=70f)CXfM+$Pf#11dFnOqq2zOSi-TdP>y0)2C1Rnd@a~InM9LUu1;N>zJ4Qh^VUo{ zb9>?O;*+JP%Wsvvck263?apU8ap&&6*}3}<9?n0KC$cNK)%>%y^^NB*3Y%Lmi?2%M z?aJ$&-8Zs4q3!FKRBLtP;LvPXcJqib$NkXyczmLZezZ_xe3ZE6xUz2?YM>)Jpbfsj zRj`-nMBCyibRwsMBc8!C2*HuWS$K|(hU`VoM$WNP$WC!qILF39c9zG9w|N}M%XT{C z|8=Cc#0wNT`GK;i>RP&E*cNhZR3jFlnnRF=sAgfiftng)Et}#@0&xi-tLvocFyzz; zvfRc#p~$Wxx7j2#t!s=RlQ<5cYzCQjt7~iZZP=(8+?nr=Sd-|6W+J_=QBC(<2BMUR z<5H^|rFRIVaYw`)YFM?52T}sbxv8+lEfOWZ~sbzN8lN+uQk4 z*-KW6#er#TtFpNg*vrLyZX;VzbL-hsS&p%~TdkVJ6Ax^|O2y>M-85CZss<^kewu2S z<{%ps;a_&N@7w)j@}<5hEP?8mfXSo1L{(yv2C*FGLBosptlt4m^0)M7S6@&njF(H1 z4Gk-+w(bUtl{LdzclVW?$uDg_T|9Q`ww2zrv1^j_4k3rLie@qYO6HW_o@#jIHqA7T zz45j10jS+Vs=Z}?cd~H~VtiN_gTt_|2_YefkY3?@[\]^_`{|}~""" -NUMBERS = """0123456789""" -UPPER_LETTERS = """ABCDEFGHIJKLMNOPQRSTUVWXYZ""" -LOWER_LETTERS = """abcdefghijklmnopqrstuvwxyz""" +NUMBERS = "0123456789" +UPPER_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +LOWER_LETTERS = "abcdefghijklmnopqrstuvwxyz" def Generate_random_password(number_of_lower_case_letters = 0, number_of_upper_case_letters = 0, number_of_numbers = 0, number_of_special_chars = 0): diff --git a/bonus.ipynb b/bonus.ipynb index 00bc2c9..7bb614a 100644 --- a/bonus.ipynb +++ b/bonus.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 2, "metadata": {}, "outputs": [ {