From 5a17ee127b113e377f1cf518cac93ea4c1715bc8 Mon Sep 17 00:00:00 2001 From: pmaurelia Date: Thu, 17 Jan 2019 15:46:07 -0500 Subject: [PATCH] finished lab --- .../Pages/main.xcplaygroundpage/Contents.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift index c1f926f..e10d905 100644 --- a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift +++ b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift @@ -13,8 +13,12 @@ /*: question1 ### 1. Create a function that will take in a continent and the number of countries in that continent. It should print the following sentence "____ is a continent which contains ___ countries". */ -// write your code here +func numberOfCountries(continent: String, countries: Int) +{ + print("\(continent) is a continent which contains \(countries) countries.") +} +numberOfCountries(continent: "North America", countries: 3) @@ -25,7 +29,7 @@ func greeting(name: String, greeting: String) { print("\(greeting), \(name)!") } -greeting(name: "Danny", "Hello") +greeting(name: "Danny", greeting: "Hello") @@ -33,7 +37,7 @@ greeting(name: "Danny", "Hello") /*: question3 ### 3. This function doesn't work, either. Can you fix the function (_not_ the call) so that it works? */ -func daysInMonth(month: String, days: String) { +func daysInMonth(month: String, days: Int) { print("There are \(days) in \(month)") } @@ -45,7 +49,7 @@ daysInMonth(month: "November", days: 30) /*: question4 ### 4. So far, you have created functions that take two arguments. Can you create (and call) one that takes three? Try to create a function that three parameters: a beverage, the number of bottles of that beverage, and a place you can keep those bottles. Print the sentence "____ bottles of ____ on the ____ wall." */ -// write your code here +// why be repetitive. a function with 3 args is the same as with 2...