Please enable JavaScript.
Coggle requires JavaScript to display documents.
Python revision (Different data types (Integer: An integer data…
Python revision
Different data types
Integer: An integer data type deals with whole numbers. A member of the set of positive whole numbers, negative whole numbers and zero
-
Boolean: The Boolean data type represents values of true/ false or yes/ no. The primitive data type of a Boolean is logical. There are arithmetic tests that can be used to create Boolean values.
A string is a data type that can contain a set of characters,numbers and spaces.
Character: A character type may contain a single letter, digit, punctuation mark, symbol, formatting code, control code, or some other specialised code.
Types of programming constructs sequence, selection and iteration.
Sequence: A sequence construct tells the processor which statement is to be executed next. By default, in imperative languages, this is the statement following the current statement.
Selection: A selection statement provides for selection between alternatives. We can identify three types of selection construct: If statements, case statement and pattern matching.
Selection continued: An if statement, sometimes referred to as a conditional, can be used in two forms if condition then action 1 and if condition 1 else action 2.
Iteration: Iteration, in the context of computer programming, is a process wherein a set of instructions or structures are repeated in a sequence a specified number of times or until a condition is met. When the first set of instructions is executed again, it is called an iteration.
Error Handling
Syntax error: They occur when the programmer fails to obey one of the grammar rules of the programming language that they are using.
Run time error: They occur whenever the program instructs the computer to carry out an operation that is either not designed to do or slow to do.
Logic error:They occur when the program runs successfully but it does not behave in the manner it was designed to.
The process of testing a program for errors during the execution of code is a cyclic activity is called debugging.
Functions: A function is very similar to a procedure except that it returns a value. There are two
types of functions. User defined functions are created by the user for a program.
-
Built in functions: Built in functions are part of the programming language. Built in functions are very useful and save a lot of effort in writing code to preform common tasks.
Algorithm = A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.
Variable and constant = Variables are used in computer programming to store specific values within a program. They are assigned both a data type and a value. some values are stored permanently; the data is constant. Other things are always changing; the data is a variable.
Scope: Is the area in the code where a variable can only be accessed and changed. Trying to access a variable in other parts of the code that do not fall in this area will not work. There are two types of scopes. Local scope which is within a function, and global scope which is anywhere in the program. The different types of scopes mean there are two different types of variables. These are local variables and global variables.
-
-
-
-