ICL Home >> Lab Sessions >> Lab 1
 

Introduction to Computational Linguistics

Lab 1 - Introduction to Python

  1. Write a simple Python module file that prints `Hello world'. First use the interactive python interpreter and then store the command in a file and import it to the Python interpreter. If you use IDLE2.4, trying running it by clicking the file.
  2. Turn the module into an executable script and run it from the DICE command line
  3. Define a string s = 'colourless'. Use slicing and concatenation to turn this into 'colorless'.
  4. Create a list of the names of the days of the week. Sort the list so it appears in alphabetic order.
  5. Create a dictionary and access some entries. What happens if you try to access a non-existant entry? Write a program that prints out each key-value pair in the dictionary, ordered alphabetically by key.
  6. Write a data structure that contains you personal information (name, phone number, email, address, etc.). Use any combination of built-in object types (strings, dictionaries, lists, ...). Access the individual components by indexing. Is your design clear and efficient?


Home : Teaching : Courses : Icl 

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh