def tness(string1,string2):
assert len(string1) == len(string2), "strings moeten even lang zijn"
counter = 0
for i in range(len(string1)):
if string1[i] == string2[i]:
counter += 1
return counter
def mutatie(string, mutaties= 1):
#mutaties = optionele parameter met default waarde 1
n = len(string)
assert int(mutaties) <= n, "ongeldig aantal mutaties"
alfabet =
["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","
Y","Z"," "]
posities_vervangen = []
while len(posities_vervangen) != mutaties:
keuze = choice(range(n))
if keuze not in posities_vervangen:
posities_vervangen.append(keuze)
antwoord = ""
for i in range(n):
if i in posities_vervangen:
vervangen = string[i]
if vervangen in alfabet:
alfabet.remove(vervangen)
antwoord += choice(alfabet)
else:
antwoord += string[i]
return antwoord
def crossover(string1,string2, punt= None):
n = len(string1)
assert len(string1) == len(string2), "strings moeten even lang zijn"
if punt is None:
punt = choice(range(1,n))
, import datetime
from datetime import date,timedelta
def pidag(datum):
dag = datum.day
maand = datum.month
if dag == 14 and maand == 3:
return True
return False
def vierkantsworteldag(datum):
jaar = datum.year
laatste2 = int(str(jaar)[2:])
dag = datum.day
maand = datum.month
if maand ** 2 == laatste2 and dag ** 2 == laatste2:
return True
return False
def liftdag(datum):
maand = datum.month
weekdag = datum.weekday()
dag = datum.day
if maand == 7 and weekdag == 4 and dag > 24:
return True
return False
def volgende_feestdag(feestdag,datum=date.today(), zelf=False):
if zelf is False:
datum += timedelta(1)
while not feestdag(datum):
datum += timedelta(1)
return datum
Five up
def is_geldige_kaart(kaart):
if isinstance(kaart,str) is False:
return False
kleuren = "SCDH"
rangen = "2345678910JQKA"
kleur = kaart[-1]
rang = kaart[:-1]
if rang.isdigit():
if kleur.upper() in kleuren and rang in rangen:
return True
else:
return False
elif rang.isupper() and kleur.isupper():
if kleur in kleuren and rang in rangen:
return True
else:
return False
elif rang.islower() and kleur.islower():
if kleur in kleuren.lower() and rang in rangen.lower():
return True
else:
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller hannahmeuleman. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.75. You're not tied to anything after your purchase.