16 Flashcards
Why is the % character a “modulus” and not a “percent”?
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 does % work?
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.
close
Closes the file. Like File->Save.. in your editor.
read
read – Reads the contents of the file. You can assign the result to a variable.
readline
readline – Reads just one line of a text file.
truncate
truncate – Empties the file. Watch out if you care about the file.
write(‘stuff’)
write(‘stuff’) – Writes “stuff” to the file.