Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE ANSWER ALL PARTS! Questions for Swift a) Assume you have a dictionary of names and ages as follows: let data = [Chris P. Bacon:

PLEASE ANSWER ALL PARTS! Questions for Swift

a) Assume you have a dictionary of names and ages as follows:

let data = [Chris P. Bacon: 32, Barb E. Dahl: 41, Carrie Oakey: 14]

Write a loop that will iterate over the data and print each name/age pair in a sentence such as : Noah Lott is 5 years old.

b) Write a while loop (or a repeat/while loop) that will print the odd numbers from 1 to N inclusive.

c) What is the purpose of Thread.sleep()?

d) What is the output of the following code?

let lowHR = 110 let highHR = 125 var movementHeartRates: [String: Int] =

["Walking": 85, "Running": 120, "Swimming": 130, "Cycling": 128, "Skiing": 114, "Climbing": 129]

for (movement, heartRate) in movementHeartRates { if heartRate > lowHR && heartRate < highHR {

continue

}

print("You should avoid \(movement).")

}

e) Assume you have a String called letters that could contain any word or set of letters. For example: let letters = BCDE Write a loop that will print each letter in the string in a sentence on its own line.

For example:

The letter is B

The letter is C

The letter is D

The letter is E

f) Write a for loop that will print the names in a String array (called names) in reverse order starting with the last element.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

How do our values and beliefs affect our responses to other people?

Answered: 1 week ago

Question

What do you understand by "Divisible Profits"?

Answered: 1 week ago

Question

2. Identify issues/causes for the apparent conflict.

Answered: 1 week ago

Question

3. What strategies might you use?

Answered: 1 week ago