100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
oplossingen extra oefeningen programmeren python dawynt dodona H7: More functions $3.75   Add to cart

Other

oplossingen extra oefeningen programmeren python dawynt dodona H7: More functions

 11 views  0 purchase
  • Course
  • Institution
  • Book

Oplossingen extra oefeningen dodona voor vak programmeren python van peter dawnyt ugent, reeks 7: geavanceerde functies

Preview 2 out of 14  pages

  • June 12, 2024
  • 14
  • 2023/2024
  • Other
  • Unknown
avatar-seller
H7: MORE ABOUT FUNCTIONS & MODULES

Dawkins’ wezel
from random import choice

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))

assert 0 < punt < n, "ongeldig crossoverpunt"


string1_deel2 = string1[punt:]
string2_deel2 = string2[punt:]
string1_deel1 = string1[:punt]
string2_deel1 = string2[:punt]

woord1 = string1_deel1 + string2_deel2
woord2 = string2_deel1 + string1_deel2
return (woord1,woord2)

Obscure feestdagen




fi

, 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

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

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

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.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

67474 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$3.75
  • (0)
  Add to cart