J277 - 2.2 - Functions in Python

J277 - 2.2 - Functions in Python

10th Grade

10 Qs

quiz-placeholder

Similar activities

Intermediate Python

Intermediate Python

University

15 Qs

Python revision

Python revision

10th Grade - University

15 Qs

Python: Functions and Parameters

Python: Functions and Parameters

9th - 12th Grade

10 Qs

10 ԹԳՀԳ 2-րդ կիսամյակ ամփոփիչ գրավոր աշխատանք/ֆունկցիաներ/

10 ԹԳՀԳ 2-րդ կիսամյակ ամփոփիչ գրավոր աշխատանք/ֆունկցիաներ/

10th Grade

10 Qs

JavaScript Functions Quiz

JavaScript Functions Quiz

12th Grade - University

15 Qs

5-函数

5-函数

University

10 Qs

Python functions and procedures

Python functions and procedures

10th - 11th Grade

8 Qs

Kuizi 15 - Web

Kuizi 15 - Web

10th Grade - University

15 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?