What is the output of the code snippet

Assignment Help Other Subject
Reference no: EM132584897

Assignment Questions -

Q1. Which of the following items are present in the function header?

A. function name

B. parameter list

C. return value

D. Both A and B

Q2. Which of the following function headers is correct?

A. def fun(a = 2, b = 3, c)

B. def fun(a = 2, b, c = 3)

C. def fun(a, b = 2, c = 3)

D. def fun(a, b, c = 3, d)

Q3. Which of the following function definition does not return any value?

A. a function that prints integers from 1 to 100.

B. a function that returns a random integer from 1 to 100.

C. a function that checks whether the current second is an integer from 1 to 100.

D. a function that converts an uppercase letter to lowercase.

Q4. "Which of the following statements correctly Represent the function body in the given code snippe"

A. . return "number"

B. print(number)

C. print("number")

D. return number

Q5 "What is the output of the following code snippet?

def func(message, num = 1):

print(message * num)

func('Welcome')

func('Viewers', 3)

A. Welcome Viewers

B. Welcome ViewersViewersViewers

C. Welcome Viewers,Viewers,Viewers

D. Welcome

Q6 "def myfunc(text, num):

while num > 0:

print(text)

num = num - 1

myfunc('Hello', 4)

A. HelloHelloHelloHelloHello

B. HelloHelloHelloHello

C. invalid call

D. infinite loop

Q7 "What is the output of the following code snippet?

def func(x = 1, y = 2):

x = x + y

y += 1

print(x, y)

func(y = 2, x = 1)

A. 13

B. 23

C. 32

D. 33

Q8. "num = 1

def func():

num = num + 3

print(num)

func()

print(num)

A. 1 4

B. 41

C. The program has a runtime error because the local Variable 'num' referenced before assignment.

D. 11

Q9. What is the output of the following code snippet?

exp = lambda x: x ** 3

print(exp(2))

A. 6

B. 222

C. 8

D. None of the above

Q10 "def f(a, b = 1, c = 2):

print('a is: ',a, 'b is: ', b, 'c is: ', c)

f(2, c = 2)

f(c = 100, a = 110)

A - a is: 2 b is: 1 c is: 2 a is: 110 b is: 1 c is: 100

B - a is: 2 b is: 2 c is: 2 a is: 110 b is: 2 c is: 100

C - a is: 0 b is: 2 c is: 2 a is: 110 b is: 0 c is: 100

D - a is: 110 b is: 0 c is: 100 a is: 110 b is: 0 c is: 100

Q11. How are lambda functions useful? Select all that apply:

A. Lambda functions are used for functional programming.

B. They are useful in allowing quick calculations or processing as the input to other functions.

C. ALL

D. They can be useful as quick, throwaway single line functions

Q12. What is the return type of function id?

A. float

B. bool

C. dict

D. Int

Q13. Select all the correct statements.

A. You can pass positional arguments in any order

B. You can call a function with positional and keyword arguments.

C. You can pass keyword Arguments in any orde

D. Positional arguments must be before Keyword arguments in a function call.

Q14. Documentation string is written as

A. #This is pytohn

B. >>>this is pytohn

C. '''this is python'''

D. ?this is python?

Q15 Function Call is written as

a. functionname

b. functioname(parameters)

c. functionname,parameters

d. None

Q16. Select which true for Python function

A. A function is a code block that only executes when it is called.

B. Python function always returns a value.

C. A function only executes when it is called and we can reuse it in a program

D. ALL

Q17. What is the output of the following function call

def fun1(name, age=20):

print(name, age)

fun1('Emma', 25)

A. Emma 25

B. Emma 20

C. Error

D. TRUE

Q18. Given the following function fun1() Please select the correct function calls

def fun1(name, age):

print(name, age)

A. fun1(name='Emma', age=23)

B. fun1(name='Emma', 23)

C. fun1('Emma', 23)

D. Error

Q19. def displayPerson(*args):

for i in args:

print(i)

displayPerson(name=""Emma"", age=""25"")

A. TypeError

B. Emma 25

C. name Age

D. Emma 25 name age

