Functions in Python

Descrição

Coding Python Quiz sobre Functions in Python, criado por PathaPadha Support em 27-10-2020.
PathaPadha Support
Quiz por PathaPadha Support, atualizado more than 1 year ago
PathaPadha Support
Criado por PathaPadha Support mais de 3 anos atrás
861
0

Resumo de Recurso

Questão 1

Questão
Given the following function fun1() Please select the correct function calls def fun1(name, age): print(name, age)
Responda
  • fun1(name=’Emma’, age=23)
  • fun1(name=’Emma’, 23)
  • fun1(‘Emma’, 23)

Questão 2

Questão
What is the output of the following function call def fun1(num): return num + 25 fun1(5) print(num)
Responda
  • 25
  • 5
  • NameError

Questão 3

Questão
What is the output of the following function call def outerFun(a, b): def innerFun(c, d): return c + d return innerFun(a, b) return a result = outerFun(5, 10) print(result)
Responda
  • 5
  • 15
  • (15, 5)
  • Syntax Error

Questão 4

Questão
Choose the correct function declaration of fun1() so that we can execute the following function call successfully fun1(25, 75, 55) fun1(10, 20)
Responda
  • def fun1(**kwargs)
  • No, it is not possible in Python
  • def fun1(args*)
  • def fun1(*data)

Questão 5

Questão
What is the output of the add() function call def add(a, b): return a+5, b+5 result = add(3, 2) print(result)
Responda
  • 15
  • 8
  • (8, 7)
  • Syntax Error

Questão 6

Questão
What is the output of the following displayPerson() function call def displayPerson(*args): for i in args: print(i) displayPerson(name="Emma", age="25")
Responda
  • TypeError
  • Emma 25
  • name age

Questão 7

Questão
What is the output of the following function call def fun1(name, age=20): print(name, age) fun1('Emma', 25)
Responda
  • Emma 25
  • Emma 20

Questão 8

Questão
What is the output of the following display() function call def display(**kwargs): for i in kwargs: print(i) display(emp="Kelly", salary=9000)
Responda
  • TypeError
  • Kelly 9000
  • (’emp’, ‘Kelly’) (‘salary’, 9000)
  • emp salary

Questão 9

Questão
Select which true for Python function
Responda
  • A function is a code block that only executes when it is called.
  • Python function always returns a value.
  • A function only executes when it is called and we can reuse it in a program
  • Python doesn’t support nested function

Questão 10

Questão
What is the output of the following code def outerFun(a, b): def innerFun(c, d): return c + d return innerFun(a, b) res = outerFun(5, 10) print(res)
Responda
  • 15
  • Syntax Error
  • (5, 10)

Questão 11

Questão
Select which is true for Python function
Responda
  • A Python function can return only a single value
  • A function can take an unlimited number of arguments.
  • A Python function can return multiple values
  • Python function doesn’t return anything unless and until you add a return statement

Questão 12

Questão
Python function always returns a value
Responda
  • True
  • False

Semelhante

Python Quiz
karljmurphy
Think Python
tsilvo2001
Basic Python - Print Formatting
Rebecca Noel
What is Python?
Daniel Ingram
Python
54671
Know your Python!
educ8ict
Basic Python - Strings
Rebecca Noel
Study on IoT systems design
Tomasz Cieplak
Python
Kirstie Wu
OpenSource Programming
Faheem Ahmed
Basic Python - Lists
Rebecca Noel