Skip to content

Commit 6835b21

Browse files
committed
Answered questions
1 parent 85d32a5 commit 6835b21

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift

+8-14
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,50 @@
1414
/*: question1
1515
### 1. Create a variable which represents your bank account balance. (For example: What is a good name for this variable that makes it easily readable for myself now and for the future me _or_ other developers I might be working with? Should I declare it using `let` or `var`? Should it be of type `Int` or `String`?)
1616
*/
17-
// write your code here
18-
17+
var bankAccountBalance = 1000
1918

2019

2120

2221
/*: question2
2322
### 2. You went to your local pet store and purchased yourself a puppy. You decided to name the puppy Bella. Once you named her, that name will stick with her forever. Create a variable that stores the name of your new puppy.
2423
*/
25-
// write your code here
26-
24+
let puppyName = "Bella"
2725

2826

2927

3028
/*: question3
3129
### 3. Use the `print()` function to print the name of your new puppy to the console.
3230
*/
33-
// write your code here
34-
31+
print(puppyName)
3532

3633

3734

3835
/*: question4
3936
### 4. Use the `print()` function to print the sentence "I just got a new puppy named <your puppy's name> and she is awesome!" to the console.
4037
*/
41-
// write your code here
42-
38+
print("I just got a new puppy named \(puppyName) and she is awesome!")
4339

4440

4541

4642
/*: question5
4743
### 5. Use the `print()` function to print the sentence "I have $<balance> in my bank account." to the console.
4844
*/
49-
// write your code here
50-
45+
print("I have $\(bankAccountBalance) in my bank account.")
5146

5247

5348

5449
/*: question6
5550
### 6. Congratulations! You just got $100 for your birthday, so now you have $100 more in your bank account. Update your bank account with the new balance and print "I now have $<balance>." to the console.
5651
*/
57-
// write your code here
58-
52+
bankAccountBalance += 100
53+
print ("I now have $\(bankAccountBalance) in my bank account.")
5954

6055

6156

6257
/*: question7
6358
### 7. You decided you don't like the name Bella. Change your puppy's name to something else. (Can you do this? What happens when you try? Why?)
6459
*/
65-
// write your code here
66-
60+
puppyName = "Abby"
6761

6862
/*:
6963
Checkout the solution branch - git co solution or git checkout solution and then scroll back down to this very spot to see a link that directs you to the solutions to the above questions.

0 commit comments

Comments
 (0)