Summary OCR EXAM REFERENCE LANGUAGE TO PYTHON GUIDE - BY CSandRS
14 views 0 purchase
Course
Computing
Institution
GCSE
Contains all the ERL (OCR exam reference language) listed out in the OCR specification alongside how to write the same in PYTHON. For J277 OCR GCSE. Contains all the Advanced PYTHON topics you need (like functions, file handling, string manipulation etc). I also have separate notes for paper 1 & 2 ...
PYTHON OCR REFERENCE LANGUAGE
SELECTION
If/elseif
if pi == 3.14: if pi == 3.14 then
print(“Good”) print("Good")
elif pi == 3: elseif pi == 3 then
print(“ok...”) print("ok...")
else: else
print(“wrong!”) print("wrong!")
endif
Switch/case
match name: switch name:
case "1": case "1":
print("1") print("1")
case "2": case "2":
print("2") print("2")
case default: default:
print("????") print("????")
endswitch
ITERATION
FOR (count-controlled)
for count in range(1,11,2): for count = 1 to 10 step 2
# 11 is exclusive print(count)
print(count) next count
WHILE (condition controlled) - pre-check. Might never run
while continue == “Y” While continue == “Y”
continue = input(“continue?”) continue = input(“continue?”)
endwhile
DO…UNTIL (condition controlled) - post-check. Will run at least once
do
continue = input(“continue?”)
until continue == “N”
STRING MANIPULATION text = “Hello”
What it does PYTHON ERL Return: “Hello”
Count the number of characters in a len(text) text.length 5
string
Extract characters from a string text[1:5] [x:y]: text.substring[1:4] [x:y]: ello
x: first character x: first character
y: last (exclusive) y: number of characters incl x
Slice characters from left/right - text.left(2) / text.right(2) He / lo
Convert string to UPPERCASE text.upper() text.upper HELLO
Convert string to LOWERCASE text.lower() text.lower hello
Concatenate/Join strings + + -
Finds ASCII value of the character ord(“A”) ASC(A) 65
Finds the character corresponding to chr(65) CHR(65) A
the ASCII value
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller CSandRS. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.87. You're not tied to anything after your purchase.