Programming Flashcards
What is a variable
Any value that will change unless it’s a constant
Variables must be declared with
In python one statement that includes the data type
Different data types ares
Integer- whole number Boolean- two choices Character - symbol on keyboard (single) String- zero or several symbols Float/Real- fractional number
Constant variable
A variable that is the same throughout the program
Benefits of constant variables are
Easy to debug program
Easy to change value as it only needs to be changed once eg VAT
2 types of operations
Arithmetic and comparison do stuff to specific pieces of data
Num1=input
Num2=input
Num3=Num1+Num2
prints”the same is “,Num3)
What will happen and why
It’s will join the numbers together (concatenation) because it hasn’t been changed to int
Sequence-
Series of steps in specific order
Selection
Choice , IF THEN ELSE
Nested iteration and selection
A loop within a loop
Choices made within the process of making a choice
A robust code is
A code that will not crash and will anticipate unexpected user inputs
Arrays
A list with only one data type
Benefits of arrays
Easily debugged
Easily processed
Iteration
For is definite
While is indefinite
Repeat….until is indefinite
Data structure
Grouping data items together so are treated as a set
Subroutine
A named self contained section of the code that performs a specific task.
Def()
Benefits of subroutines
Makes the program structure easy to read
Each subroutine can be tested separately
2 types of subroutine
Procedures and function
Procedures
Just carry out instructions nothing is returned
Functions
Carry out instructions but always return a statement
A global variable is used. Whereas a local variable is
All throughout the program whereas a local variable is is only in a certain part of the program eg subroutine
A structured program
Breaks a program into chunks of subroutines which will be more manageable
Advantages of structured programs
Decomposing the program
Each data structure can be tested separately
Different programmers can work on different data structures at the same time hence making it quicker to complete
Validating input data
Validation will only check if a data is reasonable not correct, if they are prompted to write date of birth it can check if the year and age makes sense but not if you entered November instead of December