Practical Class #02 - First Programs
(30/09 to 04/10)
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: October 19th (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:
- Explore the VSCode IDE and the Python interpreter for your first Python programs
- Manipulate simple data and algebraic expressions
- Handle Input and Output
- Debug simple programs
If you feel stuck, go back and revise the lecture T02: The basics
1) My first Mooshak submissions

On this course we will use Mooshak to automatically evaluate your Python code (see Mooshak's help).
In this problem the goal is to make your first submissions in Mooshak, all for the [IP001] Hello there. The problem statement will also be available inside Mooshak. Always start by carefully reading the problem statement given!
- Start by submitting an Accepted in Mooshak. Create a file called for instance ip001.py, write the code and test it in your computer. Is it doing what you expected?
- After a correct submission you should now experiment with some common errors to see the behavior of Mooshak in these cases:
- Try to get a Compile Time Error - for instance you could create code that does not close any open parentheses } and resubmit.
- Try to get a Wrong Answer - for instance you could change the output to produce a different message than what was requested
- After having this errors your list should be something like this picture. (the number to the left of the result is the number of correct tests)
2) Reading my first input

For this exercise you will be solving the problem [IP002] Bond, James Bond!.
- Read the problem, code and submit an Accepted solution. Don't forget to test first on your computer!
- After a correct submission experiment with another type of error, by adding one more instruction to read something from the output (e.g. read three lines of input).
Submit to Mooshak to see what happens and to discover your first Runtime Error.
If you click on the underlined result itself you can see a detailed table containing the result of each test case and also giving you the first input where your program failed, and the respective expected output (should be something like this picture - note on how the observations report what error was obtained).
Here are a couple more notes about Mooshak on this course:
- You can experiment on your own computer with the provided input examples to check the result (just copy+paste the inputs)
If you saved your input in a file named aed002.py you can also use redirection to feed your program with that input using a line such as python aed002.py < input.txt
- All problem statements will follow roughly the same format, specifying the problem, the input, the output, the constraints and giving at least one input example and its corresponding output.
- You do not need to verify the constraints on your code. On the contrary, the constraints give you guarantees on the input that will be given to your program. You can assume the test cases we will feed your code obey the constraints (e.g. the word sizes will never be larger than 20).
- All the lines of input and output should be terminated with the newline character (including the last line). Failure to do this can result in a Presentation Error.
- You should only output what is given in the statement. Any extra output will can your code be marked as incorrect.
- You can click on the submission number on the left of each listing row to recover your submitted code.
- If you press on more... you can see an interface for seeing submissions that allows you to select only a certain student, a certain problem, etc.
- If you submit a file that is exactly the same as one that you already submitted, Mooshak will not accept and report a Duplicate submission.
3) Training with Mooshak

Read the statements, code and submit Accepted solutions to all of the following problems. Don't forget to test first on your computer!
- [IP003] Check Please
- [IP004] Circle Math
- [IP005] E-I-E-I-No
- [IP006] Time Goes By
Extra exercise for consolidating your knowledge [extra]
IP Mooshak classes will usually include at least one extra
exercise that you can use of you want to keep testing your
knowledge of the material. For this class we propose another
problem for you will only need what you learned in lecture #02 - The Basics.
Challenge exercise [challenge]
IP Mooshak classes will usually include one challenge exercise, which can be much harder the previous ones and might even need knowledge that was not given explicitly on the course.
However, since this is the first challenge, it is almost of the same difficulty of the previous exercises.
Happy coding! 😊 (if you finish everything and need more practice exercises, let us know on discord - we have plenty more to give you 💻)