Programming I - Labs 2019/2020
This page contains materials for the practice lessons of the Programming I (NPRG030) course that is being/has been taught during winter semester 2019/2020 at Charles University in Prague, Czech Republic. The course official web page is/was to be found at Tomáš Holan's webpage. The practice lessons (labs) are/were backed by many, for this group, concretely, by Jakub Gemrot
Monday's labs, 15:40, SW2, Jakub Gemrot: firstname.lastname@example.org
How to pass the labs
- Max TWO absences
- Do ALL homeworks I give you
- Almost no excuses here, it has very good motivation I('ll) share during the first lab
- Pass a lab exam
- Two dates: 16. 12. 2019 / 6. 1. 2020
- Come up with an individual semester project
- Deliver a semester project
- Delivery deadline: “up-to-you” = to be negotiated :)
- Apart from the implementation you will also have to create user's manual and programmer's manual
- Follow delivery guidelines when submitting your work
Send me an email (email@example.com) containing a link where I can download your homework / project.
Always use subject: PRG1 - 2019 - L[lab number] - [homework name]
Example: PRG1 - 2019 - L01 - Recodex
The subject is crucial! My mailbox is often overflowing and I have to process emails in batches - at these times, I'm searching for your homeworks via subject names.
- As promised, this lab will be about fun stuff!
- Example game: Paddle
- This is advanced version of Paddle that contains sounds, moving brick, ball that is getting faster every brick hit and it is also changing a color for a bit every hit
- Beware, you have to change paths into sounds.py in order to run it in your context!
- You will need Pyglet installed: pip install –upgrade pyglet –user
- Stuff we are going to use:
- PRG1 - 2019 - L09 - Paddle
- Do at least one thing from the following:
- Implement (at least one) power-up(s), e.g.: bigger ball, faster ball, bigger paddle, faster paddle, etc.
- Implement 3 different level layouts: level 1 - checkerboard, level 2 - circle, level 3 - full brick wall (standard)
- Implement (at least one additional) brick type, e.g.: non-destroyable, needs-to-be-hit-twice, ball-slowing, ball-fasting, random direction bounce, etc.
- E.g.: if add fails for the left operand, radd is tried on the right one
- “Private methods” are not correct in Python context, these are just scrambled names, stackoverflow discussion
- Python OOP “Example” File
- PRG1 - 2019 - L07 - Sorts
- Implement BubbleSort, HeapSort and QuickSort
- Implement timing decorator (or use one)
- Gather running time of sorting algorithms for arrays of size 1 ~ 10.000.000 (step: *2 … 1, 2, 4, 8, …)
- Use random number generator for that
- Plot running times using scatter plot
- Revisiting modules again (finishing the Lab 05 story)
- Classes and Objects!
- PRG1 - 2019 - L06 - ImLib
- Create your own class for holding value of a complex number
- Implement add, sub, mul operators
- Implement greater/less then relations (compare real component first, then imaginary)
- Implement negation operator
- Provide interoperability with Python number types (int and float) wrt. to operators/relations above
- Modules and packages
- I highly recommend you to read this through completely
- List of Python built-in modules
- What it is, how to use it
- PRG1 - 2019 - L05 - Compute dir size
- create a program that will recursively sum the size of all files within a given folder and its subfolders
- Quick intro to os and os.fstat
- More from https://www.learnpython.org
- List comprehensions explained, I prefer this one as it starts with the semantics first
- .keys() and .items() are important!
- More topics
- PRG1 - 2019 - L04 - File stats
- Ask user for a path to a some text file
- As an example files you can use the following book
- Read the file and:
- Print the number of words within the file
- a word is a sequence of non-whitespace symbols
- Find and print the most frequent word(s)
- Print average frequency of words
- Find and print the words of frequency nearest to the word frequency median
- Find and print the least frequent word(s)
- Deadline: 10.11.2019 23:59
- Optional fun
- Try to revisit homeworks from 02 and rewrite them with at least number of lines possible
- Intro continues
- We will be playing with
- Homework is in Recodex!
- There are following assignments in order, which is advised to implement them in
- 5P 0.2 Hello World 2
- Caesar cipher
- Is a number symmetric in Python?
- Prime factorization
- Součet řady celých čísel
- Maximum value in a sequence (with occurrences) in Python
- Intro to Python!
- How to install Python + Visual Studio Code + Run the first program (PDF)
- We are using https://www.learnpython.org
- And how to read input from console
- Note that input is always string, so you have to cast it to, e.g., int if you want a number
- In hope user has actually typed a number … but that's another story
- Second batch of homeworks :)
- PRG1 - 2019 - L02 - First Pythons
- Do the first 22 programs in Python
- Deadline: 20.10.2019 23:59
- Welcome to Programming!
- Some introductory formal / informal info
- First batch of homeworks :)
- PRG1 - 2019 - L01 - Recodex
- PRG1 - 2019 - L01 - Prisoners
- Solve the following problem, Prisoners, and ideally (but optionally) prove that your solution is working
- PRG1 - 2019 - L01 - Coins
- Solve the following problem, Wizard & Prisoner - Coins, in a way that the description also serves as a proof that your algorithm is working
- Deadline: 13.10.2019 23:59