Introduction to Programming 2024/2025 (CC1024) - DCC/FCUP

Practical Class #06 - Lists (04/11 to 08/11)


Exercises for submission

In what concerns the "exercises during classes" component of the evaluation, the exercises that you can submit for this class are:

Deadline for submission: November 23rd (submit to IP's Mooshak)

You are encouraged to talk to the professors and your colleagues if you encounter difficulties. However, any more direct help that you receive should be acknowledged in the comments of the code you submit.
After the deadline the problems will still be available on Mooshak, but the submissions will not count towards your grade.
Each practical class is worth 10% of your final component for exercices during class. Since there will be 11 classes with submissions, you can achieve maximum grade even without doing all classes.
For a problem to count you must pass all tests (that is, to have an accepted). Even if you solve all problems, the maximum on one class is 100%.
To obtain 100% it will always be enough to solve the main exercises.


With the exercises in this class you will develop the following skills:

  1. Explore function definition and function calling
  2. Understand the concept of lists and how you can use them in Python
  3. Know how to insert, remove and modify elements in lists
  4. Know how to call auxiliary list methods, such as count and sort
  5. Understand that a list variable is essentially a reference to the list
  6. Gain experience with some algorithmic patterns

If you feel stuck, go back and revise all the lectures, but in particular the following ones: T08: Tuples and Lists | T09: More (on) Lists | T10: Advanced Lists


1) The start

The first set of problems will give you the basics about lists.


Read the statements, code and try to submit Accepted solutions to all of the following problems. Don't forget to test first on your computer!

  1. [IP048] List Transformation (changing elements from a list)
  2. [IP049] Fibonacci Sequence (creating a list and accessing its elements)
  3. [IP050] Drunken Lists (traversing a list)
  4. [IP051] Rotating Toys (inserting/removing elements from a list)


2) Getting a bit harder

Now that you understand the basics, let's see if you can solve the next batch of problems (and if you payed attention to some of the existing list methods).


Read the statements, code and try to submit Accepted solutions to all of the following problems. Don't forget to test first on your computer!

  1. [IP052] Duplicated Reports (using count)
  2. [IP053] Kwik-E-Mart (create a new list while traversing another list)
  3. [IP054] Just an Average Person (using sort)


3) Working with matrices

What if we told you that matrices are just lists of lists?


Read the statements, code and try to submit Accepted solutions to all of the following problems. Don't forget to test first on your computer!

  1. [IP055] Messy Matrix (from a matrix to a list)
  2. [IP056] Turn it Back! (from a list to a matrix)
  3. [IP057] A Summing Project (summing two matrices)


4) Extra exercises for consolidating your knowledge [extra]

Loved the main exercises and want more adventure in Springfield, home of the Simpsons? Here are more exercises to sharpen your skills.


Read the statements, code and try to submit Accepted solutions to all of the following problems. Don't forget to test first on your computer!

  1. [IP058] Pascal Triangle (easy-peasy, right?)
  2. [IP059] Church Members (how to use a normal sort with two criteria?)
  3. [IP060] Eeny, Meeny, Miny, Moe (be organized!)

3) Challenge exercises [challenge]

You’ve tackled the trickiest tasks across town, from sorting Ned Flanders' humble lists to helping Milhouse dodge Nelson, and even assisting Reverend Lovejoy’s congregation in order. Springfield thanks you for your Python prowess and quick thinking!

But as any true problem-solver knows, there are always two final challenges awaiting at the end: Homer and Mr. Burns' spiral quests.

Think you have what it takes? Tackle these two last challenges, and you’ll truly be a Springfield Python Master! Good luck, and may the spirals align in your favor!


Read the statements, code and try to submit Accepted solutions to the following problems. Don't forget to test first on your computer!

  1. [IP061] Donut Path
  2. [IP062] Treasure Hunt

Happy coding! 😊