Term 1 Notes
1. Algorithm & Programming Basics
Variables:
These are used to store data.
Example:
age = 14
Input/Output Statements:
● Input: Takes data from the user.
Example:
age = input("Enter your age: ")
● Output: Displays information to the user.
Example:
print("Your age is", age)
Selection Statements:
These are used to make decisions.
Example:
if age > 18:
print("You are an adult.")
else:
print("You are a minor.")
Data Types:
● Integer: Whole numbers (e.g., 23)
● Float: Decimal numbers (e.g., 3.14)
● String: Text (e.g., "hello")
, 2. Binary Conversion
● Binary to Decimal:
Example:
1011 (binary) = 11 (decimal)
● Decimal to Binary:
Example:
13 (decimal) = 1101 (binary)
The 1 and 0 play a key role.
E.g if you want to turn 10 in to binary you follow the table we know that 8 + 2
makes 10
All we need to do is 00001010 the 1 represent the addition of 8 and 2 via the table.
3. Binary Addition
Add binary numbers just like decimal, carrying over when the sum reaches 2.
Example:
101
+ 110
------
1011 (11 in decimal)
1+1=10
1+1+1=11
0+0=0
0+1=1
1+0=1
4. Hexadecimal