1/10
Looks like no tags are added yet.
What is string manipulation?
Joining strings together using + e.g “your name is “ + name
Give the OCR Exam Reference Language + Python for: length
OCR - word.length
PYTHON - len(word)
Give the OCR Exam Reference Language + Python for: uppercase, lowercase
OCR - word.upper word.lower
PYTHON - word.upper() word.lower()
Give the OCR Exam Reference Language + Python for: part of a string
OCR - word.substring(start, length/end)
PYTHON - word[start : length/end]
word = "Computer". What are word.lengthand word.substring(0, 4)?
word.length is 8. word.substring(0, 4) is "Comp": 4 characters starting at position 0.
What do ASC("A") and CHR(97) return?
ASC("A") returns 65, the ASCII code. CHR(97)returns "a", the character for that code.
How do you open a file and read in OCR Exam Reference Language and Python?
OCR - myFile = open("data.txt")
PYTHON - myFile = open(“data.txt” , “r”)
How do you open a file and read every line in OCR Exam Reference Language and Python?
OCR - myFile = open("data.txt")
while NOT myFile.endOfFile()
line = myFile.readLine()
endwhile
myFile.close()
Python -myFile = open("data.txt", "r")
for line in myFile:
print(line.strip())
lines myFile.close()
How do you write to a file in OCR Exam Reference Language?
myFile = open("scores.txt").
myFile.writeLine("Alex,25")
myFile.close()
How do you create a new file in OCR Exam Reference Language?
Use newFile("name.txt") to create a new file.