Paste_Image.png
import UIKit
//: Declare a constant of type Int called myAge and set it to your age.
let myAge = 29
//: Declare a variable of type Double called averageAge. Initially, set it to your own age. Then, set it to the average of your age and my own age of 30.
var averageAge = myAge
averageAge = (30 + averageAge)/2
//: Create a variable called answer and initialize it with the value 0. Increment it by 1. Add 10 to it. Multiply it by 10 and divide by 3. After all of these operations, what’s the answer?
var answer = 0
answer += 1
answer += 10
answer *= 10
answer /= 3
answer
//: Declare two constants a and b of type Double and assign both a value. Calculate the average of a and b and store the result in a constant named average.
let a = 1.0
let b = 2.0
let average = (a + b)/2
网友评论