OCR Exam Reference Language Flashcards

1
Q

Casting example

A

str(29)
int(“102”)
float(30)
bool(“False”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Random number

A

number = random(1100)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Iteration (for loop) example

A

for i = 1 to 10 step 1
input item
next i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Iteration (while loop) example

A

while firstname != “Steven”
firstname = input(“Try again:”)
endwhile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Length of a string example

A

word = “dictionary”
print(word.length)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

String cases example

A

phrase = “The Cat Sat On The Mat”
print(phrase.lower)
prin(phrase.upper)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

ASCII Conversion

A

ASC(“C”) returns 67
CHR(100) returns “d”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

File handling - writing to a (new) file example

A

newFile(“paint.txt”)
file2 = open(“paint.txt”)
paint = input(“Enter a paint colour:”)
file.writeLine(paint)
file2.close()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Declare arrays

A

array names[3]
array names = “Ella”, “Sam”, “Ali”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly