Classroom Assessment 2: General Requirements

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Classroom assessment 2

General requirements
ˆ You can work in any Python IDE (IDLE, PyCharm, Visual Studio Code, etc.)

ˆ Each of the two tasks has to be completed in a separate .py code file

ˆ Use functions to modularize your program whenever possible. In each task there has to be at
least two functions: input and process (exact names may differ depending on the task you are
given). To print out a list or a matrix, you can use the standard print function

ˆ Add protection against possible incorrect user input, so that the latter does not crash the
program
ˆ All solutions will be checked manually, therefore you have to provide informative messages
when interacting with the user, both when inputting data and when printing out results. E.g.
instead of printing just the value 10, output ’The sum of digits = 10’.

ˆ After completing the exercises, add them to a zip archive (only the two .py files) and upload
the archive to Canvas in the corresponding section

Topics
ˆ One-dimensional lists

ˆ Strings

You will need to know implementations of the following basic operations:

ˆ Input lists from the keyboard

ˆ Generate random lists of numbers

ˆ Iterate over a list in a while or a for-loop

ˆ Change a list (add, remove items)

ˆ Iterate over a string

ˆ Compare characters alphabetically

1
Examples of tasks
1. Make a loop that requests strings from the user (the loop finishes when the user enters an
empty string). For each string, make a list of those of its letters that represent basic vowel
sounds of the English alphabet (a, e, i, o, u), and print it to the screen, e.g. ’hello’ → [’e’, ’o’]
2. Generate a random list of n integer numbers, each number should be in the range [a..b]. n,
a and b are requested from the user. Make a new list of numbers, which are symmetric (e.g.
131, 22, 919), i.e. read in the same way from left to right and from right to left.

You might also like