100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary computational thinking: python, file editing, and regex

Rating
-
Sold
-
Pages
2
Uploaded on
24-09-2025
Written in
2024/2025

this document contains a summary of the computational thinking lectures. it covers how to open, read, write and close text and csv files with python. in addition, error handling is explained via try-exception constructs and additional blocks such as else and finally. a large part is dedicated to using regular expressions (regex), including repetition operators, groups and choices, predefined classes, special characters and escape characters. substitution with regex in strings is also included. together, these topics form practical building blocks for applying computational thinking in programming tasks such as input and output operations, pattern recognition and automation.

Show more Read less
Institution
Course








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Study
Course

Document information

Uploaded on
September 24, 2025
Number of pages
2
Written in
2024/2025
Type
Summary

Subjects

Content preview

Samenvatting Hoorcolleges Computationeel Denken

Hoorcollege 11:

Openen en bewerken van tekst bestanden:
fh1 = open(‘myfile.txt’, “r”) # open for reading
fh1 = open(‘myfile.txt’, “w”) # open for writing, remove existing content
fh1 = open(‘myfile.txt’, “a”) # open for writing, keep existing content

fh1.readline() # read single line
fh1.readlines() # read a list of lines
fh1.read(7) # read the next 7 characters
fh1.strip() # strips the file of empty lines

fh1.write(“Hallo World\n”) # write text to file, not explicit newline at the
end
fh1.close() # close a file after use
with open(‘file.txt’, ‘r’) # no closing using with()


Openen en lezen van csv bestanden:
import csv
fh1 = open(‘csv_file.csv’) # open file for reading
ch1= csv.reader(fh1) # create a csv variable from the file handle
regel = next(ch1) # eerste regel
regel[i] # i’e element van de eerste regel

Bewerken van csv bestanden:
ch1 = csv.writer(fh1) # create write file
ch1.writerow(content) # write row and fill with content
fh1.close() # close starting file

Try en except:
try block: tests a block of code for errors
except block: handles the error
else: execute the code when there is no error
finally: executes code regardless of the result
$3.59
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
studiemotion

Get to know the seller

Seller avatar
studiemotion Universiteit Utrecht
Follow You need to be logged in order to follow users or courses
Sold
New on Stuvia
Member since
2 months
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions