lab4-extra¶
powers(n, k)
¶
A function powers(n, k)
that returns the list
[1, n, n^2, n^3, ..., n^k]
where k
is an integer. Note that
there should be k + 1
elements in the list.
Example:
In [ ]: powers(2, 3)
Out[ ]: [1, 2, 4, 8]
In [ ]: powers(0.5, 2)
Out[ ]: [1.0, 0.5, 0.25]
seq_mult_scalar(a, s)
¶
Write a function seq_mult_scalar(a, s)
which takes a list of numbers
a
and a scalar (i.e. a number) s
. For the input
a = [a0, a1, a2,.., an]
the function should return
[s * a0, s * a1, s * a2, ..., s * an]
.
Example:
In [ ]: seq_mult_scalar([-4, 9, 1], 10)
Out[ ]: [-40, 90, 10]
Please include the extra tasks in your file lab4.py
and submit as lab4 assignment.
Back to lab4.
End of lab4-extra.