Comp Sci notes

Date: 2023-02-01

What is a variable?

A variable is a location in memory where a data point is stored. It is temporary.

// example of a variable
// StartPage
let theme = getStorage("themeSetting", "dark");

Global variable

A global variable is a variable that can be accessed throughout an entire script.

// example of a global variable
// coolnote
let currentText = '';
let currentFile = '/';

Local variable

A local variable is a variable that can be accessed only in a specific function, procedure or block.

// example of a local variable
// StartPage
function updateTime() {
    var currentTime = new Date();
    var hours = currentTime.getHours();
    var minutes = currentTime.getMinutes();
// ...

Data types

Data types include but are not limited to…

Example Pseudocode

ATAR Standard

1.  BEGIN
2.      Num1, Num2, Output are float
3.      INPUT(Num1)
4.      INPUT(Num2)
5.      Output <= Num1 + Num2
6.      OUTPUT(Output)
7.  END

Syllabus

1.  Begin
2.      Num1, Num2, Total are float
3.      Input(Num1, Num2)
4.      Read(Num1, Num2)
5.      Total <= Num1 + Num2
6.      Output <= Total
7.  End

Example Pseudocode 2

ATAR Standard

Syllabus

1. Begin
2.     Num1, Num2, Num3 are float
3.     Input <- Num1, Num2, Num3
4.     Read(Num1, Num2, Num3)
5.     If (Num1 > Num2 AND Num1 > Num3) Then
6.         Output <- "The first is the biggest"
7.     EndIf 
8.     If (Num2 > Num1 AND Num2 > Num3) Then
9.         Output <- "The second is the biggest"
10.    EndIf
11.    If (Num3 > Num1 AND Num3 > Num2) Then
12.        Output <- "The third is the biggest"
13.    EndIf
14.    If (Num1 == Num2 AND Num2 == Num3) Then
15.        Output <- "They are the same"
16.    EndIf
17. End 

Python it up

num1,num2,num3 = 0,0,0
num1 = float(input("Enter the first number. "))
num2 = float(input("Enter the second number. "))
num3 = float(input("Enter the third number. "))

if (num1 > num2) and (num1 > num3):
	print("The first is the largest, it is "+num1)
elif (num2 > num1) and (num1 > num3):
	print("The second is the largest, it is "+num2)
elif (num3 > num1) and (num1 > num2):
	print("The third is the largest, it is "+num3)
else:
	print("They are all the same")

home