Q20. Choose the correct function declaration of fun1() so that we can execute the following function call successfully

fun1(25, 75, 55)

Fun1(10, 20)

A. def fun1(**kwargs)

B. No, it is not possible in Python

C. def fun1(args*)

D. def fun1(*data

Q21. def outerFun(a, b):

def innerFun(c, d):

return c + d

return innerFun(a, b)

res = outerFun(5, 10)

print(res)

A. 10

B. 15

C. (5, 10)

D. Syntax Error

Q22. "def fun1(num):

return num + 25

fun1(5)

print(num)

A. 25

B. 5

C. NameError

D. Type Eror

Q23. def add(a, b):

return a+5, b+5

result = add(3, 2)

print(result)

A. 15

B. 8

C. (8, 7)

D. Syntax Error

Q24. def display(**kwargs):

for i in kwargs:

print(i)

display(emp=""Kelly"", salary=9000)

A. TypeError

B. Kelly 9000

C. ('emp', 'Kelly') ('salary', 9000)

D. emp Salary

Q25. Python function always returns a value

A. FALSE

B. TRUE

Q26. What is the output of the following piece of code?

def a(b):

b = b + [5]

c = [1, 2, 3, 4]

a(c)

print(len(c))

A. 4

B. 5

C. 2

D. 1

Q27. Which of the following is an invalid variable?

A. my_string_1

B. 1st_string

C. foo

D.  _

Q28. What is called when a function is defined inside a class?

A. A Module

B. Class

C. Another function

D. Method

Q29. What gets printed?

name = ""snow storm""

name[5] = 'X'

print(name)

A. snow storm

B. snowXstorm

C. snow Xtorm

D. ERROR, this code will not run

Q30. def simpleFunction():

"This is a cool simple function that returns 1"

return 1

print(simpleFunction.__doc__[10:14])

A. simpleFunction

B. simple func

C. funtion

D. cool

Q31. values = [1, 2, 1, 3]

nums = set(values)

def checkit(num):

if num in nums:

return True

else:

return False

for i in filter(checkit, values):

print(i)

A. 1 2 3

B. 1 2 1 3

C. 1 2 1 3 1 2 1 3

D. Syntax Error

Q32. Values = [2, 3, 2, 4]

def my_transformation(num):

return num ** 2

for i in map(my_transformation, values):

print(i)

A. 2 3 2 4

B. 1 1 1 2

C. 4 9 4 16

D. 4 6 4 8

Q33. def sayHello():

print('Hello World!')

sayHello()

sayHello()

A. 'Hello World!'

'Hello World!'

B. Hello World!

Hello World!

C. Hello World!

D. 'Hello World!'

Q34. def printMax(a, b):

if a > b:

print(a, 'is maximum')

elif a == b:

print(a, 'is equal to', b)

else:

print(b, 'is maximum')

PrintMax(3, 4)

A. 3

B. 4

C. 4 is maximum

D. None of the mentioned

Q35. x = 50

def func(x):

print('x is', x)

x = 2

print('Changed local x to', x)

func(x)

print('x is now', x)

A. x is now 50

B. x is now 2

C. x is now 100

D. None of the mentioned

Q36. What will be the output of the following Python code?

x = 50

def func():

global x

print('x is', x)

x = 2

print('Changed global x to', x)

func()

print('Value of x is', x)

A. x is 50 Changed global x to 2 Value of x is 50

B. x is 50 Changed global x to 2 Value of x is 2

C. x is 50 Changed global x to 50 Value of x is 50

D. None of the mentioned

Q37. What will be the output of the following Python code?

def say(message, times = 1):

print(message * times)

say('Hello')

say('World', 5)

A. Hello WorldWorldWorldWorldWorld

B. Hello World 5

C. Hello World,World,World,World,World

D. Hello HelloHelloHelloHelloHello

Q38. def func(a, b=5, c=10):

print('a is', a, 'and b is', b, 'and c is', c)

func(3, 7)

func(25, c = 24)

func(c = 50, a = 100)

a)

A. a is 7 and b is 3 and c is 10

a is 25 and b is 5 and c is 24

