Mapa mental
programming basics
Conteúdo do mapa
programming basics
data types
- programming languages have 5 main data types, Integer, Real, Boolean, Character and string
- each data type is allocated a different amount of memory
- integer 2 or 4 bytes
- Real 4 or 8 bytes
- boolean, 1 bit is nneded but 1 byte is used
- character 1 byte
- string 1 byte for every character in the string
- programming languages can be weakly or strongly typed. Weakly typed languages will try to convert data types to avoid errors, however this can lead to more unpredictable results. Strongly typed languages wont try to convert data types so will produce more errors but more predictable results
- casting is used to change the data type
- Languages have functions that let you manually covert between data types
- int(1) converts the string 1 into integer 1
- float(1) converts the integer 1 to the float 1.0
- bool(1) converts integer 1 to the boolean value true
- str(true) converts boolean value "true" into string true
- Languages have functions that let you manually covert between data types
- Using the correct data types for different variables
- initial of first name: N
- surname: Chapman
- age(in whole years):27
- height (in meters): 1.64
- male or female: male
operators
- functions and operators
- addition +
- subtraction -
- multiplication *
- division /
- expontation ** or ^
- Quotient DIV
- remainder MOD or %
- comparison operator
- == is equal to
- <> or != is not equal to
- < less than
- > greater than
- <= lass than equal to
- > more than equal to
- functions and operators
constants and variables
- data values can be constants or variables
- data values can be stored in constants or variables
- the name of a constant or variable is linked to the memory location
- a constant is assigned a data value at design time that cant be changed
- variables on the other hand change value which makes them far more useful than the constants
- data values can be constants or variables
strings
- strings are written inside quotation marks
- string1 = "My favourite colour is"
- string2 = "purple"
- new_string = string1 + " " + string2
- string2 = "purple"
- string1 = "My favourite colour is"
- programs let you manipulate strings in a variety of different ways
- x.upper: changes all the characters in the string to uppercase
- x.lower changes all the characters in the string to lowercase
- x.length: returns the number of characters in string x
- x[i] extracts the character position i from string x
- x.subString(a,b): extracts a string from a starting position a with length b from string x
- strings are written inside quotation marks
program flow
defensive design
- helps to ensure programs function properly
- makes sure inpus cant be exploited
- programmers try to protect their programs through defensive design
- when programs are functioning correctly they should never break and never produce errors
Informações
- Descrição
- Mapa Mental sobre programming basics, criado por Jonathan Green em 06-06-2019.
- Criado por
- Jonathan Green
- Visualizações
- 0
- Avaliação