wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Swift playground - about me module

Total questions: 16

Worksheet time: 13mins

Name
Class
Date
1.

What is a property in Swift?

a)

A function that performs an action

b)

A variable that describes an attribute of an object

c)

A type of loop used in coding

d)

A keyword used to import modules

2.

Which code would you use to change the background color of your profile?

a)

.foregroundColor(.blue)

b)

.background(.blue)

c)

.color(.blue)

d)

.font(.blue)

3.

What Swift feature allows you to add emojis or special characters to your profile?

a)
  • Text

b)
  • Image

c)
  • Symbol

d)
  • Shape

4.

ZStack is used to layer views on top of each other in Swift Playgrounds.

a)

TRUE

b)

FALSE

5.

During a group project, Maya used the (a)   component to arrange elements horizontally on the presentation slide.

6.

Which component is used to group views in a vertical layout?

a)
  • HStack

b)
  • VStack

c)
  • ZStack

d)
  • GridStack

7.

Michael is learning Swift Playgrounds and wants to change the color of the text in his project. Which property should he use to achieve this?

a)

.font

b)

  • .color

c)

  • .foregroundColor

d)

  • .textColor

8.

What does the padding( ) modifier do?

a)
  • Changes the background color

b)
  • Adds space around an element

c)
  • Centers the element

d)
  • Aligns text to the left

9.

Which of these modifiers is used to add a border to a shape?

a)
  • .outline( )

b)
  • .frame( )

c)
  • .border( )

d)
  • .stroke( )

10.

What happens when you combine multiple stacks (HStack, VStack, ZStack) in a Swift Playgrounds project?

a)
  • The layout breaks and throws an error.

b)
  • Only the first stack is rendered, and others are ignored.

c)
  • You can create complex, layered designs with precise control over spacing and alignment.

d)
  • The stacks automatically align based on screen size.

11.

The (a)   modifier is used to crop a view into a specific shape, such as a circle or a rounded rectangle.

12.

  1. The . (a)   ( ) modifier adjusts the transparency of a view.

13.

  1. When working with a ZStack, the (a)   element in the code will appear at the bottom.

14.

Which combination of modifiers is best for creating a circular profile picture?

a)

.frame(width: 100, height: 100) + .cornerRadius(50) + .shadow( )

b)
  • .frame(width: 100, height: 100) + .clipShape(Circle( )) + .shadow( )

c)
  • .frame(width: 100, height: 100) + .background(.white) + .padding( )

d)
  • .frame(width: 100, height: 100) + .border(.black) + .cornerRadius(50)

15.
  1. What is the purpose of the .clipShape( ) modifier in Swift Playgrounds?

a)
  • To crop the view into a specific shape, such as a circle or rectangle

b)
  • To add padding around the view

c)
  • To create a shadow effect around the view

d)
  • To align the view within a stack

16.

Write code to create a VStack displaying a title "Hello, World!" in bold and a subtitle "Welcome to Swift Playgrounds" in italic below it.

4 lines