Question: The following corresponds to python coding. Please answer, these are very short, thank you. a) What is the printed value of this code? def add(a,b=1):

The following corresponds to python coding. Please answer, these are very short, thank you.

a) What is the printed value of this code? def add(a,b=1): return(a+b) n=add(2) n=add(n,n) print(n)

a.4

b.3

c.6

d.7

e.5

----

b) What's the output of this code?

mammals = ["human", "monky", "mouse", "rat", "cat", "dog"] mammals[3:5] = ["horse", "elephant"] mammals.sort() print(mammals)

a. ["human", "monky", "mouse", "rat", "cat", "dog"]

b. ['mouse', 'monky', 'human', 'horse', 'elephant', 'dog']

c. ['human', 'monky', 'mouse', 'horse', 'elephant', 'dog']

d. ['dog', 'elephant', 'horse', 'human', 'monky', 'mouse']

---

c) The following code generates an error. Why? import math print(sin(math.pi/2))

a. The function should be 'sine', not 'sin'

b. sin function is missing 'math.' prefix.

c. pi is not defined in the math package

d. 'import' should be replaced with 'from'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!