Python

This is the programming langauge that will be used throughout the course

What is Python? Executive Summary

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.

Often, programmers fall in love with Python because of the increased productivity it provides. Since there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python programs is easy: a bug or bad input will never cause a segmentation fault. Instead, when the interpreter discovers an error, it raises an exception. When the program doesn't catch the exception, the interpreter prints a stack trace. A source level debugger allows inspection of local and global variables, evaluation of arbitrary expressions, setting breakpoints, stepping through the code a line at a time, and so on. The debugger is written in Python itself, testifying to Python's introspective power. On the other hand, often the quickest way to debug a program is to add a few print statements to the source: the fast edit-test-debug cycle makes this simple approach very effective. (https://www.python.org/)

These are the aspects of Python that the examiner expects to to be able to use (in the coursework) and discuss (in the examination). I have indicated (where appropriate) the page location of the detail in the booklet.

  • Data types (page 19)
  • Programming concepts (practice and experience of the three key structures - sequence, iteration and condition (selection/choice))
  • Arithmetic operations (page 17)
  • Relational operations (page 17)
  • Boolean operations (page 25)
  • Data structures (page 37)
  • Input/output and file handling (page 48)
  • String handling operations (page 43)
  • Random number generation (page 28)
  • Subroutines (page 34)
  • Structured programming (practice and experience of the use of structures - modularity, parameters)
  • Robust and secure programming (page 54)
  • Classification of programming languages (See notes)

Copy these headings to a Word document and then add notes as appropriate.

Improvement tasks November 28th.

Try this code in Python. What does Python do to the variable name?

Show both the code and the result. Explain the process taking place and the effect of the "+" in the code.

Try this code in Python. What does Python make the answer (x)?

Include the flowchart in your notes. Show both the code and the result. Explain why the answer is a different data type to a and b.

Write a program to ask the user for a temperature in Celsius and then get Python to turn that into Fahrenheit. make sure that you include not only the code but the output as well. Annotate the code to explain the names of the variables and the calculation (F = C/5*9 + 32).

IF you are stuck then one of the links on this page shows an overly complicated solution if you wish; but you would have to understand it sufficiently to explain it.

 

 

Useful links

Here are links related to programming in Python.

Techniques

Here are links to a few examples of techniques that may or may not prove useful.

Exemplar material

Here are links to examplar coursework tasks and their solutions.

Improvement tasks

Here are links to improvement tasks.