a is 5 and b is 100 and c is 50

B. a is 3 and b is 7 and c is 10

a is 5 and b is 25 and c is 24

a is 50 and b is 100 and c is 5

C. a is 3 and b is 7 and c is 10

a is 25 and b is 5 and c is 24

a is 100 and b is 5 and c is 50

D. none

Q39. def maximum(x, y):

if x > y:

return x

elif x == y:

return 'The numbers are equal'

else:

return y

print(maximum(2, 3))

A. 2

B. 3

C. The numbers are equal

D. None of the mentioned

Q40. Local variable is:

A. Variale defined within the function

B. variable defined oudie the function

C. varialle defined in python code

D. None of these

Q41. Gloal variable is:

A. Variale defined within the function

B. variable defined oudie the function

C. varialle defined in python code

D. None of these

Reference no: EM132584897

Questions Cloud

The risk-free security and the market portfolio : Explain how differences in allocations between the risk-free security and the market portfolio can determine the level of market risk.
Discuss importance of inventory management : Discuss Importance of Inventory management.
Capital budgeting techniques- net present value method : Explain the net present value (NPV) method for determining a capital budgeting project's desirability.
What manifestations might you observe for patient with ards : What manifestations might you observe for a patient with ARDS? What complications can Mr. Nguyen develop from being mechanically ventilated?
What is the output of the code snippet : What is the output of the following code snippet and Which of the following statements correctly Represent the function body in the given code snippe
What is the stock new required rate of return : In addition, expected inflation increases by 2.00%. What is the stock's new required rate of return?
Describe the method of disseminating the results : The dissemination of EBP results serves multiple important roles. Sharing results makes the case for your decisions. It also adds to the body of knowledge.
In describing confidence intervals on mean : In describing confidence intervals on a mean, z and t intervals are frequently mentioned. How are z and t confidence intervals different?
What is the annualized rate of return on investments : 1. Mrs. Kapoor has been accumulating mutual funds over the past two years. She decides to sell her holdings on January 31, 2017

Reviews

Write a Review

Other Subject Questions & Answers

  Characterize the corporate strategy adopted by telefonica

Go back in time to 1986. Do a SWOT analysis for Telefonica de Espana. Does your analysis lead to the same conclusions as Telefonica's managers? How would you characterize the corporate strategy adopted by Telefonica?

  Clarify the federal government's division of powers

Analyze the federal government's division of powers between its three branches. How do parties resolve disputes pertaining to jurisdiction court and laws to be applied to a case?

  Write an press release about an employee lawsuit

Select a press release about an employee lawsuit published within the last six months. Search the Internet to find at least one news item about this lawsuit.

  Determine which theoretical public health model was used

After you have selected and reviewed details about this campaign, evaluate the campaign to determine which theoretical PUBLIC HEALTH model was used.

  How do appeals change when audience or subject matter change

How do appeals change when the audience or subject matter changes? What about the ads tell you that they are appealing to that audience(s)?

  How did the speaker gain the audience attention

How did the speaker gain the audience's attention? Explain the topic and purpose of the speech. Describe any facts or explanations given to support the speaker's argument or topic of discussion

  Examine the cognitive changes

Examine the cognitive changes associated with the selected developmental stage. Examine the emotional changes associated with the selected developmental stage

  Social problems in society from a sociological viewpoint

One of the most crucial components to this course concerns addressing social problems in society from a sociological viewpoint as opposed to a strictly policy

  Identify departmental and organizational survey

Identify departmental and organizational survey readiness for accreditation, licensing and/or certification processes

  Examine the ethical challenges that zappos faces

Analyze the manner in which Zappos leadership has fostered a culture of ethicalness in the company. Suggest two (2) actions that other companies can take in order to mimic this culture.

  Introduction to marketing for hospitality and tourism

Subject Description - (MGK1103 Principles of Marketing) An Introduction to Marketing for Hospitality and Tourism - Service characteristics of Hospitality and Tourism Marketing

  Define processes permitted by our professional license

We must know and get familiar with the procedures, actions, and processes permitted by our professional license. Review the following article.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd