Question
Create a variable [String: Int] dictionary that can be used to look up the number of days in a particular month. Use a dictionary literal
Create a variable [String: Int] dictionary that can be used to look up the number of days in a particular month. Use a dictionary literal to initialize it with January, February, and March. January contains 31 days, February has 28, and March has 31. Print the dictionary.
Using subscripting syntax to add April to the collection with a value of 30. Print the dictionary.
It's a leap year! Update the number of days in February to 29 using the updateValue(_:, forKey:) method. Print the dictionary.
Use if-let syntax to retrieve the number of days under "January". If the value is there, print "January has 31 days", where 31 is the value retrieved from the dictionary.
Given the following arrays, create a new [String : [String]] dictionary. shapesArray should use the key "Shapes" and colorsArray should use the key "Colors". Print the resulting dictionary.
let shapesArray = ["Circle", "Square", "Triangle"] let colorsArray = ["Red", "Green", "Blue"]
Print the last element of colorsArray, accessing it through the dictionary you've created. You'll have to use if-let syntax or the bang operator to unwrap what is returned from the dictionary before you can access element of the array.
all of this goes together(one question) pls write the dictionary questions in xcode(swift) not c++. thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started