Please enable JavaScript.
Coggle requires JavaScript to display documents.
2.2 Programming Techniques - Coggle Diagram
2.2 Programming Techniques
Variables, Constants and Assignments
Assignment
- a statement in computer programming that is used to set a value to a variable name. (In Phyton, it's putting a value in a variable by using "=")
Constant
- A constant is a variable which
cannot be changed
after it is set.
(A constant could be useful if you were never going to change the value. For instance, the maximum number of marks for the Computer Science exam is always 80. Storing that in a constant would be useful.)
Variable
- something that stores information. Its value can be given by the programmer, or inputed by the user. This can be changed/ overwritten.
E.g. "Score = 0" (At the start of the game), but it changes when it's overwritten: Score = score + 1
Or the user can give it a value e.g. name = input("What is your name?") The question will be displayed and the user can type in their name which will bi stored.
Logical Operations
Logical AND
- It will only succeed if both criteria are met.
Logical OR
- will succeed if either of the criteria are met
Logical Comparison
== checks to see if two things are the same.
Logical NOT
- will allow the code to run unless the entry is the same as the one given.
File Handling
String Manipulation
Arithmetic Operations
Multiplication
: *
Division
: /
Addition:
+
, and Subtraction
: -
Sub Programs
Lists
Data Types and Casting
Data types
A
Character
is a single letter, number or punctuation. Strings are made up of made up of multiple characters "strung" together. e.g. num=42 print(chr(num))
Float
- A real is a number with a decimal place. This is a great variable type for storing things like prices.
An
Integer
is a whole number.
A
Boolean
variable holds ONLY either True or False.
The
String
variable type is used to store combinations of letters, numbers, punctuation and spaces. (Any answer to an input statement is a string)
Casting
- Converting between different variable types.
Input and Output
Outputs
present information to the end user. This is often done by displaying information on the screen.
Inputs
take data into the script from the user and do something with it/ process it - usually to make an output.
Program Flow