var message: String var hasPostOffice: Bool = true
var unemployment: Int = 150
var numberOfStopLights: Int = 4
numberOfStopLights += 2
let townName = "Knowhere"
let townDescription = "\(townName) has a population of \(population), \(numberOfStopLights) stoplights and \(unemployment) people unemployed." print(townDescription)
if population < 10000 {
message = "\(population) is a small town!" } else if population >= 10000 && population < 50000 { message = "\(population) is a medium town!" } else if population >= 50000 && population < 100000 { message = "\(population) is pretty big!" } else { message = "\(population) is very large!" }
print(message)
if !hasPostOffice { print("This town has no post office!") }
/*var sampleVariable = 1 // This is how you define a new variable
let sampleConstant = "Constant" // This is how you define a new constant
var sampleInteger: Int = 3 // Defining a variable with an explicit type
let sampleString: String = "Another Constant"
// Including values/expressions inside strings ("The sum is: 4")
let sumString = "The sum is: \(sampleVariable + sampleInteger)"
var sampleList = ["item1", "item2", "item3"] // Defining an array
var sampleDict = ["key1" : sampleList[0], "key2" : "value2", "key3" : "value3"] // Defining a dictionary
sampleList[1] = "Updated Item" // Setting the value of an element
print(sampleList[0],",", sampleList[2]) print(sampleDict["key1"]!, sampleDict["key2"]!, sampleDict["key3"]!) // Reading the value of an element */