day 4 Flashcards
1
Q
arc4random()
A
generates a random number
2
Q
func syntax
A
func nameOfFunction() { // body of function goes here }
3
Q
function type
A
func sayHelloToStudent(student: String) { print("Hello \(student)") }
4
Q
multiple func paramters
A
greetStudent(student: String, school: String)
5
Q
multiple func paramters example
A
func averageScore(firstScore: Double, secondScore: Double, thirdScore: Double) { let totalScore = firstScore + secondScore + thirdScore print(totalScore / 3) }
6
Q
To return a value from a function
A
func calculateTip(priceOfMeal: Double) -> Double { return priceOfMeal * 0.15 }
func isPastBedtime(hour: Int) -> Bool { if hour > 9 { return true } else { return false } }
7
Q
boolean
A
var name=True print(name)
8
Q
if true do something
A
if true{print(“hi”}
9
Q
if statement needs
A
boolean to check
10
Q
else only executes
A
if condition false
11
Q
else if
A
to add extra conditions
12
Q
else statement always
A
last statement
13
Q
user input
A
readline()
14
Q
var password=
A
readline()
15
Q
while code
A
while true{print(“hi”}