100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Samenvatting Computationeel Denken Final Exam(INFOCODE) $7.96   Add to cart

Summary

Samenvatting Computationeel Denken Final Exam(INFOCODE)

 67 views  2 purchases
  • Course
  • Institution

Stof voor eindtentamen van CODE.

Preview 3 out of 21  pages

  • May 27, 2021
  • 21
  • 2019/2020
  • Summary
avatar-seller
SV CODE eindtentamen
Isabelle van Aard – januari 2020

College 10 – Bestanden en exceptions

Bestanden lezen en schrijven

• Wiskundige taken (Bereken de kans dat je een aantal keer achter elkaar zes gooit)
• Geen externe input
• Meeste taken gebruiken data
• Input van de gebruiker, command line argument, webservice, database
• Data in bestanden
• Data science, information retrieval: heel vaak tekstbestanden
• Verschillende manieren om bestand te lezen
• Hele bestand: tekst = bestand.read()
• Een regel: regel = bestand.readline()
• Alle regels in een lijst: alle_regels =
bestand.readlines()
• Gebruik in for-loop bestand =
open("inhoud.txt")
for regel in bestand:
print(regel)
• Bepaald aantal karakters: stuk = bestand.read(10)
• Een bestand is een lange rij bytes. Elke byte representeert een karakter
• Regeleindes zijn een speciaal karakter \n
o Bij het ontwaken\neen handvol confetti\nop het hoofdkussen
o → Teksteditors ‘vertalen’ het teken \n naar een visueel
regeleinde
• Python-functies lezen bytes totdat ze \n tegenkomen
o readline(), readlines(), for regel in bestand
• Dit karakter wordt ook gelezen en opgeslagen in de variabele
• bestand = open("gedicht.txt")
regel = bestand.readline() # regel is nu "Bij het
ontwaken\n"
• print() interpreteert \n ook als regeleinde
• print() voegt zelf ook altijd een regeleinde toe
• Dus: twee regeleindes → lege regel
• Bestand sluiten na gebruik
• Opnieuw lezen, lezen na schrijven, overschrijven
• In Python: bestand.close()
• Automatisch sluiten: blok met with en as
bestand = open("inhoud.txt")
for regel in bestand:
print(regel.strip())
bestand.close()
• with open("inhoud.txt") as bestand:
• for regel in bestand:
o print(regel.strip()) # bestand automatisch gesloten

1

, • open("bestand.txt", "w") → haalt bestaande inhoud weg
• Vaak de bedoeling
• Voorbeeld: preprocessing van tekst opslaan in bestand
• Andere gevallen: na bestaande tekst doorgaan
• Voorbeeld: log-bestanden, resultaten experimenten
• Append met open("bestand.txt", "a")
• Expliciet lezen: open("bestand.txt", "r")
o "r" is default-waarde van dit argument

CSV




• CSV-bestanden schrijven
• Strings niet verplicht
• import csv csv_file =
open("cijfers.csv", "a")
• cijfer_uit = csv.writer(csv_file)
cijfer_uit.writerow(["John Smith",7,5,9,7])
cijfer_uit.writerow(["Jane Doe",8,4,7,6.3])
csv_file.close()




2

, Exceptions




College 11a – Music information retrieval

➢ MIR is concerned with the extraction, analysis, and usage of information about any kind of
music entity (e.g., a song or a music artist) on any representation level (bv audio signal,
symbolic MIDI representation of a piece of music, or name of a music artist)
o MIR is hardly a stable concept, but a very lively research area

MIR scenarios:
• Melody search → puur IR (zoekvraag en ik wil iets vinden); de rest gaat meer over actieve
betrokkenheid in de muziek.
• Query by humming (zingt liedje in hoofd en systeem herkent wat je doet)
• What's playing? (Shazam: opname identificeren)
• Recommendation (discover weekly: nieuwe muziek)
• Music I can play along with (chordiffy; yt movie met leuke muziek --> track uploaden en
dan kan je meespelen (want je ziet de song op je beeld en dan kan je het volgen op je gitaar oid)


3

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 IsabelleU. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.96. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78310 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
$7.96  2x  sold
  • (0)
  Add to cart