diff --git a/Rolldice.py b/Rolldice.py new file mode 100644 index 0000000..74eebbc --- /dev/null +++ b/Rolldice.py @@ -0,0 +1,25 @@ +#dice percentage +import random + +def percent(number): + dice=[0,0,0,0,0,0]# I created an array with 6 elements named dice and I filled this array with the value zero. + n=5000 + for i in range(n): + number=random.randint(1,6)# It will generate a random number with a value between 1 and 6 in a repetition 5000 times. + if number==1:#If the value is 1, increase the element 0 in the array by 1 + dice[0]+=1 + elif number==2:#It is the same for each numbers + dice[1]+=1 + elif number==3: + dice[2]+=1 + elif number==4: + dice[3]+=1 + elif number==5: + dice[4]+=1 + else: + dice[5]+=1 + percentage=dice[number-1]/n*100 #At the end of the repetition i calculated percentages with 2 decimal places. + return percentage # I wanted to return percentage + + +print("Percentage of throws of value","4","=",percent(4),"%") #I wrote it to the screen diff --git a/gcd1.py b/gcd1.py new file mode 100644 index 0000000..707040c --- /dev/null +++ b/gcd1.py @@ -0,0 +1,23 @@ +# a program which can calculate the greatest common divisor (GCD) of my inputs. +import math +def gcd(): + count=int(input("How many numbers do you want to enter: "))#I asked the number of the enters + numbers=[] #I opened a new list with the name numbers. + + a=0 + while a12): #I asked all of the requirements + raise ValueError("The length of the password is not valid")#If there is a not valid enter,it will raise a error in each situation. + break + elif not re.search("[a-z]",p): + raise ValueError("There is no lower case in your password") + break + elif not re.search("[0-9]",p): + raise ValueError("There is no number in your password") + break + elif not re.search("[A-Z]",p): + raise ValueError("There is not a upper case in your password") + break + elif not re.search("[$#@]",p): + raise ValueError("There is not a special character in your password") + break + + else: + print("Valid Password")#If all of the possibilities are true, it will write valid password to the screen. + x=False + break \ No newline at end of file