diff --git a/Dice_Percentage.py b/Dice_Percentage.py new file mode 100644 index 0000000..88ec547 --- /dev/null +++ b/Dice_Percentage.py @@ -0,0 +1,9 @@ +import random +dice = [0, 0, 0, 0, 0, 0] +y= int(input("which number's percentage:")) +for i in range(5000): + x = random.randrange(1, 7) + dice[x-1]+=1 # counting numbers +percentage= dice[y-1]/5000*100 # finding the percentage of number +print("Percentage of throws of value ", y, "=", percentage, "%" ) + diff --git a/Password.py b/Password.py new file mode 100644 index 0000000..c6903ba --- /dev/null +++ b/Password.py @@ -0,0 +1,23 @@ +import re +password= input("Input your password: ") +val = True +while True: + if (len(password)<6 or len(password)>12): #this is password rule + raise ValueError("Not a Valid Password") # if there is an error,it will show error message + break + elif not re.search("[a-z]",password): #this is password rule + raise ValueError("Not a Valid Password") + break + elif not re.search("[0-9]",password): #this is password rule + raise ValueError("Not a Valid Password") + break + elif not re.search("[A-Z]",password): #this is password rule + raise ValueError("Not a Valid Password") + break + elif not re.search("[$#@]",password): #this is password rule + raise ValueError("Not a Valid Password") + break + else: + print("Valid Password") + val = False + break \ No newline at end of file diff --git a/The_Greatest_Common_Divisor.py b/The_Greatest_Common_Divisor.py new file mode 100644 index 0000000..968eee0 --- /dev/null +++ b/The_Greatest_Common_Divisor.py @@ -0,0 +1,27 @@ +'''## 4. The Greatest Common Divisor +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 commond(): + liste = [] + try: + number =int(input("number of inputs: ")) #Ask user the enter the number of inputs (n). + + except Exception: + print("de not enter Nan or non numerical inputs") + + else: + for i in range(number): + j = int(input("enter the number :")) #Ask user to enter `n` input numbers one by one + liste.append(j) + return print(math.gcd(*liste)) #Calculate the greatest common divisor (GCD) of `n` numbers +commond() + diff --git a/__pycache__/my_dice.cpython-39.pyc b/__pycache__/my_dice.cpython-39.pyc new file mode 100644 index 0000000..fbd5db0 Binary files /dev/null and b/__pycache__/my_dice.cpython-39.pyc differ diff --git a/main.py b/main.py new file mode 100644 index 0000000..8851d6a --- /dev/null +++ b/main.py @@ -0,0 +1,4 @@ +import my_dice # calling the new module my_dice +repetition = int(input("entre repetition number:")) # getting an input from the user using "Enter repetition number: +number = int(input("which number's percentage:")) # getting an input from the user for using "which number's percentage:" +print("The probability of",number,"is", my_dice.rollDice(repetition, number), "%") \ No newline at end of file diff --git a/my_dice.py b/my_dice.py new file mode 100644 index 0000000..cf2293c --- /dev/null +++ b/my_dice.py @@ -0,0 +1,10 @@ +def rollDice(repetition, number): + import random + dice = [0, 0, 0, 0, 0, 0] + + for i in range(repetition): + j = random.randrange(1, 7) + dice[j-1]+=1 # counting repetitions + percentage= dice[number-1]/repetition*100 # finding the percentage of repetition + return percentage +