python code -- 4
Budget: $30 – $250 USD
1.Let s be a string that contains a sequence of decimal numbers
separated by commas, e.g., s = '1.23,2.4,3.123'. Write a Python code that gets s
from a user using the input statement and prints the sum of the numbers in s. You
may use a while statement to find the commas in the string, extract one number
in each execution of the loop and sum the numbers after all of them are extracted.
You may use the built-in string method, find.
2.Consider the recursive function, ?(?), such that ?(0) = √? and
?(? + 1) = (2? + 1)?(?)/2, meaning that ?(1) = √?⁄2, ?(2) = 3√?⁄4, etc.
Write a Python code that computes this function for a given value of x. The code
is expected to get a nonnegative integer, x, from a user using the input statement.
It is expected to have a recursive function to compute ?(?) and print it. Using a
regular function instead of a recursive function will cause loss of points. Assume
that the user correctly enters a nonnegative integer so that the code does not have
to check if it is properly entered
3.Consider the following function:
?(?, ?) =
2
√?
2
(−1)4?5467
?! (2? + 1)
:;7
4<=
=
2
√?
>? −
??
3
+ ⋯+
(−1):;7?5:;7
(? − 1)! (2? − 1)
A
Write a Python code that computes this function for a given value of x. The code
is expected to get a real number (float), 0 £ x £ 1, and a positive integer, k, from a
user using the input statement. It is expected to compute ?(?, ?) and print it. You
may directly use the math.factorial function to compute the factorials in ?(?, ?).
You may start with ?(?, ?) = 0 and use a for loop with range(k) to add each term
to ?(?, ?) = 0 in each execution of the loop. Assume that the user enters valid
numbers so that the code does not have to check if they are properly entered
separated by commas, e.g., s = '1.23,2.4,3.123'. Write a Python code that gets s
from a user using the input statement and prints the sum of the numbers in s. You
may use a while statement to find the commas in the string, extract one number
in each execution of the loop and sum the numbers after all of them are extracted.
You may use the built-in string method, find.
2.Consider the recursive function, ?(?), such that ?(0) = √? and
?(? + 1) = (2? + 1)?(?)/2, meaning that ?(1) = √?⁄2, ?(2) = 3√?⁄4, etc.
Write a Python code that computes this function for a given value of x. The code
is expected to get a nonnegative integer, x, from a user using the input statement.
It is expected to have a recursive function to compute ?(?) and print it. Using a
regular function instead of a recursive function will cause loss of points. Assume
that the user correctly enters a nonnegative integer so that the code does not have
to check if it is properly entered
3.Consider the following function:
?(?, ?) =
2
√?
2
(−1)4?5467
?! (2? + 1)
:;7
4<=
=
2
√?
>? −
??
3
+ ⋯+
(−1):;7?5:;7
(? − 1)! (2? − 1)
A
Write a Python code that computes this function for a given value of x. The code
is expected to get a real number (float), 0 £ x £ 1, and a positive integer, k, from a
user using the input statement. It is expected to compute ?(?, ?) and print it. You
may directly use the math.factorial function to compute the factorials in ?(?, ?).
You may start with ?(?, ?) = 0 and use a for loop with range(k) to add each term
to ?(?, ?) = 0 in each execution of the loop. Assume that the user enters valid
numbers so that the code does not have to check if they are properly entered