J277 - 2.2 - Functions in Python

J277 - 2.2 - Functions in Python

10th Grade

10 Qs

quiz-placeholder

Similar activities

Lesson 3 Recap

Lesson 3 Recap

University

6 Qs

Python functions

Python functions

12th Grade

11 Qs

Phiếu học tập số 3 lớp 10A5

Phiếu học tập số 3 lớp 10A5

University

10 Qs

python. Коллекции

python. Коллекции

7th - 11th Grade

10 Qs

Python User Defined Functions

Python User Defined Functions

12th Grade

14 Qs

Quiz on Python Functions

Quiz on Python Functions

12th Grade

11 Qs

Python CT con

Python CT con

10th - 12th Grade

15 Qs

XII - CS - Lesson 7 - Function - Quiz 1

XII - CS - Lesson 7 - Function - Quiz 1

12th Grade

10 Qs

J277 - 2.2 - Functions in Python

J277 - 2.2 - Functions in Python

Assessment

Quiz

Computers

10th Grade

Medium

Created by

R Eveleigh

Used 8+ 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?