
Understanding Swift Variables and Scope

Quiz
•
Computers
•
9th Grade
•
Medium
Iman Meg
Used 4+ times
FREE Resource
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a variable in Swift?
A constant value that cannot be changed
A named storage that can hold a value
A function that performs a specific task
A type of loop used in programming
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a correct way to declare a variable in Swift?
`let age = 25`
`var name = "John"`
`int height = 180`
`string city = "New York"`
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the difference between `let` and `var` in Swift?
`let` is used for loops, `var` is used for functions
`let` declares a constant, `var` declares a variable
`let` is used for strings, `var` is used for integers
`let` is used for global scope, `var` is used for local scope
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a global variable?
A variable declared inside a function
A variable declared outside all functions
A variable declared inside a loop
A variable declared inside a conditional statement
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the scope of a local variable?
It can be accessed from anywhere in the program
It can only be accessed within the block where it is declared
It can be accessed by all functions in the program
It can be accessed by all classes in the program
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a correct data type in Swift?
`integer`
`float`
`Int`
`double`
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following Swift code? ```swift var x = 10 x = 20 print(x) ```
10
20
30
Error
8.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements about variable state is true?
A variable's state cannot change during program execution
A variable's state is its current value at any point in time
A variable's state is determined by its data type
A variable's state is always initialized to zero
9.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of the following Swift code? ```swift let pi = 3.14 pi = 3.14159 ```
3.14
3.14159
Error
0
Similar Resources on Wayground
10 questions
TLE QUIZZIZ 2

Quiz
•
9th - 12th Grade
10 questions
Code.org CS Discoveries U3L08 Sprite Properties

Quiz
•
9th Grade
10 questions
9 класс Информатика Одномерный массив данных

Quiz
•
9th - 10th Grade
10 questions
For - tercero bachillerato

Quiz
•
9th - 12th Grade
10 questions
Python Quiz

Quiz
•
9th Grade
10 questions
Операторы и функции языка Pascal

Quiz
•
1st - 10th Grade
14 questions
year 8 lesson 2 quiz - python

Quiz
•
8th - 10th Grade
6 questions
T3Quiz#1A09[GEN]

Quiz
•
9th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

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

Interactive video
•
6th - 10th Grade
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
30 questions
Introduction to Computers

Quiz
•
8th - 9th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
20 questions
Hardware vs. Software Quiz

Quiz
•
7th - 10th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade