---
# System prepended metadata

title: AS CS Guide

---

---
title: AS CS Guide
---

**CS Guide by Zidaan**
*More to be added*


# OPERATORS (CONCATENATION)

## (1) **&**
Concatenates two variables together into a single string

|Pseudocode|Python|VB|
|--|--|--|
|&|No such operator|&|

EXAMPLE: This will concatenate an integer into a string and output it as "My age is 18 years old"
```
DECLARE MyString, MySentence as STRING
DECLARE MyInteger as INTEGER

MyString = "My age is "
MyInteger = 18

MySentence = MyString & MyInteger & " years old"

OUTPUT MySentence
```

## (2) **+**
Concatenates two (strings ONLY) together into a single string

|Pseudocode|Python|VB|
|--|--|--|
|+|+|+|

EXAMPLE: This will concatenate two strings into one and output it as "Howdy partner, how do you do?"
```
DECLARE MyFirstString, MySecondString, MySentence as STRING

MyFirstString = "Howdy partner, "
MySecondString = "how do you do?"

MySentence = MyFirstString + MySecondString

OUTPUT MySentence
```

<br>

# OPERATORS (ARITHMETIC)

## (1) **MODULUS**
Finds the remainder of a division operation

|Pseudocode|Python|VB|
|--|--|--|
|MOD|%|Mod|

EXAMPLE: This will output 0
```
DECLARE MyInteger as INTEGER
MyInteger = 9 MOD 3
OUTPUT MyInteger
```

EXAMPLE: This will output 1
```
DECLARE MyInteger as INTEGER
MyInteger = 9 MOD 4
OUTPUT MyInteger
```

## (2) **DIV**
Finds the value of a division operation (Rounded down to an integer)

|Pseudocode|Python|VB|
|--|--|--|
|DIV|//|\ (Backslash)|

EXAMPLE: THis will output 3
```
DECLARE MyInteger as INTEGER
MyInteger = 10 DIV 3
OUTPUT MyInteger
```

<br>

# OPERATORS (LOGIC)

## (1) **NOT**

|Pseudocode|Python|VB|
|--|--|--|
|NOT|!=|Not|

EXAMPLE: This will output to TRUE
```
DECLARE MyBoolean as BOOLEAN
MyBoolean = NOT FALSE
OUTPUT MyBoolean
```

## (2) **OR**

|Pseudocode|Python|VB|
|--|--|--|
|OR|or|Or|

Example: This will output to TRUE
```
DECLARE MyBoolean as BOOLEAN
MyBoolean = FALSE OR TRUE
OUTPUT MyBoolean
```

## (3) **AND**

|Pseudocode|Python|VB|
|--|--|--|
|AND|and|And|

Example: This will output to FALSE
```
DECLARE MyBoolean as BOOLEAN
MyBoolean = FALSE AND TRUE
OUTPUT MyBoolean
```

<br>

# INPUT AND OUTPUT

## (1) **INPUT**
Takes an input from the user and assigns that input to a variable

|Pseudocode|Python|VB|
|--|--|--|
|INPUT|input()|Console.Readline()|

EXAMPLE: This will input a name and then output it
```
DECLARE MyName as STRING
INPUT MyName
OUTPUT MyName
```
Python
```
MyName = input()
```
VB
```
MyName = Console.Readline()
```

## (2) **OUTPUT**
Prints out a variable or series of variables or strings to the console

|Pseudocode|Python|VB|
|--|--|--|
|OUTPUT|print()|Console.Writeline()|

EXAMPLE: This will output a string concatenated with a variable like so: "Hello NAME it's nice to finally meet you!"
```
OUTPUT "Hello " + MyName + " it's nice to finally meet you!"
```
Python
```
print("Hello " + MyName + " it's nice to finally meet you!")
```
VB
```
Console.Writeline("Hello " + MyName + " it's nice to finally meet you!")
```

<br>

# COUNT BASED LOOPS

## (1) **FOR**

```
FOR (integer variable with assignment) TO (maximum integer)
	(block of code that will be repeated
	with the integer variable available
	the amount of times set as maximum integer)
NEXT
```

EXAMPLE: Will output 1 all the way to 10
```
FOR i = 0 TO 10
	OUTPUT i
NEXT
```

<br>

# CONDITION BASED LOOPS

## (1) **WHILE**
Pre checks a condition before executing a loop until that condition is fulfilled

```
WHILE (condition) DO
	(block of code)
ENDWHILE
```

EXAMPLE: This code will keep printing out "Hello" until the counter has reached 10
```
DECLARE counter as INTEGER
counter = 0

WHILE counter <> 10 DO
	OUTPUT "Hello"
	counter = counter + 1
ENDWHILE
```

## (2) **REPEAT...UNTIL**
Executes its block of code before running a post-check on the condition until the condition returns truthy

```
REPEAT
	(block of code)
UNTIL (condition)
```

EXAMPLE: This code will FIRST ask for your password, and keep asking until the password is correct
```
DECLARE MyString as STRING

REPEAT
	OUTPUT "Please enter the password"
	INPUT MyString
UNTIL (MyString == "Password")
```

> **NOTE**: A key difference between REPEAT and WHILE loops is that REPEAT loops will run one iteration no matter what, before checking the condition, WHILE loops will check the condition before running any iterations

# SELECTION STATEMENTS

## (1a) **IF**
Executes a specific block of code if a condition evaluates to truthy (true)

```
IF (condition) THEN
    (block of code)
ENDIF
```

EXAMPLE: This code will output to "I am a student" only because the IAmStudent variable is TRUE
```
DECLARE IAmStudent as BOOLEAN

IAmStudent = TRUE

IF IAmStudent THEN
OUTPUT "I am a student"
ENDIF
```

## (1b) **IF..ELSE**
Executes a block of code if a condition evaluates to truthy, executes a different block if it evaluates to falsy (false)

```
IF (condition) THEN
    (truthy block of code)
ELSE
    (falsy block of code)
ENDIF
```

EXAMPLE: This code will output to "I am not a student" only because the IAmStudent variable is FALSE
```
DECLARE IAmStudent as BOOLEAN

IAmStudent = FALSE

IF IAmStudent THEN
    OUTPUT "I am a student"
ELSE
    OUTPUT "I am not a student"
ENDIF
```

## (2) **CASE**
Executes a block of code depending if a variable is a certain value

```
CASE OF (variable)
    (possible value): (statement)
    (another possible value): (statement)
    OTHERWISE: (statement if none else execute)
ENDCASE
```

EXAMPLE: This code will output "Yeehaw" because the occupation variable is "Cowboy"
```
DECLARE Occupation as STRING

Occupation = "Cowboy"

CASE OF Occupation
    "Policeman": OUTPUT "Wee woo wee woo"
    "Wrestler": OUTPUT "Smack!"
    "Cowboy": OUTPUT "Yeehaw"
    OTHERWISE: OUTPUT "Unemployed :/"
ENDCASE
```