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

Other

oplossingen extra oefeningen programmeren python dawynt dodona H5: functions

 13 views  0 purchase
  • Course
  • Institution
  • Book

Oplossingen extra gemaakte oefeningen in dodona op reeks 5 (functies). Programmeren van peter dawnyt ugent.

Preview 3 out of 19  pages

  • June 12, 2024
  • 19
  • 2023/2024
  • Other
  • Unknown
avatar-seller
H5: FUNCTIES

Kopzorgen voor Noach
def splitsing(woord):
klinkers = 'aeiouAEIOU'
pre x = ""
i=0
while woord[i] not in klinkers:
pre x += woord[i] #pre x van medeklinkers
i += 1
lengte_pre x = len(pre x)
su x = woord[lengte_pre x:]
return (pre x, su x)

def kruising(woord1,woord2):
pre x1, su x1 = splitsing(woord1)
pre x2, su x2 = splitsing(woord2)

kruising1 = pre x1 + su x2
kruising2 = pre x2 + su x1
return (kruising1, kruising2)

McArthurs wiskundetruc
def gast(maand,leeftijd):
maanden = ["januari",
"februari","maart","april","mei","juni","juli","augustus","september","november","december"]
rangnr = maand
getal = ((((rangnr * 2) + 5) * 50) + int(leeftijd)) - 365
return getal

def macArthur(getal):
nieuw = getal + 115
string = str(nieuw)
lengte = len(string)
if len(string) == 4:
rangnr = string[0] + string[1]
leeftijd = string[2:]
else:
rangnr = string[0]
leeftijd = string[1:]

return (int(rangnr), int(leeftijd))

Levensverwachting
def levensverwachting(geslacht,roker,sport,alcohol,fastfood):
som = 70
if geslacht == "vrouw":
som += 4

if roker is True:
som -=5
else:
som += 5

if sport == 0:
som -=3
else:
som += (1) * int(sport)

if alcohol ==0:




ffifi fi fiffi fi ffi fiffifi

, som +=2
elif alcohol <=7:
som +=0
else:
som -= 0.5 * (int(alcohol) - 7)

if fastfood is False:
som += 3

return oat(som)

Woordsommen
def letterwaarde(letter):
if letter.isalpha():
klein = letter.lower()
waarde = ord(klein) - ord('a') + 1 #positie in alfabet
else:
waarde = 0
return waarde

def woordwaarde(woord):
som = 0
for karakter in woord:
waarde = letterwaarde(karakter)
som += waarde
return som

def iswoordsom(woord1,woord2,woord3):
return (woordwaarde(woord1) + woordwaarde(woord2) == woordwaarde(woord3))
# zal true of false returnen

123
def evenOneven(n):
even = 0
oneven = 0
for karakter in str(n):
if int(karakter) % 2==0:
even +=1
else:
oneven +=1
return (even, oneven)

#procedure eenmaal toepassen

def volgende(n):
even, oneven = evenOneven(n)
return int(str(even) + str(oneven) + str(even + oneven))

def stappen(n):
stappen = 0
while n !=123:
n = volgende(n)
stappen += 1
return stappen

Meirp
def omgekeerd_getal(getal):
return int(str(getal)[::-1])




fl

, def ispriem(getal):
for i in range(2,int(getal)):
if int(getal) % i ==0:
return False
return True

def ismeirp(getal):
omgekeerd = omgekeerd_getal(getal)
priem = ispriem(getal)
priem2 = ispriem(omgekeerd)
if (priem is True) and (priem2 is True) and (str(omgekeerd) != str(getal)):
return True
else:
return False

Bovensteboven
def bovensteboven(getal):
ok = "01689"
nietok = "2357"
woord = ""
for karakter in str(getal):
if karakter in ok:
if karakter == "6":
woord += "9"
elif karakter == "9":
woord += "6"
else:
woord += karakter

omg = woord[::-1]
if omg == str(getal):
return True
else:
return False

def volgende(n):
getal = n + 1
waarde= bovensteboven(getal)
while waarde is False:
getal += 1
waarde = bovensteboven(getal)
return getal

C-som
def csom(getal):
if len(str(getal)) ==1:
return getal
else:

while len(str(getal)) > 1:
som = 0
for karakter in str(getal):
som += int(karakter)
getal = som
return getal

Hardnekkigheid
def vermenigvuldiging(getal):
som = 1
for karakter in str(getal):

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 $4.01. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75619 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
$4.01
  • (0)
  Add to cart