You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift
+8-14
Original file line number
Diff line number
Diff line change
@@ -14,56 +14,50 @@
14
14
/*: question1
15
15
### 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`?)
16
16
*/
17
-
// write your code here
18
-
17
+
varbankAccountBalance=1000
19
18
20
19
21
20
22
21
/*: question2
23
22
### 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.
24
23
*/
25
-
// write your code here
26
-
24
+
letpuppyName="Bella"
27
25
28
26
29
27
30
28
/*: question3
31
29
### 3. Use the `print()` function to print the name of your new puppy to the console.
32
30
*/
33
-
// write your code here
34
-
31
+
print(puppyName)
35
32
36
33
37
34
38
35
/*: question4
39
36
### 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.
40
37
*/
41
-
// write your code here
42
-
38
+
print("I just got a new puppy named \(puppyName) and she is awesome!")
43
39
44
40
45
41
46
42
/*: question5
47
43
### 5. Use the `print()` function to print the sentence "I have $<balance> in my bank account." to the console.
48
44
*/
49
-
// write your code here
50
-
45
+
print("I have $\(bankAccountBalance) in my bank account.")
51
46
52
47
53
48
54
49
/*: question6
55
50
### 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.
56
51
*/
57
-
// write your code here
58
-
52
+
bankAccountBalance +=100
53
+
print("I now have $\(bankAccountBalance) in my bank account.")
59
54
60
55
61
56
62
57
/*: question7
63
58
### 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?)
64
59
*/
65
-
// write your code here
66
-
60
+
puppyName ="Abby"
67
61
68
62
/*:
69
63
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