Photo AI

Last Updated Sep 27, 2025

Languages and Boolean Logic Guide Simplified Revision Notes

Revision notes with simplified explanations to understand Languages and Boolean Logic Guide quickly and effectively.

user avatar
user avatar
user avatar
user avatar
user avatar

245+ students studying

Languages and Boolean Logic Guide

Variables

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

Casting

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

Outputting to Screen

print(string)

lightbulbExample

Example:

print("hello")

Taking Input from User

variable = input(prompt to user)

lightbulbExample

Example:

name = input("Please enter your name")

Iteration

Count Controlled

for i = 0 to 7
 print("Hello")
next i

Will print "Hello" 8 times (0–7 inclusive).

Condition Controlled

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"

Logical Operators

AND, OR, NOT

lightbulbExample

Example:

while x <= 5 AND flag == false

Comparison Operators

SymbolMeaning
==Equal to
!=Not equal to
<Less than
<=Less than or equal to
>Greater than
>=Greater than or equal to

Arithmetic Operators

OperatorFunctionExample
+Additionx = 6 + 5 → 11
-Subtractionx = 6 • 5 → 1
*Multiplicationx = 12 * 2 → 24
/Divisionx = 12 / 2 → 6
MODModulus12 MOD 5 → 2
DIVQuotient17 DIV 5 → 3
^Exponentiation3 ^ 4 → 81

Selection

If/Else

if entry == "a" then
 print("You selected A")
elseif entry == "b" then
 print("You selected B")
else
 print("Unrecognised selection")
endif

Switch/Case

switch entry:
 case "A":
  print("You selected A")
 case "B":
  print("You selected B")
 default:
  print("Unrecognised selection")
endswitch

String Handling

Length of a String:

stringname.length

Substring:

stringname.substring(startingPosition, numberOfCharacters)

(Strings start at the 0th character.)

lightbulbExample

Example:

someText = "Computer Science"

print(someText.length)
print(someText.substring(3, 3))

Subroutines

infoNote

Function Example

function triple(number)
 return number * 3
endfunction

// Called from main program
y = triple(7)

infoNote

Procedure Example

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

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])

infoNote

2D Array Example:

array board[8, 8]
board[0, 0] = "rook"

Reading and Writing Files

Reading

myFile = openRead("sample.txt")
x = myFile.readLine()
myFile.close()

Writing

myFile = openWrite("sample.txt")
myFile.writeLine("Hello World")
myFile.close()

Comments

Comments are denoted by //.

print("Hello World") // This is a comment
Books

Only available for registered users.

Sign up now to view the full note, or log in if you already have an account!

500K+ Students Use These Powerful Tools to Master Languages and Boolean Logic Guide

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 Flashcards

1 quizzes

Quizzes on Languages and Boolean Logic Guide

Test your knowledge with fun and engaging quizzes.

Try Computer Science Quizzes

29 questions

Exam questions on Languages and Boolean Logic Guide

Boost your confidence with real exam questions.

Try Computer Science Questions

27 exams created

Exam Builder on Languages and Boolean Logic Guide

Create custom exams across topics for better practice!

Try Computer Science exam builder

12 papers

Past Papers on Languages and Boolean Logic Guide

Practice past papers to reinforce exam experience.

Try Computer Science Past Papers

Other Revision Notes related to Languages and Boolean Logic Guide you should explore

Discover More Revision Notes Related to Languages and Boolean Logic Guide to Deepen Your Understanding and Improve Your Mastery

Load more notes

Join 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!

97% of Students

Report Improved Results

98% of Students

Recommend to friends

500,000+

Students Supported

50 Million+

Questions answered