16 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Why is the % character a “modulus” and not a “percent”?

A

Mostly that’s just how the designers chose to use that symbol. In normal writing you are correct to read it as a “percent.” In programming this calculation is typically done with simple division and the / operator. The % modulus is a different operation that just happens to use the % symbol.

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

How does % work?

A

Another way to say it is, “X divided by Y with J remaining.” For example, “100 divided by 16 with 4 remaining.” The result of % is the J part, or the remaining part.

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

close

A

Closes the file. Like File->Save.. in your editor.

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

read

A

read – Reads the contents of the file. You can assign the result to a variable.

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

readline

A

readline – Reads just one line of a text file.

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

truncate

A

truncate – Empties the file. Watch out if you care about the file.

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

write(‘stuff’)

A

write(‘stuff’) – Writes “stuff” to the file.

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