Programming Basics Flashcards
Binary
Machine code in 1s and 0s
Programming Languages
A middle man to translate computer machine code into a digestable language
Low-level vs. high-level programming languages
Low level: C, Assembly (closer to binary code)
High level: Java Python
IDE’s (Integrated Development Environments)
We use IDE’s to write code. A place to write, run, and debug code and also convert it to machine code (visual studio code. NetBeans, IntelliJ)
Syntax
All programming languages have a set of rules you must follow, at the forefront of those rules is grammar. Grammar in programming = syntax. In order to run smoothly, Syntax for each language must be correct.
Each language must be unique in its Syntax.
Print Statement
This is console.log, the output of the code
Modulus
Represented with % - allows us to get the remainder of a divisional operation
Done to see if the answer is even or odd
Strings
Another way to say text
Anything enclosed by quotation marks is a string
Concatenation
Adding strings together
Integer vs. String
4 in quotation marks (“4”) is treated as a STRING
4 without quotation marks (4) is treated as an INTEGER
Variable
Something that can store information and be referenced and manipulated.
Each variable has a type, name, and a piece of information stored inside of it.
One of the most important concepts in programming is variables. A variable points to a specific memory address that stores a value. Variables are given a name which can be used throughout your code to access that value.
Primitive Variables
Integers, Booleans, Floats, doubles, strings and Chars
Integer Variables
A variable that can store an Integer value,
Only whole values, it can and will not hold any decimal values
Boolean Variables
True or false
Used in conditional Statements
Float Variables
Can store up to 32 bits of information (in decimals)
Double Variables
Can store up to 64 bits of information (in decimals)
String Variables
Text stored in a readable format for the user
Char Variable
Stands for character
Can each hold one character
Useful when a programmer wants to read one button press of one character in a string without using a String variable (think keyboard)
Limitations of Variables
Integer, Float and double variables can be:
- added
-subtracted
- Multiplied
- Divided
- Modulused
String Variables can be:
-added
Char’s and Booleans’s:
Can’t be operated on
Conditional Statements (IF Statement)
If some condition is true, then carry out the instructions located within the IF statements brackets. ELSE do the other thing.
Conditional Statements + brackets
Most programming languages use braces/brackets () {}
Whatever is inside the braces will be evaluated as either true or false
If the statement is true, whatever is enclosed inside a set of curly braces directly after the if statement will run
If the information in the bracket is not true, then none of the code will run
Else-IF and Else
The else-if statement will only be evaluated if the preceding if (or if-else) statement was bypassed due to it being false
Switch Statement
Functionally similar to many else-if statements together
Start with a colon
Each switch statement also includes a default case (else statement)
Conditional Statements
Adds variablitly to programming - program runs differently based on user input
if a user does something we want to adapt accordingly
A program without conditional statements would run the same thing every time - really primitive