Pseudocode Guide
Pseudocode Guide
Cambridge:
OUTPUT “Hello!”
Edexcel:
SEND “Hello!” TO DISPLAY
Cambridge:
StudentName "Peter Mark"
StudentMark 75
OUTPUT StudentName
OUTPUT StudentMark
Edexcel:
SET StudentName TO “Peter Mark”
SET StudentMark TO 75
SEND StudentName TO DISPLAY
SEND StudentMark TO DISPLAY
Cambridge:
OUTPUT "The Name of student is: ",StudentName
OUTPUT StudentMark,"is the mark of the student"
OUTPUT StudentMark,"is the mark of",StudentName
Edexcel:
SEND "The Name of student is: " & StudentName TO DISPLAY
SEND StudentMark & "is the mark of the student" TO DISPLAY
SEND StudentMark & "is the mark of" & StudentName TO DISPLAY
Edexcel:
SEND "Enter student name:" TO DISPLAY
RECEIVE StudentName FROM (STRING) KEYBOARD
SEND "Enter student mark:" TO DISPLAY
RECEIVE StudentMark FROM (INTEGER) KEYBOARD
ComputerMrk = 75
EnglishMrk = 90
MathsMrk =70
TotalMrk = ComputerMrk + EnglishMrk + MathsMrk
AvgMrk = TotalMrk/3
print("The total marks is ",TotalMrk)
print ("The average is ", AvgMrk)
Edexcel:
Arithmetic Operators:
Addition : +
Subtraction : -
Multiplication : *
Division : /
Power Of : ^
SET ComputerMrk TO 75
SET EnglishMrk TO 90
SET MathsMrk TO 70
SET TotalMrk TO ComputerMrk + EnglishMrk + MathsMrk
SET AvgMrk TO TotalMrk/3
SEND "The total marks is " & TotalMrk TO DISPLAY
SEND "The average is " & AvgMrk TO DISPLAY
Cambridge:
Arithmetic Operators:
Addition : +
Subtraction : -
Multiplication : *
Division : /
Power Of : ^
ComputerMrk 75
EnglishMrk 90
MathsMrk 70
TotalMrk ComputerMrk + EnglishMrk + MathsMrk
AvgMrk TotalMrk/3
OUTPUT "The total marks is ",TotalMrk
OUTPUT "The average is ", AvgMrk
Example 6: Input two numbers and output the difference between the two
Python:
NumOne = int(input("Enter number one:"))
NumTwo = int(input("Enter number two:"))
Difference = NumOne - NumTwo
print("The difference is:",Difference)
Edexcel:
SEND “Enter number one: ” TO DISPLAY
RECEIVE NumOne FROM (INTEGER) KEYBOARD
SEND “Enter number two: ” TO DISPLAY
RECEIVE NumTwo FROM (INTEGER) KEYBOARD
SET Difference TO NumOne - NumTwo
SEND "The difference is:",Difference TO DISPLAY
Cambridge:
DECLARE NumOne, NumTwo, Difference : INTEGER
OUTPUT “Enter number one:"
INPUT NumOne
OUTPUT "Enter number two:"
INPUT NumTwo
Difference NumOne - NumTwo
OUTPUT "The difference is:",Difference
Example 7: Input the price of a chocolate bar and the number of bars purchased.
Calculate the total price for all the bars. Output the total price
Python:
ChocoPrice = float(input("Enter the price of a chocolate:"))
ChocoNum = int(input("Enter the number of chocolates:"))
TotPrice = ChocoPrice * ChocoNum
print("Total price for chocolate bars ", TotPrice)
Edexcel:
SEND “Enter the price of a chocolate” TO DISPLAY
RECEIVE ChocoPrice FROM (REAL) KEYBOARD
SEND “Enter the number of chocolatez” TO DISPLAY
RECEIVE ChocoNum FROM (INTEGER) KEYBOARD
SET TotPrice TO ChocoPrice * ChocoNum
SEND "Total price for chocolate bars " & TotPrice TO DISPLAY
Cambridge:
DECLARE ChocoPrice, TotPrice : REAL
DECLARE ChocoNum : INTEGER
OUTPUT “Enter the price of a chocolate”
INPUT ChocoPrice
OUTPUT “Enter the number of chocolates”
INPUT ChocoNum
TotPrice ChocoPrice * ChocoNum
OUTPUT "Total price for chocolate bars " TotPrice
Example 8: Input the body temperature in Celsius, convert it to Fahrenheit, and output the
Fahrenheit value
Python:
TempC = float(input("Enter the temperature in Celsius:"))
TempF = (TempC * (9/5))+ 32
print("The temperature in Fahrenheit is:", TempF)
Edexcel:
SEND “Enter the temperature in Celsius:” TO DISPLAY
RECEIVE TempC FROM (REAL) KEYBOARD
SET TempF TO (TempC*(9/5))+32
SEND “The temperature in Fahrenheit is:” & TempF TO DISPLAY
Cambridge:
DECLARE TempC, TempF : REAL
OUTPUT “Enter the temperature in celcius:”
INPUT TempC
TempF (TempC*(9/5))+32
OUTPUT “The temperature in Fahrenheit is:” ,TempF
Example 9 : A shop provides a discount of 40% for all the products sold.
Write a program to input the Name of a product, The price of the product
and the number of units sold(Quantity).
Calculate the total price
Calculate the Discount amount
Calculate the final amount to be paid
Output the Product Name, Number of units sold and the final amount
Python:
PName = str(input("Enter the product name "))
PPrice = float(input("Enter the product price "))
PQuantity = int(input("Enter the quantity "))
Cambridge:
DECLARE PName : String
DECLARE PPrice, TotPrice, DAmount, FinalAmt : Real
DECLARE PQuantity : Integer
Python:
BAmount = float(input("Enter the amount to borrow "))
Years = int(input("Enter the number of years "))
TotInterest = (BAmount*0.15)*Years
TotPay = TotInterest + BAmount
MonthlyAmt = TotPay/(12*Years)
Edexcel:
SET Interest TO 0.15
TotSecs = (Hours*3600)+(Minutes*60)+Seconds
print("Athlete Name: ", AName)
print("Race time in seconds: ",Seconds)
Cambridge:
DECLARE AName : String
DECLARE Hours, Minutes, Seconds, TotSecs : Integer
TotSecs (Hours*3600)+(Minutes*60)+Seconds
Edexcel:
SEND “Enter the athlete name” TO DISPLAY
RECEIVE AName FROM (String) KEYBOARD
SEND “Enter race time in Hours:” TO DISPLAY
INPUT Hours FROM (Integer) KEYBOARD
SEND “Enter race time in Minutes:” TO DISPLAY
INPUT Minutes FROM (Integer) KEYBOARD
SEND “Enter race time in Seconds:” TO DISPLAY
INPUT Seconds FROM (Integer) KEYBOARD
Python:
CostPerSt = 4 #Constant
Cambridge:
CONSTANT CostPerSt 4 #Constant
Edexcel:
SET CostPerSt TO 4 #Constant
Python:
StName = str(input("Enter Student Name"))
P1Mark = int(input("Enter P1 Mark "))
P2Mark = int(input("Enter P2 Mark "))
FinalMark = ((P1Mark/75)*60)+((P2Mark/50)*40)
Cambridge:
DECLARE StName : String
DECLARE P1Mark, P2Mark : Integer
DECLARE FinalMark : Real
FinalMark ((P1Mark/75)*60)+((P2Mark/50)*40)
Edexcel:
SEND “Enter Student Name” TO DISPLAY
RECEIVE StName FROM (String) KEYBOARD
SEND “Enter P1 Mark” TO DISPLAY
RECEIVE P1Mark FROM (Integer) KEYBOARD
SEND “Enter P2 Mark” TO DISPLAY
RECEIVE P2Mark FROM (Integer) KEYBOARD
if Num<0:
print('Its a Negative - Number')
else:
print('Its a Positive + Number')
Example 15: Following is to input the student name and computer paper mark(out of 75)
Calculate the mark out of 100
Output whether the student have pass the exam (40% or more)
Or failed the exam (Less than 40%) along with the student name
Python:
Name = input('Enter the student name ')
Mark = int(input('Enter the mark out of 75 '))
MarkPercentage = (Mark/75)*100
Example 16: Following program is to input 2 numbers, Calculate the difference between the
two number as a Positive Value and output the difference.
Python:
Relational Operators:
== : Equals to
!= : Not Equals to
> : Greater Than
< : Less Than
>= : Greater Than or Equals to
<= : Less Than or Equals to
Example 17: Following program is to input Two Numbers and a Sign (+ or -)
Calculate the Sum of the two numbers if the sign is +
Calculate the Difference of the two numbers if the sign is -
Display the result indicating whether it was + or - performed