Photo AI
Last Updated Sep 27, 2025
Revision notes with simplified explanations to understand Languages and Boolean Logic Guide quickly and effectively.
245+ students studying
Variables are assigned using the = operator.
x = 3
name = "Bob"
A variable is declared the first time a value is assigned. It assumes the data type of the value it is given. Variables declared inside a function or procedure are local to that subroutine.
Variables in the main program can be made global with the keyword global.
global userid = 123
Variables can be typecast using the int, str, and float functions.
str(3) returns "3"
int("3") returns 3
float("3.14") returns 3.14
print(string)
Example:
print("hello")
variable = input(prompt to user)
Example:
name = input("Please enter your name")
for i = 0 to 7
print("Hello")
next i
Will print "Hello" 8 times (0–7 inclusive).
While Loop:
while answer != "computer"
answer = input("What is the password?")
endwhile
Do Until Loop:
do
answer = input("What is the password?")
until answer == "computer"
AND, OR, NOT
Example:
while x <= 5 AND flag == false
Symbol | Meaning |
---|---|
== | Equal to |
!= | Not equal to |
< | Less than |
<= | Less than or equal to |
> | Greater than |
>= | Greater than or equal to |
Operator | Function | Example |
---|---|---|
+ | Addition | x = 6 + 5 → 11 |
- | Subtraction | x = 6 • 5 → 1 |
* | Multiplication | x = 12 * 2 → 24 |
/ | Division | x = 12 / 2 → 6 |
MOD | Modulus | 12 MOD 5 → 2 |
DIV | Quotient | 17 DIV 5 → 3 |
^ | Exponentiation | 3 ^ 4 → 81 |
if entry == "a" then
print("You selected A")
elseif entry == "b" then
print("You selected B")
else
print("Unrecognised selection")
endif
switch entry:
case "A":
print("You selected A")
case "B":
print("You selected B")
default:
print("Unrecognised selection")
endswitch
Length of a String:
stringname.length
Substring:
stringname.substring(startingPosition, numberOfCharacters)
(Strings start at the 0th character.)
Example:
someText = "Computer Science"
print(someText.length)
print(someText.substring(3, 3))
function triple(number)
return number * 3
endfunction
// Called from main program
y = triple(7)
procedure greeting(name)
print("Hello " + name)
endprocedure
// Called from main program
greeting("Hamish")
Values are passed by value unless stated otherwise. Use byVal and byRef for clarity if required.
Arrays are 0-based and declared using the array keyword.
array names[5]
names[0] = "Ahmad"
names[1] = "Ben"
names[2] = "Catherine"
names[3] = "Dana"
names[4] = "Elijah"
print(names[3])
array board[8, 8]
board[0, 0] = "rook"
myFile = openRead("sample.txt")
x = myFile.readLine()
myFile.close()
myFile = openWrite("sample.txt")
myFile.writeLine("Hello World")
myFile.close()
Comments are denoted by //.
print("Hello World") // This is a comment
Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!
10 flashcards
Flashcards on Languages and Boolean Logic Guide
Revise key concepts with interactive flashcards.
Try Computer Science Flashcards1 quizzes
Quizzes on Languages and Boolean Logic Guide
Test your knowledge with fun and engaging quizzes.
Try Computer Science Quizzes29 questions
Exam questions on Languages and Boolean Logic Guide
Boost your confidence with real exam questions.
Try Computer Science Questions27 exams created
Exam Builder on Languages and Boolean Logic Guide
Create custom exams across topics for better practice!
Try Computer Science exam builder12 papers
Past Papers on Languages and Boolean Logic Guide
Practice past papers to reinforce exam experience.
Try Computer Science Past PapersDiscover More Revision Notes Related to Languages and Boolean Logic Guide to Deepen Your Understanding and Improve Your Mastery
Load more notesJoin 500,000+ A-Level students using SimpleStudy...
Join Thousands of A-Level Students Using SimpleStudy to Learn Smarter, Stay Organized, and Boost Their Grades with Confidence!
Report Improved Results
Recommend to friends
Students Supported
Questions answered