The exponentiation operator in python is **
. You might have seen the ^
character on your calculator. They do the same thing.
For example :
2**2 = 4
3**3 = 27
25**0.5 = 5
Compute $2^{10}$:
Write a function kthDigit
that takes two integer arguments n
and k
and returns the k-th digit of n
?
For example :
kthDigit(567, 2)
should return 6
kthDigit(324877, 5)
should return 2
kthDigit(235468, 1)
should return 8
Write a function kEdit
that takes three integer arguments n
, k
, and e
with $0 \leq e \leq 9$ that replaces the k
-th digit of n
with e
.
Examples :
kEdit(1234, 2, 0)
should return 1204
kEdit(34578, 3, 1)
should return 34178
An RGB value is three colors that combine to make up one color. Write a function rgbconvert
that takes in a 9 digit integer n
, and returns 3 integers that represents each RGB value.
Examples:
rgbconvert(255255255)
=> 255, 255, 255
rgbconvert(132234075)
=> 132, 234, 75
Given this code:
x = 12
y = 5
z = y
y = 12
x = 1
z = x + y + z
what is the value of z? Verify your solution by running the code above.
Given this code:
z = 5 * (12 % 1) / 18
x = 23 - 14
y = x * z
z = 2 * x
what is the value of z? Verify your solution by running the code above.
Given this code:
d = 1
c = d
b = c
a = b
what is the value of a? Verify your solution by running the code above.