Exercise 7.2#
Question 1#
Calculate the following sum using a for
loop:
(The answer is
Question 2#
Find and print the first for
loop:
Question 3#
Write some code that takes a string as an input and prints it out with spaces inserted between each character. Make sure not to insert spaces before and after the string.
Question 4#
Write some code that will calculate the Taylor series expansion of
, using the first terms. Both and must be provided by the user. Remember:Hint: You could use math.factorial OR you could calculate a running factorial in the loop.
Bonus: modify your code above to print out the solution in the form:
“e^5 = 1 + 5 + 5^2 /2! + 5^3 /3! + 5^4 /4! = 65.375”
where the user has chosen and in this example (make your code work in the general case).