Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1 задание
- var journal = ["Alex B" : 4, "Johnny C" : 3, "Gavrila H" : 5, "Tosya M" : 3, "Tur" : 4]
- journal["Johnny C"] = 5
- journal["Tosya M"] = 4
- journal["Fred G"] = 3
- journal["Kira T"] = 5
- journal["Alex B"] = nil
- journal["Tur"] = nil
- var total = Int()
- var avarage = Double()
- for value in journal.values {
- total += value
- }
- avarage = Double(total) / Double(journal.count)
- print("The total score of group: \(total), the avarage score: \(avarage)\n")
- //2 задание
- let moths = ["Jan" : 31, "Feb" : 28, "Mar" : 31, "Apr" : 30, "May" : 31, "Jun" : 30, "Jul" : 31, "Aug" : 31, "Sep" : 30, "Oct" : 31, "Nov" : 31, "Dec" : 31]
- for (key, value) in moths {
- print("Moth : \(key) - days : \(value)")
- }
- print("\n")
- for moth in moths.keys {
- print("Moth : \(moth) - days : \(moths[moth]!)")
- }
- var chess = [String : Bool]()
- var i = 1
- for letter in "ABCDEFGH" {
- for num in "12345678" {
- let num = String(num)
- let letter = String(letter)
- if (i + Int(num)!) % 2 == 0 {
- chess[letter + num] = false
- } else {
- chess[letter + num] = true
- }
- }
- }
- print(chess)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement