Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Dice_Percentage.py
Original file line number Diff line number Diff line change
@@ -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, "%" )

23 changes: 23 additions & 0 deletions Password.py
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions The_Greatest_Common_Divisor.py
Original file line number Diff line number Diff line change
@@ -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()

Binary file added __pycache__/my_dice.cpython-39.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -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), "%")
10 changes: 10 additions & 0 deletions my_dice.py
Original file line number Diff line number Diff line change
@@ -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