К основному контенту

Сообщения

7th lection task

1) import Foundation var daysInMonths = [ 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ] var namesOfMonths = [ "January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December" ] let birthday = daysInMonths [ 9 ] * 0 + 4 var birthdayArray = daysInMonths var daysInTheYearTillBirthday = 0 birthdayArray. removeLast () birthdayArray. removeLast () birthdayArray [ 9 ] = birthday print ( birthdayArray ) print ( daysInMonths ) print ( namesOfMonths ) // testTuple is created for auto-in testing var testTuple : [( String , Int )] = [] for ( index , value ) in namesOfMonths. enumerated () { print ( " \( namesOfMonths [ index ] ) has \( daysInMonths [ index ] ) days" ) testTuple. append ((( namesOfMont...
Недавние сообщения

6th lection task

1) import Foundation var value1 = "33" var value2 = "3e" var value3 = "fff123" var value4 = "12" var value5 = "dummy" let defaultValue = 0 var valueSum : Int = 0 // valueSum += Int(value1) ?? defaultValue // print(valueSum) // valueSum += Int(value2) ?? defaultValue // print(valueSum) // valueSum += Int(value3) ?? defaultValue // print(valueSum) // valueSum += Int(value4) ?? defaultValue // print(valueSum) // valueSum += Int(value5) ?? defaultValue // print(valueSum) print ( " \( valueSum ) + \( Int ( value1 ) ?? defaultValue ) + \( Int ( value2 ) ?? defaultValue ) + \( Int ( value3 ) ?? defaultValue ) + \( Int ( value4 ) ?? defaultValue ) + \( Int ( value5 ) ?? defaultValue ) " ) print ( String ( valueSum ) + value1 + value2 + value3 + value4 + value5 ) 2) import Foundation let x : Character = "z" var index = 0...

5th lection task

import Foundation // количество секунд от начала года до дня рождения // в каком квартале родился и вывести // шахматная доска 8х8. какое поле черное, а какое белое // first task let january = 31 let february = 28 let march = 31 let april = 30 let may = 31 let june = 30 let july = 31 let august = 31 let september = 30 let october = 4 // var result = 24 * 60 * 60 * (january + february + march + april + may + june + july + august + september + october) // print(result) // second task let birthday = may if birthday == january || birthday == february || birthday == march { print ( "first quarter" ) } else if birthday == april || birthday == may || birthday == june { print ( "second quarter" ) } else if birthday == july || birthday == august || birthday == september { print ( "third quarter" ) } else { print ( "fourth quarter" ) } ...

Fourth lection task // ДЗ четвертой лекции

1) import Foundation var enteredAge1 = "33" var enteredAge2 = "3e" var enteredAge3 = "fff123" var enteredAge4 = "12" var enteredAge5 = "dummy" var ageSum = 0 if Int ( enteredAge1 ) != nil { ageSum += Int ( enteredAge1 ) ! } if Int ( enteredAge2 ) != nil { ageSum += Int ( enteredAge2 ) ! } if Int ( enteredAge3 ) != nil { ageSum += Int ( enteredAge3 ) ! } if Int ( enteredAge4 ) != nil { ageSum += Int ( enteredAge4 ) ! } if Int ( enteredAge5 ) != nil { ageSum += Int ( enteredAge5 ) ! } print ( ageSum ) 2) import Foundation var errorType : ( statusCode : Int , message : String , errorMessage : String ? ) = ( 20 , "Error 200" , "Boom" ) if errorType. statusCode >= 200 && errorType. statusCode <= 300 { print ( errorType. message ) } else { print ( errorType. errorMessage ! ) } ...

Third lection task // ДЗ третьей лекции

import Foundation let mySportMark = ( maxPushUps : 50 , maxPullUps : 20 , maxSitUps : 50 ) print ( mySportMark ) print ( "My push-ups max is \( mySportMark . maxPushUps ) " ) print ( "My pull-ups max is \( mySportMark . maxPullUps ) " ) print ( "My sit-ups max is \( mySportMark . maxSitUps ) " ) var first = mySportMark. maxPushUps var second = mySportMark. maxPullUps var third = mySportMark. maxSitUps var alexSportMark = ( maxPushUps : 0 , maxPullUps : 0 , maxSitUps : 0 ) print ( alexSportMark ) first = 15 second = 10 third = 5 alexSportMark. maxPushUps = first alexSportMark. maxPullUps = second alexSportMark. maxSitUps = third print ( alexSportMark ) var newFirst = mySportMark. maxPushUps - alexSportMark. maxPushUps print ( newFirst )

Second lection task // ДЗ по второй лекции

1) import Foundation print ( "Int min value is \( Int . min ) Int max value is \( Int . max ) " ) print ( "Int8 min value is \( Int8 . min ) Int8 max value is \( Int8 . max ) " ) print ( "UInt8 min value is \( UInt8 . min ) UInt8 max value is \( UInt8 . max ) " ) // Can't do this to Float and Double // print("Float min value is \(Float.min) Float max value is \(Float.max)") // print("Double min value is \(Double.min) Double max value is \(Double.max)") 2) import Foundation let firstInt : Int = 12 let firstFloat : Float = 3.14 let firstDouble : Double = 12.20482048 let secondInt : Int = firstInt + Int ( firstFloat ) + Int ( firstDouble ) let secondFloat : Float = Float ( firstInt ) + firstFloat + Float ( firstDouble ) let secondDouble : Double = Double ( firstInt ) + Double ( firstFloat ) + firstDouble print ( secondInt ) print ( secondFloat ) p...
First lection task. // ДЗ по первой лекции import Foundation //Student's Params let studentsFirstName = "Hanzo" let studentsLastName = "Hassashi" let studentsAge = "19" let studentsHeight = "188" let studentsFavouriteRestaurant = "McDonalds" print ( " \( studentsFirstName ) \( studentsLastName ) is \( studentsAge ) years old\n \( studentsFirstName ) height is \( studentsHeight ) . \( studentsFirstName ) likes \( studentsFavouriteRestaurant ) " )