Month: October 2016

Nat 5 – Our first program

Today in class we used TRACS to look at the program from last time, so we could better understand how it works and how the Python translator works.

  • A compiler changes all the source code (python) to machine (object) code. The machine code is then executed after all lines have been complied.
  • An interpreter changes one line of source (Python) code to Machine (object) code, this is then executed immediately.

The class was then set a new program to create.

Task

Write a program that takes in 3 numbers, calculates the total, then works out the change from a given amount.

Test data

2.99, 1.50, 3.00
10.00

N5 Python – Introduction

add2numbersOur 1st Python program makes use of a number of new constructs and variables.

# – Internal Commentary, anything after the # on the same line is ignored by the translator

= (Assignment) – values are assigned to the variables using an equals sign.

input() –  a string is captured from the keyboard using the input() function

int() – this function changes the datatype of the given variable to an integer (Whole number)

Expression – The expression is the right hand side of the =, this is evaluated and any calculations performed, the results are then assigned to the variable on the left hand side of the equals

print() – This function displays a string. The “,” is used to concatenate strings and add a space between them.

 

AH – Cheat sheets for a range of applications

I found these cheat sheets  on this site and here. A cheat sheet is a condensed (normally 2 A4 sides) set of notes for an aplication or programming language. They are not designed to be notes in themselves, they are more an aide-mémoire to help you recall how to do something.

There are a lot of languages here but I thought it was worth keeping the list intact. There is a lot in here that is in the course so make sure that you read the entire list.

Command Line

Databases

Programming

Unix/Linux

Web Development

Miscellaneous Topics