Revision (theory test).pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

COMP502 – Revision Theory Test Revision Problem Solving Process – the process of writing an application to solve a problem of certain requirements. Although many variations regarding the process exist, it largely consists of the following four steps: o An...

COMP502 – Revision Theory Test Revision Problem Solving Process – the process of writing an application to solve a problem of certain requirements. Although many variations regarding the process exist, it largely consists of the following four steps: o Analysis – to have a clear understanding of what’s given and what’s required, i.e., to define the requirements and specifications. o Design – to develop an algorithm and form a solution. o Implementation – to carry out the design and implement the solution developed in the design step. o Testing – to test the implementation and make sure it satisfies the requirements by executing the application against a set of selected data. Unlike the natural languages like English, a programming language is an artificial language that is used to instruct a computer to do a task. Machine language. Programming languages started with machine language. Sometimes referred to as machine code, the machine language is a collection of binary digits (i.e., 0s and 1s). The Machine language is the only language that can be directly executed – all other languages must be translated into machine language to execute. Assembly language. Machine language was difficult to write the prone to errors. So, Assembly language was created to address the problems. A program called “assembler” was needed to translate assembly code to machine code. Although it’s less prone to errors than its predecessor, assembly language was not efficient to write – even a simple task would require long, and complex program to accomplish. Moreover, it lacked portability - programs written for one type of CUP wouldn’t work for other types. High-level language. Programming languages we’re using today are high-level languages. High-level languages are close to natural languages and easier to write and understand. Like assembly language, high-level languages also need to be translated to machine language. The program used to translate high-level language to machine language is called “compiler” or “interpreter”. In terms of how a language is translated to the machine language, programming languages can be categorised into compiled and interpreted languages. o For a compiled language, the whole program is compiled (translated) before the output is produced. The implication is that the whole program must syntax error-free before the it can be compiled. o For an interpreted language, the program is interpreted one line at a time, until finish or an error is encountered. A programming language can be said to be either static typing or dynamic typing. o For a static typing language, you must specify a type to create a variable. o For a dynamic typing language, specifying a type is not required when a variable is created. Programming paradigm is a way of organising code in an application. The following describes the differences between procedural and object oriented programming. o Procedural programming © Alex Yu CfIT WINTEC 2021 COMP502 – Revision ▪ A program is divided into a set of procedures (AKA. routines or sub-routines), each of which is further divided into a set of smaller procedures until they are manageable. ▪ Procedures and data are separate o Object Oriented Programming (OOP) ▪ A program is divided into a set of objects; objects are then constructed together to form solution to the program ▪ Methods (procedures) and data are bundled together to form an object The benefits of using functions are: o Maintainability o Reusability o Simplicity o Cleaner variable namespace o Easier debugging The following describes the characteristics of the Python language (note, some features are not Python specific): o Python is an interpreted language. o Python is a dynamic language. o Python is case-sensitive. o In Python, a value must be given to create a variable. On indentation in Python: o Indentation is the whitespace characters added to the beginning of a line of code. o Python uses indentation to determine the scope of a statement. o Statements belonging to the same scope must have consistent indentation for the program to work properly. o In Python indentation is not just for code presentation, it’s part of the program logic. On Boolean expressions o There are six Relational operators: >, =,

Use Quizgecko on...
Browser
Browser