From c9560b3845f86af51f34b3fd9e788d24309ad6a0 Mon Sep 17 00:00:00 2001 From: hopeful11 <77275763+hopeful11@users.noreply.github.com> Date: Thu, 7 Oct 2021 16:23:33 +0200 Subject: [PATCH 1/2] week-4 --- gcd.py | 19 +++++++++++++++++++ password.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 gcd.py create mode 100644 password.py diff --git a/gcd.py b/gcd.py new file mode 100644 index 0000000..7e47baf --- /dev/null +++ b/gcd.py @@ -0,0 +1,19 @@ +from math import gcd +from functools import reduce +def inputs(): + try: + global x,y + x=int(input("please,enter your first number:")) + y=int(input("please enter your second number:")) + except ValueError: + print("Please enter your number") + +def Gcd(): + return gcd(x,y) + +if __name__ == '__main__': + inputs() + + +print(Gcd()) + diff --git a/password.py b/password.py new file mode 100644 index 0000000..ed0bd6b --- /dev/null +++ b/password.py @@ -0,0 +1,29 @@ +import re +password=input("Şifre giriniz:") +def Password(password): + x=True + while x: + if len(password)<6 or len(password)>16 : + raise ValueError("Password has to between 6-16 characters.") + elif not re.search("[a-z]",password): + raise ValueError ("Password must have at least 1 letter between [a-z]") + elif not re.search("[A-Z]",password): + raise ValueError("Password must have at least 1 letter between [A-Z]") + elif not re.search("[0-9]",password): + raise ValueError("Password must have at least 1 number between [0-9]") + elif not re.search("[$#@]",password): + raise ValueError("Password must have at least 1 charachter between [$#@]") + else: + print("Congratulations,Valid Password") + x=False + break + +try: + Password(password) + +except ValueError as V : + print(V) + +finally: + print("Don't give up") + From 041270cb8fb55e26a9517012f391aa6df826a85b Mon Sep 17 00:00:00 2001 From: hopeful11 <77275763+hopeful11@users.noreply.github.com> Date: Tue, 16 Nov 2021 22:01:10 +0100 Subject: [PATCH 2/2] week-4 --- basic_import.py | 4 ++++ dice.py | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 basic_import.py create mode 100644 dice.py diff --git a/basic_import.py b/basic_import.py new file mode 100644 index 0000000..c6b3439 --- /dev/null +++ b/basic_import.py @@ -0,0 +1,4 @@ +import dice +ddice=dice.rollDice(int(input("Enter repetition number: "))) +for i in range(len(ddice)): + print("The probability of {} is {}%".format(i+1,ddice[i])) \ No newline at end of file diff --git a/dice.py b/dice.py new file mode 100644 index 0000000..9dae833 --- /dev/null +++ b/dice.py @@ -0,0 +1,7 @@ +from random import randint +def rollDice(number): + dice=[0,0,0,0,0,0] + for i in range(1,5001): + dice[randint(1,6)-1]+=1 + for i in range(6): + print('Percentage of throws of value {} =: {:.2%}'.format((i+1),(dice[i]/5000)))