J277 - 2.2 - Functions in Python

Quiz
•
Computers
•
10th Grade
•
Medium
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
Similar Resources on Wayground
10 questions
Python Review - Functions

Quiz
•
9th - 12th Grade
12 questions
Python Functions 2

Quiz
•
11th - 12th Grade
15 questions
ONE 6th FORM Introduction to Python Basics

Quiz
•
11th Grade
10 questions
Python Basic files

Quiz
•
10th - 12th Grade
10 questions
Quiz6

Quiz
•
University
10 questions
C++ vs Python: A Quiz Introduction

Quiz
•
11th Grade - University
10 questions
Understanding Procedures in Python

Quiz
•
9th Grade - University
14 questions
Section 4A: Decompose the code using functions

Quiz
•
12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
Proper Keyboarding Techniques

Interactive video
•
6th - 10th Grade
10 questions
Understanding Computers: Hardware, Software, and Operating Systems

Interactive video
•
7th - 12th Grade
29 questions
AP CSP Unit 2 Review (Code.org)

Quiz
•
10th - 12th Grade