2.2 Programming techniques Flashcards

1
Q

How to change case of variable

A

Pseudocode:
* Variable.upper/lower

Python:
* Variable.upper/lower()

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

How to find length of a variable

A

Pseudocode:
* Variable.length

Python:
* len(Variable)

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

How to convert something to ASCII

A

Pseudocode:
* ASC(A)

Python:
* ord(“A”)

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

How to convert ASCII to letter

A

Pseudocode:
* CHR(97)

Python:
* chr(97)

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

File handling

Open file

A

Pseudocode:
file = open(“fruit.txt”)

Python:
file = open(“fruit.txt”,”r”)

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

File Handling

Close file

A

file.close()

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

File handling

Readline

A

file.readline()

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

File handling

Writeline

A

Psuedocode:
file.writeline(“Oranges”)

Python:
file.write(“Oranges”)

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

File handling

New file

A

Pseudocode:
newFile(“Shopping.txt”)

Python:
file = open(“shopping.txt”,”w”)

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

Fields and records

A

Fields define the columns in a table, specifying what kind of data can be stored in each column.

Records represent the rows in a table, each row containing data for a specific instance of the entity being stored.

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

Functions vs procedures

A

a function returns a value, while a procedure does not

procedures could be printing something

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

Random numbers

A

Pseudocode:
number = random(1,10)

Python:
import random
number = random.randint(1,10)

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