Programming Core Elements

August 23, 2014

Let’s continue with the Computer Science course. Remember we are planning to make the computer do the work we want it to do and will eventually script repetitive tasks. This will become very valuable when i begin the Cyber Forensics portion. Though it can be applied to many different applications.

Please keep in mind that these should be used as mere reference, as the notes are written in what you could call “very notated” the use of full structured sentences is rare. If you need more info it can be found at MIT’s OpenCourseware.

Intergrated Developer Environment – IDE

  • Python uses IDLE
  • Specialised Text editor

Objects

  • Python is an “Object” including its code
  • Objects have a type which identify what it is (Two Types)
    • Scaler Type
    • Non-Scaler Type

Different Types

  • Intger – Number eg. 3
  • Float – floating point numbers eg. 4.1, these are not the same as real numbers
  • Boolean – True or False
  • None – NoneType is used for a temporary value
  • String – “This is a string”

Expressions

  • Is the sequence of operands and operators
    • Operands – objects
    • Operators – + – / x

You should remember to use floating point numbers to obtain real division also overloaded operators have a meaning that depend in the type of operands.

TypeErrors is performed by the program running type checking in order to avoid undesired results. It’s also good to know that Python programs can also be reffered to as “scripts”

  • Script – Sequence of commands
  • Variable – Name of an object
  • Assignments – state python binds a name to the object

Python Input State

  • Raw_input – Always expects a string from the user
  • Input – basically don’t use as it’s unavailable in Python 3.0

Straight Line Programs

  • Everything in the application is executed just once

Conditional Statements

  • if / else / elif

Programs are intended to be read not just executed, this helps debugging. This is the reason for indentation even when it’s not required.

Branching Programs

  • Due to the structure of the code in Python using statements. More interesting then straight line. Each command is executed at most once, program execution time is governed by the size of the program.

Looping Construct

  • Turing complete aka iteration provides the ability to execute a statement more then once.