diff --git a/Password.py b/Password.py new file mode 100644 index 0000000..1030d22 --- /dev/null +++ b/Password.py @@ -0,0 +1,36 @@ +"""Write a Python program to check the validity of a password (input from users) + +Rules : + +At least 1 letter between [a-z] and 1 letter between [A-Z] +At least 1 number between [0-9]. +At least 1 character from [$#@]. +Minimum length 6 characters. +Maximum length 16 characters. +If password is not valid throw ValueError with a proper error message +for each rule. If the password is valid print a success message. +Use some from raise, except, assert, else and finally keywords.""" + + +import re +p= input("Input your password :") +x = True +while x: + if (len(p)<6 or len(p)>16): + raise ValueError ("Length has to be between 6-16 characters.") + elif not re.search("[a-z]",p): + raise ValueError('You have to "$","#","@"') + elif not re.search("[0-9]",p): + raise ValueError("You should use at least one digit number.") + elif not re.search("[A-Z]",p): + raise ValueError("A capital letter must be used.") + elif not re.search("[$#@]",p): + raise ValueError("A symbol must be used.") + + else: + print("Valid Password") + x=False + break + +print("\n Your password is : ",p) + \ No newline at end of file diff --git a/TheGcd.py b/TheGcd.py new file mode 100644 index 0000000..b1d1092 --- /dev/null +++ b/TheGcd.py @@ -0,0 +1,38 @@ +"""As a user, I want to use a program which can calculate the greatest common divisor (GCD) of my inputs. + +Acceptance Criteria: + +Ask user the enter the number of inputs (n). +Ask user to enter n input numbers one by one. +Use try/except blocks to verify input entries and warn the user for Nan or non numerical inputs. +Calculate the greatest common divisor (GCD) of n numbers. +Use gcd function in module of math.""" + + +import math +def TheGCD(): + i=0 + + n = int(input("Enter number of elements : ")) + lst=[] + if n<0: + raise ValueError("Number of elements must be higher than zero") + else: + while i