2.2.3 Additional programming techniques

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/10

encourage image

There's no tags or description

Looks like no tags are added yet.

11 Terms

1
New cards

What is string manipulation?

Joining strings together using + e.g “your name is “ + name

2
New cards

Give the OCR Exam Reference Language + Python for: length

OCR - word.length

PYTHON - len(word)

3
New cards

Give the OCR Exam Reference Language + Python for: uppercase, lowercase

OCR - word.upper word.lower

PYTHON - word.upper() word.lower()

4
New cards

Give the OCR Exam Reference Language + Python for: part of a string

OCR - word.substring(start, length/end)

PYTHON - word[start : length/end]

5
New cards

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.

6
New cards

What do ASC("A") and CHR(97) return?

ASC("A") returns 65, the ASCII code. CHR(97)returns "a", the character for that code.

7
New cards

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

8
New cards

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

9
New cards

How do you write to a file in OCR Exam Reference Language?

myFile = open("scores.txt")
myFile.writeLine("Alex,25")
myFile.close()
.

10
New cards

How do you create a new file in OCR Exam Reference Language?

Use newFile("name.txt") to create a new file.

11
New cards