QUESTIONS AND CORRECT DETAILED ANSWERS
WITH RATIONALES
What is a program? CORRECT ANSWER-a set of instructions that a computer follows to perform a task
What is a compiler? CORRECT ANSWER-
A compiler converts the whole program into machine code before it is run.
What does 2**2 do CORRECT ANSWER-This will raise 2 by the 2 power
What does // do CORRECT ANSWER-This is integer division (division without remainder)
- eg 7 // 3 = 2
What does % do in python? CORRECT ANSWER-This is modulus sign (remainder from division)
- eg 7%3 = 1
What angles do trig functions use? CORRECT ANSWER-Radians
What is the computer memory hierarchy CORRECT ANSWER-Fastes - CPU registers
Cache
Main memory
Secondary memory (Files)
Slowest Offline Memory
As you go from the cpu registers to the offline memory, what happens CORRECT
ANSWER-- slower to access
- more total data
- more long lasting/permanent
, What are variables? CORRECT ANSWER-Boxes of memory
For a variable name, what does it have to start with CORRECT
ANSWER- Has to start either with a letter to an underscore
- cannot start with a number
- and cannot be and reserved keyword like while or if
What is the order of assignment of variables CORRECT ANSWER-
First we evaluate the RHS, then assign that value to the LHS
What are the integers? CORRECT ANSWER-whole numbers and their negatives
What are floating point numbers? CORRECT ANSWER-numbers with decimal points, positive or negative
What re Boolean? CORRECT ANSWER-True or False
What is a string? CORRECT ANSWER-A sequence of characters, or text
How would you add a quotation to a string CORRECT ANSWER-
Add a back slash to specify which character you want to print
- eg 'He said "i\m tired."'
How to print one backslash CORRECT ANSWER-\\
How to print a tab CORRECT ANSWER-\t
how to print on a new line CORRECT ANSWER-\n
How to print a backspace CORRECT ANSWER-\b