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