day1: variables, constants, strings, and numbers import Cocoa //variable var greeting Hello, playground //constants let character Daphe let filename paris.jpg //命名规则驼峰法 //string let movie we are family let move go back to our home //read the length of string let nameLength move.count print(nameLength) //uppercase: sends back the same string except every one of its letters is now uppercased let uppercase movie.uppercased() print(uppercase) //if youre asking swift to read some data you dont need the parentheses //but if youre asking swift to do some work for you then you do //has prefix: let us know if a string starts with some letters of our choosing //strings are case sensitive print(movie.hasPrefix(A day)) print(movie.hasPrefix(we are)) print(filename.hasSuffix(.jpg)) //swift ignores the underscores let score 10_000_000 let lowScore score - 3 let higherScore score 10 let doubledScore score * 2 let squaredScore score * score let halvedScore score / 2 var counter 10 counter counter 5 counter 5 counter * 5 //find out if one integer is a multiple of another integer let number 120 print(number.isMultiple(of:3)) print(120.isMultiple(of:3)) //the output of num is 0.30000000000000004 let num 0.1 0.2 print(num) let a 1 let b 2.0 let c a Int(b) let d Double(a) b //name 3 is not allowed, once swift has decided what data type a constant or variable holds it must always hold that same type of data var name John name 3