7001ICT | Programming Principles | Programming

Home Recent Questions 7001ICT | Programming Principles | Programming

1    Preparation

Before your workshop class:

•    Read all of this document.
•    Review the lecture notes sections 1 to 20.
•    Bring some paper (a print-out of this document is best) and writing implements.
•    Bring a storage device, such as a portable hard drive and cable, or a USB drive.

2    Pre-workshop questions (1 mark)

Complete these questions in writing before the start of the workshop. They will be marked early in the workshop.

1. Give two di erences between a tuple and a list.
2. Give an important di erence between an array in an older language, such as C, and a list in Python.
3. Complete this table, if the following statements have already been executed. Try to work it out yourself, before con rming with the REPL.

i = 3

s = 'robin'

xs = [5, 4, 3, 2, 1]

t = (i, xs, s, False)
expression    type    value
i    int    3

3. Workshop activities

3.1 Marking last workshop's problems

If you have problems that still need marking from the previous workshop, get them marked at the start of this one.

3.2 Problem 1 (1 mark)

Problem: The Unix tool head prints only the top few lines of a le. Write your own version of head that prompts for the name of the le to read, and the number of lines to print. For example:

File name: Lear.txt

Lines: 9


The Owl and the Pussy-cat went to sea

In a beautiful pea-green boat,

They took some honey, and plenty of money,

Wrapped up in a five-pound note.

The Owl looked up to the stars above,

And sang to a small guitar,

"O lovely Pussy! O Pussy, my love,

What a beautiful Pussy you are,

If the le has fewer lines than requested, print as many as there are.

Hint: You don't need to store all the lines in memory before printing them.

3.3 Problem 2 (1.5 marks)

This problem and the rest are due at the beginning of the week 9 workshop. Ask any questions you have about the problems now, or in the week 8 workshop.
Problem: The Unix tool wc counts the numbers of characters, words and lines in a le. Write your own version of wc that prompts for the name of the le to read, then prints the counts. For example:

File name: Lear.txt

Characters: 1242

Words: 224

Lines: 38

Hint: You don't need to store all the lines in memory before counting.

3.4 Problem 3 (1.5 marks)

Problem: Write a program that prompts for the name of a le containing numbers, one per line, and prints the average (arithmetic mean) and the median. For example:

File name: scores.txt

Average = 24.5

Median = 25.5

Note: it is intended that you compute the average and the median yourself. You may not use the statistics module.

4. After the workshop

• You have created programs that might be useful to refer back to in future workshops. Make sure that you will have that work in the future. One copy is not enough for at IT professional. You should have at least 2 copies:

1. on your Gri  th network storage drive; and
2. on your portable storage device.
• Please answer these feedback questions.
{ What was the best aspect of this workshop?
{ What was the most di cult or worst aspect of this workshop? { Did you nd an error in these workshop notes?

Search Here

Latest Reviews

  • Marcus
    30 Apr, 2019

    My assignment help services are provided in the best way by this website. The writers have completed my assignment in such a way that they helped me increase my overall performance.

  • Emy
    29 Apr, 2019

    Awesome work done by the experts of this company. I visited this site to get math assignment completed. My assignment was complete in every aspect. Thanks to the professionals who provided assignment writing help.

  • Darina
    25 Apr, 2019

    All thanks to the writers of Assignment Help 4 Me who completed my Physics assignment in the right manner. The structure of the assignment was totally customized according to my needs and that too at cheap prices.

View All Reviews


Assignment Help 4 Me