J277 - 2.2 - Functions in Python

J277 - 2.2 - Functions in Python

10th Grade

10 Qs

quiz-placeholder

Similar activities

KODEKIDDO HACK #MLH3

KODEKIDDO HACK #MLH3

4th Grade - University

10 Qs

Python User Defined Functions

Python User Defined Functions

12th Grade

14 Qs

Test on Python Function

Test on Python Function

11th - 12th Grade

12 Qs

Python Functions 1

Python Functions 1

12th Grade

12 Qs

Python Round 2

Python Round 2

University

10 Qs

Functions and Modules

Functions and Modules

University

10 Qs

HCI 584 Python quiz

HCI 584 Python quiz

University

15 Qs

Funzioni Python

Funzioni Python

12th Grade

14 Qs

J277 - 2.2 - Functions in Python

J277 - 2.2 - Functions in Python

Assessment

Quiz

Computers

10th Grade

Medium

Created by

R Eveleigh

Used 7+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to define a function in Python?

`function myFunction():`

`def myFunction():`

`define myFunction():`

`func myFunction():`

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a valid function parameter in Python?

`def myFunction(x, y):`

`def myFunction(x y):`

`def myFunction(x; y):`

`def myFunction(x: y):`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following function call: `print(add(2, 3))` if the function is defined as `def add(a, b): return a + b`?

`23`

`5`

`None`

`Error`

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you specify a default value for a function parameter in Python?

`def myFunction(x = 10):`

`def myFunction(x: 10):`

`def myFunction(x -> 10):`

`def myFunction(x <- 10):`

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the `return` statement in a function?

To print the result

To exit the function and return a value

To define a function

To pass control to another function

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following functions will return the square of a number?

`def square(x): return x * 2`

`def square(x): return x ** 2`

`def square(x): return x + x`

`def square(x): return x / 2`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code snippet? ```python def greet(name): return "Hello, " + name print(greet("Alice")) ```

`Hello,`

`Hello, Alice`

`Alice`

`Error`

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?