Function with parameters in swift playground - 1

Function with parameters in swift playground - 1

9th Grade

10 Qs

quiz-placeholder

Similar activities

JavaScript Function

JavaScript Function

9th - 12th Grade

8 Qs

Term (3) PC8.1 : Describe a function

Term (3) PC8.1 : Describe a function

9th Grade

7 Qs

CMU CS Academy Unit 2 Part 3

CMU CS Academy Unit 2 Part 3

9th Grade

11 Qs

Database Queries

Database Queries

9th - 10th Grade

14 Qs

PC4.8-PC4.9 CSC403 T2

PC4.8-PC4.9 CSC403 T2

9th Grade

10 Qs

Python Functions

Python Functions

9th - 12th Grade

8 Qs

Functions in C++

Functions in C++

9th - 12th Grade

10 Qs

Function with parameters in swift playground - 1

Function with parameters in swift playground - 1

Assessment

Quiz

Computers

9th Grade

Hard

Created by

Yaseen Jassim

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is a parameter in a Swift function?

A variable that holds the return value of the function

A variable that holds the input value passed to the function

A keyword that defines the type of the function

A keyword that defines the scope of the function

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following is a valid function definition in Swift that takes two parameters and returns their sum?

func addNumbers() -> Int { return a + b }

func addNumbers(a: Int, b: Int) -> Int { return a + b }

func addNumbers(Int, Int) -> Int { return a + b }

func addNumbers(a, b) -> Int { return a + b }

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the purpose of using parameters in a Swift function?

To define the return type of the function

To specify the scope of the function

To provide input values to the function

To define the name of the function

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the syntax for defining a function with a parameter in Swift?

func functionName { parameterName: ParameterType } { /* function body / }

func functionName(parameterName: ParameterType) { / function body / }

func functionName(ParameterType parameterName) { / function body / }

func functionName() -> ParameterType { / function body */ }

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How can you call a function with a parameter in Swift?

By passing the parameter value in square brackets []

By passing the parameter value in parentheses ()

By passing the parameter value in curly braces {}

By passing the parameter value in angle brackets <>

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the purpose of the return keyword in a function with parameters?

To specify the data type of the parameter

To exit the function early without returning a value

To indicate the starting point of the function

To return a value from the function

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What happens if a function with parameters is called without passing any arguments?

The function returns a default value

The function returns an error message

The function uses default values for the parameters

The function throws an exception

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?