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

Other

extra oplossingen oefeningen programmeren python dawynt dodona H9: text files

 14 views  0 purchase
  • Course
  • Institution
  • Book

Oplossing voor extra gemaakte dodonaoefeningen op H9: text files, van vak Programmeren peter dawynt Ugent.

Preview 3 out of 25  pages

  • June 12, 2024
  • 25
  • 2023/2024
  • Other
  • Unknown
avatar-seller
H9: TEXT FILES

Rosarchtest
def rorschach(bestand,bestand2=None):
uitvoer = open(bestand2,'w',encoding='utf-8') if bestand2 is not None else None
with open(bestand,'r',encoding='utf-8') as invoer:
for regel in invoer:
zonder = regel.strip('\n')
if bestand2 is not None:
print(zonder +zonder[::-1] , le = uitvoer, end="\n")
else:
print(zonder + zonder[::-1])

#BADA55
def leet2letter(bestand):
with open(bestand,'r',encoding='utf-8') as invoer:
dict = {}
for regel in invoer:
zonder = regel.strip('\n')
lijst = zonder.split()
cijfer = lijst[0]
letters = lijst[-1]
for karakter in letters:
cijfer = cijfer.upper()
if cijfer not in dict:
dict[cijfer] = set()
dict[cijfer].add(karakter.upper())
return dict

def letter2leet(dict):
omg= {}
for cijfer in dict:
letters = dict[cijfer]
for karakter in letters:
omg[karakter] = cijfer
return omg

def leetspeak(woord,omg):
antwoord = ""
for karakter in woord:
karakter = karakter.upper()
if karakter in omg:
antwoord += omg[karakter].upper()
else:
antwoord += karakter
return antwoord

def ishexkleur(woord):
if woord.count("#") != 1:
return False
if len(woord) != 4 and len(woord) != 7:
return False
mag = "ABCDEFabcdef"
for karakter in woord[1:]:
if karakter.isalpha() and karakter not in mag:
return False
return True

def kleur(woord,dict):
leet = leetspeak(woord,dict)




fi

, assert ishexkleur("#"+leet), "ongeldige kleur"
return “#"+leet

Code van Hippocrates
def code2karakter(bestand):
dict = {}

with open(bestand,'r',encoding="utf-8") as le:
for regel in le:
#je ID code eruit halen
IDcode = ""
i=0
karakter = regel[i]
while karakter != " ":
IDcode += karakter
i += 1
karakter = regel[i]

beschrijving = regel[len(IDcode)+1:]
n = len(beschrijving)
for i in range(n):
ID= str(IDcode) + "." + str(i)
waarde = beschrijving[i]
if ID not in dict:
dict[ID] = waarde
return dict

def decodeer(tekst,dict):
#value error met try en except blokken (except is dus wnr dit niet is)

try:
return ''.join(dict[karakter] for karakter in tekst.split())
except KeyError as error:
raise ValueError('ongeldige gecodeerde tekst')

def karakter2codes(bestand):
dict = code2karakter(bestand)

nieuwe_dict = {}
for sleutel in dict:
waarde = dict[sleutel]
if waarde not in nieuwe_dict:
nieuwe_dict[waarde] = set()
nieuwe_dict[waarde].add(sleutel)
return nieuwe_dict

def codeer(tekst,dict):
from random import choice
try:
return ' '.join(choice(list(dict[karakter])) for karakter in tekst)

except KeyError as error:
raise ValueError("ongeldige platte tekst") from error


Spectroscopie
def referentiespectra(bestand):
with open(bestand,'r',encoding='utf-8') as invoer:
dict = {}
for regel in invoer:




fi fi

, lijst = regel.split()
element = lijst[0]
waarden = lijst[1]
nieuwe_lijst = waarden.split(",")
verz = []
for karakter in nieuwe_lijst:
verz.append( oat(karakter))
dict[element] = tuple(sorted(verz))
return dict

Eiwitmassa
def massatabel(bestand):
dict = {}
with open(bestand,'r') as invoer:
for line in invoer:
letter, massa = line.split()
dict[letter] = oat(massa)
return dict

def eiwitmassa(woord,tabel,peptide=False):
som = 0
for karakter in woord:
som += tabel[karakter]
if peptide is False:
som += 18.01056
return som
return som

Levende voormalige presidenten
import csv
import datetime
from datetime import date,timedelta
#we gaan ervannnuit dat bestand gwn in huidige directory bevindt, dus niet mer urlib ofzo werken

def omzet(datum):
#22/2/1732
lijst = datum.split("/")
dag = int(lijst[0])
maand = int(lijst[1])
jaar = int(lijst[-1])
datum = date(jaar, maand, dag)
return datum


def staatshoofden(bestand):
with open(bestand,'r',encoding='utf-8') as data:
inlezen = csv.reader(data,delimiter='\t')

dict = {}
for regel in inlezen:
naam = regel[0]
geboorte = omzet(str(regel[1]))
begin = omzet(str(regel[2]))
if regel[3] is not "":
einde = omzet(str(regel[3]))
else:
einde = None
if regel[4] is not "":
overlijden = omzet(str(regel[4]))
else:





fl fl

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79650 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

Recently viewed by you


$3.84
  • (0)
  Add to cart