Python VI

Mary PW Chin 钱碧慧博士
PhD (Wales), MSc (Surrey)
E-mail:

1st bite of Python

Printing

2nd bite of Python

Loops

3rd bite of Python

If-elif-else

4th bite of Python

Nested loops

5th bite of Python

Input, while, tables

6th bite of Python

Strings

7th bite of Python

Simple maths

8th bite of Python

More loops

9th bite of Python

Dictionaries

10th bite of Python

Drawing

11th bite of Python

Statistics & histograms

12th bite of Python

Pretty nets

13th bite of Python

Medical scans

14th bite of Python

Handwriting recognition

15th bite of Python

Flower recognition

Strings & text processing

Data file: ☞ download cutting.txt

Slides here are continuously being revised and updated. If you have been here before, your browser might have some old files cached. To ensure that you see the latest version, please follow the instructions given in the following link: ☞ how to clear browser cache.

Gentle reminder

For every program you encounter it is always an excellent exercise to change the variable names to names which are most meaningful to you, then make the program run. You will gain deeper understanding of the program. You will see the program in a new light. Everyone is different: variable names most intuitive to me differ from variable names most intuitive to you. My programs are written with variable names most intuitive to me, so you should change them to names most intuitive to you so that the program flow becomes more obvious.

Synopsis
  1. Lists;
  2. appending to list;
  3. length of lists;
  4. joining lists;
  5. reverse-ing lists;
  6. sorting lists;
  7. counting lists;
  8. reading text files;
  9. striping strings;
  10. the regular expression module and its split and substitute methods;
  11. the random module and its shuffle method.
  12. enumerate;
  13. ord;
  14. encryption and decryption: proof of principle.

Exercises
  1. Write a program to print the following with a for loop:
                   DELIGHT
                   TDELIGH
                   HTDELIG
                   GHTDELI
                   IGHTDEL
                   LIGHTDE
                   ELIGHTD
                 
  2. Write a program to print the following with a for loop:
                   WONDERFUL
                   OWONDERFU
                   NOWONDERF
                   DNOWONDER
                   EDNOWONDE
                   REDNOWOND
                   FREDNOWON
                   UFREDNOWO
                   LUFREDNOW
                 
  3. Write a program to print the following with a for loop:
                   WONDERFUL
                   ONDERFULU
                   NDERFULUF
                   DERFULUFR
                   ERFULUFRE
                   RFULUFRED
                   FULUFREDN
                   ULUFREDNO
                   LUFREDNOW
                 
  4. Write a program to encrypt and decrypt your output from Excerise 1. Use an encryption method no simpler than that of slide #44.
  5. Write a program to encrypt and decrypt your output from Excerise 2. Use an encryption method no simpler than that of slide #44.
  6. Write a program to encrypt and decrypt your output from Excerise 3. Use an encryption method no simpler than that of slide #44.

Challenge

Journey into Cryptography

1st bite of Python

Printing

2nd bite of Python

Loops

3rd bite of Python

If-elif-else

4th bite of Python

Nested loops

5th bite of Python

Input, while, tables

6th bite of Python

Strings

7th bite of Python

Simple maths

8th bite of Python

More loops

9th bite of Python

Dictionaries

10th bite of Python

Drawing

11th bite of Python

Statistics & histograms

12th bite of Python

Pretty nets

13th bite of Python

Medical scans

14th bite of Python

Handwriting recognition

15th bite of Python

Flower recognition