1
2
3
4
5
6
7
8
9
10
11
12
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to Trinket.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11
0
0
0
0
Type the modulo operator | % | ^ *% *$ | |
What is the name of this operator (one word, lowercase)? | % | modulo | ^ *modulo *$ |
Write the code that finds the remainder when 8 is divided by 3. | 8 % 3 | 8 `% `3 | |
Find the remainder when you divide 12 by 3. Assign the result to the variable left_over. | left_over = 12 % 3 | left_over = 12 % 3 | |
Code the shorthand version of the following statement: | total = total + 5 | total += 5 | ^ *total \+= 5 *$ |
Code the shorthand version of the following statement: | loss = loss - 5 | loss -= 5 | ^ *loss -= 5 *$ |
Find the remainder when you divide one number by another and assign the result to a variable. Make up the numbers and the variable name. | left_over = 3 % 2 | ^ *[a-zA-Z_][a-zA-Z0-9_]* = [-]?(?:[.]\d+|\d+(?:[.]\d*)?) % [-]?(?:[.]\d+|\d+(?:[.]\d*)?) *$ | |
Use shorthand code to multiply a variable by a number and assign the result to the same variable. Make up the variable name and the number. | result *= 14 | ^ *[a-zA-Z_][a-zA-Z0-9_]* \*= [-]?(?:[.]\d+|\d+(?:[.]\d*)?) *$ | |
Find what's left over when you divide one variable by another and assign the result to a third variable. Make up the variable names. | x = y % z | ^ *[a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]* % [a-zA-Z_][a-zA-Z0-9_]* *$ | |
Using shorthand code, subtract one variable from another and assign the result to the first variable. Make up the variable names. | x -= y | ^ *[a-zA-Z_][a-zA-Z0-9_]* -= [a-zA-Z_][a-zA-Z0-9_]* *$ | |
| 1d58b19f80 | ||
| 4c60daa23f |