Programming for mathematics
Warm-upComputationalWhat is the value of x after these three lines run?
x = 3
x = x + 4
x = 2 * x
What is the value of x after these three lines run?
x = 3
x = x + 4
x = 2 * x
What does the Python line count = count + 1 do?
Write the binary number in decimal.
Write in binary, without leading zeros. (Type just the digits, for example 101.)
What does this program print?
total = 0
for i in range(1, 6):
if i % 2 == 1:
total = total + i
print(total)
In Python, 0.1 + 0.2 == 0.3 evaluates to False. Why?
The uniqueness proof for binary representations starts: “the last binary digit of must be the remainder of on division by ”. Why is that true?
Write to_binary(n) that returns the binary representation of a whole number n as a string without leading zeros, using repeated division by 2 (don't use Python's built-in bin). to_binary(0) should be "0".
This function is meant to compute . It runs without any error — but it is wrong. Find and fix the bug. Then check your fixed version against the formula .
In the Lean section, which of these machine-checked statements tells you that the sum equals ?