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
Permalink: http://bit.ly/mff-uk-prg1-labs-2019
Dates
Monday's labs, 15:40, SW2, Jakub Gemrot: jakub.gemrot@gmail.com
Interesting
VisuAlgo - visualization of algorithms including AVL trees! Puzzle Prime - great box of puzzles (kudos to Simon Williams who brought this up)
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
- Project idea deadline: 2.12.2019
- Describe what you would like to create in 3-10 sentences and send it to jakub.gemrot@gmail.com
- Description deadline: 16.12.2019
- Use (copy-and-update) the following template
- You can get inspired at web pages of my colleagues:
- 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
Submitting homeworks
Send me an email (jakub.gemrot@gmail.com) containing a link where I can download your homework / project.
Ideally use DropBox or One Drive or WeTransfer; from time to time I have problems downloading files from GDrive (they are having wild JavaScripting that gets blocked by my filters occasionally).
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.
Labs History
Lab 09
- 16.12.2019
- 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:
- Homework
- 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.
Lab 08
- 9.12.2019
- Python Q&A, Algorithmization
- Homeworks
- PRG1 - 2019 - L08 - Train crossing the bridge
- We will need a circle buffer (a.k.a. circular queue) for that
- PRG1 - 2019 - L08 - Reusable ids
- You will need to know what linked lists are in order to solve this
Lab 07
- 25.11.2019
- Leftovers!
-
- 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
- Homework
- 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
Lab 06
- 18.11.2019
- Revisiting modules again (finishing the Lab 05 story)
- Classes and Objects!
- Excellent Intro to Classes and Objects on realpython.com
- Important built-in methods: isinstance and issubclass
- Another tutorial, which is mentioning important built-in class attributes as well as getatts(), setattr(), delattr() functions, member hiding and others
- Operator overloading on geeksforgeeks.com
- Homework
- 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
Lab 05
- 11.11.2019
- Modules and packages
-
- I highly recommend you to read this through completely
- List of Python built-in modules
- Recursion!
- What it is, how to use it
- Homework
- 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
Lab 04
- 4.11.2019
- 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 on lambda functions here, again this is more thorough explanations what lambda functions are (including theoretical background!)
- Here is the official documetation on Python built-in functions
-
- More topics
- Homework
- 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
Lab 03
- 21.10.2019
- Intro continues
- We will be playing with
- Custom function definitions
- We will need some string built-in methods
- 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
- Bases
Lab 02
- 14.10.2019
- Intro to Python!
- How to install Python + Visual Studio Code + Run the first program (PDF)
- We are using https://www.learnpython.org
-
- Note isinstance
- Note 'is' operator
-
- Plus slicing (exemplified on strings)
- Plus some extra list methods
- 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
Lab 01
- 7.10.2019
- 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