Math and Random
Foundation has sqrt, pow, abs, floor. Int.random(in:) gives random numbers.
Example
import Foundation
print(sqrt(16.0), pow(2.0, 10.0), abs(-5), floor(2.7))
print(max(3, 9), min(3, 9))
let r = Int.random(in: 1...6)
print((1...6).contains(r))Exercise
Random in a range.
Int.random(in: )
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.