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
21 changes: 21 additions & 0 deletions Gcd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from math import gcd
import math
numbers = []
n = int(input("how many numbers?:"))
count=0
while True:
count+=1
if count==n+1:
break
try:
number=int(input("enter numbers"))
numbers.append(int(number))
except ValueError:
print("Enter a valid number")
count-=1
print(math.gcd(*numbers))





4 changes: 4 additions & 0 deletions basic_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import my_dice
dice=my_dice.rollDice(int(input("Enter repetition number: ")))
for i in range(len(dice)):
print("The probability of {} is {}%".format(i+1,dice[i]))
28 changes: 28 additions & 0 deletions dice_percentage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import array as arr
import random
dice = arr.array('i',[0,0,0,0,0,0])
count=0
while True:
x= random.randint(1,6)
count+=1
if count== 5001:
break
elif x==1:
dice[0]+=1
elif x==2:
dice[1]+=1
elif x==3:
dice[2]+=1
elif x==4:
dice[3]+=1
elif x==5:
dice[4]+=1
elif x==6:
dice[5]+=1
sum=dice[0]+dice[1]+dice[2]+dice[3]+dice[4]+dice[5]
print("Percentage of throws of value 0:",(dice[0]/sum)*100)
print("Percentage of throws of value 1:",(dice[1]/sum)*100)
print('Percentage of throws of value 2:',(dice[2]/sum)*100)
print("Percentage of throws of value 3:",(dice[3]/sum)*100)
print("Percentage of throws of value 4:",(dice[4]/sum)*100)
print("Percentage of throws of value 5:",(dice[5]/sum)*100)
7 changes: 7 additions & 0 deletions my_dice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from random import randint
def rollDice(number):
dice=[0]*6 #[0,0,0,0,0,0]
for i in range(number):
dice[randint(1,6)-1]+=1 #specify the index => [randint(1,6)-1]
dice=[round((dice[i]/number)*100,2) for i in range(len(dice))]
return dice
23 changes: 23 additions & 0 deletions password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import re
def password_validity():
password = input("enter a valid password")

charRegex = re.compile(r'(\w{6,16})')
lowerRegex = re.compile(r'[a-z]+')
upperRegex = re.compile(r'[A-Z]+')
digitRegex = re.compile(r'[0-9]+')
chaRegex = re.compile(r'[#@$]+')

if charRegex.findall(password)== []:
raise ValueError('The password must be between 6 and 16 characters.')
elif lowerRegex.findall(password)==[]:
raise ValueError('There should be lowercase letter.')
elif upperRegex.findall(password)==[]:
raise ValueError('There should be uppercase letter.')
elif digitRegex.findall(password)==[]:
raise ValueError('There should be at least one digit.')
elif chaRegex.findall(password)==[]:
raise ValueError('There should be at least one of the shown special symbols.')
else:
print('Valid password')
password_validity()