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
12 questions
Python Functions 2

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

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

Quiz
•
11th Grade
10 questions
Python Round 2

Quiz
•
University
10 questions
Quiz6

Quiz
•
University
10 questions
python quiz

Quiz
•
6th Grade - Professio...
10 questions
C++ vs Python: A Quiz Introduction

Quiz
•
11th Grade - University
10 questions
Python Basic files

Quiz
•
10th - 12th Grade
Popular Resources on Wayground
18 questions
Writing Launch Day 1

Lesson
•
3rd Grade
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
Discover more resources for Computers
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
10 questions
Characteristics of Life

Quiz
•
9th - 10th Grade
10 questions
Essential Lab Safety Practices

Interactive video
•
6th - 10th Grade
62 questions
Spanish Speaking Countries, Capitals, and Locations

Quiz
•
9th - 12th Grade
20 questions
First Day of School

Quiz
•
6th - 12th Grade
21 questions
Arithmetic Sequences

Quiz
•
9th - 12th Grade