gs gs109 Python Functions - Python Function - Quiz No.1
gs gs109 Python Quiz
This quiz belongs to book/course code gs gs109 Python of gs organization. We have 134 quizzes available related to the book/course Python. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Python Functions. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: Which of the following is the use of function in python?
Functions are reusable pieces of programs
Functions don’t provide better modularity for your application
you can’t also create your own functions
All of the mentioned
Question 2: Which keyword is used for function?
Fun
Define
def
Function
Question 3: What will be the output of the following Python code?
def sayHello(): print('Hello World!') sayHello() sayHello()
Hello World! Hello World!
'Hello World!' 'Hello World!'
Hello Hello
None of the mentioned
Question 5: What will be the output of the following Python code?
x = 50 def func(x): print('x is', x) x = 2 print('Changed local x to', x) func(x) print('x is now', x)
x is 50 Changed local x to 2 x is now 50
x is 50 Changed local x to 2 x is now 2
x is 50 Changed local x to 2 x is now 100
None of the mentioned
Question 6: 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)
x is 50 Changed global x to 2 Value of x is 50
x is 50 Changed global x to 2 Value of x is 2
x is 50 Changed global x to 50 Value of x is 50
None of the mentioned
Question 7: What will be the output of the following Python code?
def say(message, times = 1): print(message * times) say('Hello') say('World', 5)
Hello WorldWorldWorldWorldWorld
Hello World 5
Hello World,World,World,World,World
Hello HelloHelloHelloHelloHello
Question 8: What will be the output of the following Python code?
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 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
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
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
None of the mentioned
Question 9: What will be the output of the following Python code?
def maximum(x, y): if x > y: return x elif x == y: return 'The numbers are equal' else: return y print(maximum(2, 3))
2
3
The numbers are equal
None of the mentioned
Question 10: Which of the following is a feature of DocString?
Provide a convenient way of associating documentation with Python modules, functions, classes, and methods
All functions should have a docstring
Docstrings can be accessed by the __doc__ attribute on objects
All of the mentioned