J277 - 2.2 - Functions in Python

J277 - 2.2 - Functions in Python

10th Grade

10 Qs

quiz-placeholder

Similar activities

Python Basic files

Python Basic files

10th - 12th Grade

10 Qs

Python Functions 2

Python Functions 2

11th - 12th Grade

12 Qs

Section 4A: Decompose the code using functions

Section 4A: Decompose the code using functions

12th Grade

14 Qs

ONE 6th FORM Introduction to Python Basics

ONE 6th FORM Introduction to Python Basics

11th Grade

15 Qs

Test on Python Function

Test on Python Function

11th - 12th Grade

12 Qs

HCI 584 Python quiz

HCI 584 Python quiz

University

15 Qs

PROGRAMMING IN PYTHON - UNIT II - TEST 1 MCQS

PROGRAMMING IN PYTHON - UNIT II - TEST 1 MCQS

University

15 Qs

Python and PseudoCode Quiz

Python and PseudoCode Quiz

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