ITSC203 Lab2
ITSC203 Lab2
ITSC203 Lab2
EVALUATION:
1 Problem 1 15
2 Problem 2 25
TOTAL MARK 40
Background Reading
Read chapters 6–10 in How to Think Like a Computer Scientist: Learning with Python,
available at www.greenteapress.com/thinkpython/thinkCSpy.pdf.
https://docs.python.org/3.8/
Important Information
YOU MUST PRESENT IMAGES OF YOUR CODE BEING EXECUTED. DO NOT
SUBMIT YOUR ANSWERS IN THE DOCUMENT. CREATE A BLANK DOCUMENT
AND SUBMIT YOUR ANSWERS THERE.
2. Comments on lines where you used some unique computation that might be tricky to
comprehend a month later.
list1 = [x for x in range(20) if x % 4 == 1] # Using list comprehension to ….
Problem 1 (15 pts)
Using the flowchart and sample output, generate the Python code that will produce the same
behavior.
SUBMISSION
1. Submit your python code and the screenshot(s) of your code working.
Food for thought: How would taking the time to plan, organize your thoughts and
approach before writing code benefit the overall programming experience?
Problem 2 (25 pts)
You will create Python code to output all the keywords available to you in the Language.
There is a builtin module named keyword that you will use to create a list of keywords. Do not
manually type in the keywords. Instead you can place the following lines at the top of your
python code. This is the only module you are allowed to use.
Figure 1: Example showing how to include the keywords from the keyword module.
Figure 2: Example of the code generating output. The figure shows the result of printing the
keywords in a tabular output
Criteria:
1. The field width used for each word should be no more than the width of the longest
keyword plus 2 extra spaces.
a. So, if the longest word is 10 the width used for each word is 12.
2. The words should be right justified in the field.
3. Your output should have 5 columns as shown in the image
4. IMPORTANT: Notice that the words are arranged alphabetically in the output.
a. This will require you to programmatically consider that when sorted, the list will
place words that start with uppercase first. You will change that behavior.
SUBMISSION
2. Submit your python code and the screenshot(s) of your code working.