Key Concepts

Review core concepts you need to learn to master this subject


var score = 0

A variable refers to a storage location in the computer’s memory that one can set aside to save, retrieve, and manipulate data.

Lesson 1 of 1
  1. 1
    The “Hello, world!” program simply writes to the screen. It does not read anything, calculate anything, or allow for user input. That’s no fun! Real programs tend to produce results based on some …
  2. 2
    Suppose we are building a game, and we want to keep track of the player’s name, the player’s score that goes from 0 to 10, the player’s level, etc. We need some variables! Before we can use a var…
  3. 3
    Computers are incredible at doing calculations. Now that we have declared variables, let’s use them with arithmetic operators to calculate things! Here are some arithmetic operators: - + additi…
  4. 4
    Sometimes the value of our variables need to be adjusted. We know that we can update our variables using arithmetic operators like this: var age = 99 age = age + 1 print(age) // Prints 100 We a…
  5. 5
    We can provide a type annotation when we declare a variable to be clear about the kind of value that the variable can store. Some of the basic data types: - Int: integer numbers - Double: float…
  6. 6
    Often times, we find ourselves needing to insert values into a string. In these cases, we can use string interpolation. In Swift, to insert a value into a string using string interpolation, we …
  7. 7
    We’ve manipulated variables in the last few exercises, but what about variables with values we don’t want to change? That’s the job for constants. Whereas variables can be reassigned during thei…
  8. 8
    Now that we’ve learned about the basics of variables and arithmetic operators, let’s write a program! The mad scientist Kelvin has mastered predicting the weather in his mountain-side meteorology …
  9. 9
    You made it to the end of the lesson! High five. 🙌 Here is a review of the lesson: - A variable represents a particular piece of your computer’s memory that has been set aside for you to use to s…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo