Consider there is a list i.e. listA = {20, 10, 5, 15, 3} Write python code that: a. Creates a function updateListA(), which takes listA as input parameter, adds 30 after 20, and adds 40 at the end of the listA. [Hint: create a parameterized function] b. Creates a function newList(), which takes listA as input parameter and creates a new list newList with same elements as listA but in reverse order. c. If there is a function defined as below: def example(par1, par2=30): print(‘valid’) From the following function calls: i. example(par1=1) ii. example(1, 2) iii. example(par2=1) iv. example(par1=5, par2=6) Which call is valid? Write the values of par1 and par2 if a call is valid? Suggest corrections if a call is invalid.
Consider there is a list i.e. listA = {20, 10, 5, 15, 3} Write python code that: |
|
a. Creates a function updateListA(), which takes listA as input parameter, adds 30 after 20, and adds 40 at the end of the listA. [Hint: create a parameterized function] |
|
b. Creates a function newList(), which takes listA as input parameter and creates a new list newList with same elements as listA but in reverse order. |
|
c. If there is a function defined as below: def example(par1, par2=30): print(‘valid’)
From the following function calls: i. example(par1=1) ii. example(1, 2) iii. example(par2=1) iv. example(par1=5, par2=6) Which call is valid? Write the values of par1 and par2 if a call is valid? Suggest corrections if a call is invalid. |
|
Trending now
This is a popular solution!
Step by step
Solved in 2 steps