J277 - 2.2 - Functions in Python

J277 - 2.2 - Functions in Python

10th Grade

10 Qs

quiz-placeholder

Similar activities

Python Objects and Recursion

Python Objects and Recursion

10th Grade

14 Qs

Functions in Python

Functions in Python

9th - 12th Grade

15 Qs

Test on Python Function

Test on Python Function

11th - 12th Grade

12 Qs

Python Round 2

Python Round 2

University

10 Qs

HCI 584 Python quiz

HCI 584 Python quiz

University

15 Qs

Funzioni Python

Funzioni Python

12th Grade

14 Qs

KODEKIDDO HACK #MLH3

KODEKIDDO HACK #MLH3

4th Grade - University

10 Qs

PROGRAMMING IN PYTHON - UNIT II - TEST 2 - MCQS

PROGRAMMING IN PYTHON - UNIT II - TEST 2 - MCQS

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?