Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homework #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@
//: Next, learn how programmers can leave notes in code.
//:
//:[Previous](@previous) | page 3 of 7 | [Next: Comments](@next)
44 + 22 + 11

500 - 100

1 * 6

25 / 5


(100 + 200 + 100)/2
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
//: Take a deep breath and move on to the next page.
//:
//:[Previous](@previous) | page 4 of 7 | [Next: When Things Go Wrong 😰](@next)
//34 + 56 + 230

200 + 34 + 45
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
//: Next, read all about your very recent past.
//:
//:[Previous](@previous) | page 6 of 7 | [Next: Wrapup](@next)
1000/2
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Next, find out how to put the results sidebar to better use.

[Previous](@previous) | page 2 of 7 | [Next: Calculations](@next)
*/

771
111
-1700


Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ let numberOfTickets = 150

//:
//:[Previous](@previous) | page 10 of 14 | [Next: Exercise: Lottery Tickets](@next)
let numberOfTickets1 = 150
let numberOfPrice1 = 10
let numberOfRoomRental1 = 1000
let numberOfPosterCost1 = 40

let numberOfTotalTicket = 150 * 10

let numberOfTotalExpense = 1000 + 40

let numberOfTotalIncomeOfShow = (150 * 10) - (1000 + 40)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ let advertising = 50

The calculations below are fixed, but you can change the results by changing the numbers above:
*/
let ticketsSold1 = 2100
let ticketPrice2 = 1
let printingCosts3 = 60
let advertising4 = 40

// Total takings
let totalTakings = ticketPrice * ticketsSold

Expand All @@ -31,3 +36,4 @@ let programmersCut = profit / 10 // This is the answer you want to get over 100!
let friendsCut = profit - programmersCut

//:[Previous](@previous) | page 11 of 14 | [Next: Exercise: What Fits on Your iPhone?](@next)

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
_Hint_: Do all of your calculations in megabytes (MB).
*/





//:[Previous](@previous) | page 12 of 14 | [Next: Exercise: Fixing Your Morning](@next)
let totalIphonStorage = 8 * 1000
let iphonStorageUsedd = 2 * 1000
let oneMinutOfVide = 150

let minutsOfVideo = (totalIphonStorage - iphonStorageUsedd) / oneMinutOfVide
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

- callout(Exercise): Create a constant for each activity you do in the morning before leaving home: things like `brushTeeth`, `uploadPhotos`, `chooseClothes`, `shower`, `goJogging`, `finishHomework`, `fixLunch`, and so on. Think about how many minutes each activity usually takes, and assign that value to each constant.
*/
let brushTeeth = 3
// Add more here...

//: - callout(Exercise): Find the total time of all the activities by adding up the constants. Try to adjust the values or add more activities until the total time looks reasonably close to the actual amount of time you spend getting ready on an average day.

Expand All @@ -31,3 +29,19 @@ let brushTeeth = 3


//:[Previous](@previous) | page 13 of 14 | [Next: Exercise: Good Names](@next)
let brushTeeth = 3
// Add more here...

let UploadPhotos = 3
let chooseClothes = 5
let Shower = 5
let GoJogging = 30
let FinishHomework = 40
let FixLunch = 30

let TotalTimeSpend = (3 + 3 + 5 + 5 + 30 + 40 + 30)

let ThingsShouldedo = ( brushTeeth + chooseClothes + Shower)
let ThingsIlikeDo = GoJogging
let thingsIdontLikeDo = FixLunch

Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ let rhso = co - lhso

//: - experiment: Rewrite the code so that it makes sense without needing a note. Use meaningful names and comments.






/*:

_Copyright © 2017 Apple Inc._
Expand All @@ -41,3 +36,18 @@ let rhso = co - lhso
_THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._
*/
//:[Previous](@previous) | page 14 of 14
let countOrange = 14
let countWatermelons = 3
let orangeWeigh = 100
let watermelonsWeigh = 200
let truckOrange = countOrange * orangeWeigh
let truckWatermelons = countWatermelons * watermelonsWeigh
let trucktotal = truckOrange + truckWatermelons
let eachSide = trucktotal / 2
let leftHandSide = eachSide / orangeWeigh
let rightHandSide = countOrange - leftHandSide





Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ let totalNumberOfMammals = 🐶 + 🐱 + 🐹 + 🐷
//: Next, learn the official names for the work you’ve been doing.
//:
//:[Previous](@previous) | page 7 of 14 | [Next: Programmer Talk](@next)
let 🕷 = 1


Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters
//: Next, learn about choosing names.
//:
//:[Previous](@previous) | page 6 of 14 | [Next: Choosing Good Names](@next)
let numberOfPot = 1

let numberOffish = 1

let numberOfSnake = 1


let totalNumberOfAnimals1 = numberOfPot + numberOffish + numberOfSnake

let totalNumberOfMammals2 = numberOfPot

Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ let totalNumberOfMammals = numberOfDogs + numberOfCats + numberOfHamsters
//: Once you’re finished experimenting, move ahead.
//:
//:[Previous](@previous) | page 4 of 14 | [Next: Typing Names and Autocompletion](@next)

let numberOfDogs1 = 6 + 2

let numberOfCats2 = 5 - 1

let numberOfTurtles3 = 2 + 1

let numberOfHamsters4 = 1 + 1
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@
//: Could there be a better way to solve this problem? Think about it for a minute or two, then move on.
//:
//:[Previous](@previous) | page 2 of 14 | [Next: Pet Problem Recap](@next)
//number of Dog
5 + 1

//number of turtles
3 - 1

//number of cat
5 + 1

//number of a mammal
9 + 1
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ let finishedMessage = username + " " + likesYourPostMessage
//: Next, find out how building strings by adding them can get complicated.
//:
//:[Previous](@previous) | page 5 of 16 | [Next: Fill In The Blanks](@next)
let FirstName = "Bushra"
let LastName = "Alatwi"

let LikesYourPostMessage = "likes your post"
let FinishedMessage1 = FirstName + " " + LastName
let FinishedMessage2 = FirstName + " " + LikesYourPostMessage


Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ let traditionalGreeting = "Hello, world!"
//: Next, take a string-based trip around the world.
//:
//:[Previous](@previous) | page 3 of 16 | [Next: Unicode](@next)
let favoriteMovie = "The Dream"

let favoriteSong = "Love"
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,29 @@ let tableTwoResponse = "Perfect, merci bien."

//:
//:[Previous](@previous) | page 14 of 16 | [Next: Exercise: Go! Fight! Win!](@next)
let ServerResponseToTableOne = "Let me make sure I've got this right: \(customerOrderOne).Is that everything?"

let tableTwoResponseOne = "Perfect, Thanks."

let serverResponseToTableTow = "Let me make sure I've got this right: \(customerOrderTwo).Is that everything?"

let tableTwoResponseTow = "thanks."

let serverResponseToTableThree = "Let me make sure I've got this right: \(customerOrderThree).Is that everything?"

let tableTwoResponseThree = "Perfect, merci bien."

let serverResponseToTableFour = "Let me make sure I've got this right: \(customerOrderFour).Is that everything?"

let tableTwoResponseFour = "Perfect."

let serverResponseToTableFive = "Let me make sure I've got this right: \(customerOrderFive).Is that everything?"

let tableTwoResponseFive = "Perfect, merci bien."

let serverResponseToTableSix = "Let me make sure I've got this right: \(customerOrderSix).Is that everything?"

let tableTwoResponseSix = "thanks."



Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,9 @@

_Hint:_ Do all of your calculations in megabytes.
*/






/*:

_Copyright © 2017 Apple Inc._

_Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:_

_The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software._

_THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE._
*/
//:[Previous](@previous) | page 16 of 16
let totaliphonestorega = 8 * 1000
let iPhonesstoregaused = 3 * 1000
let oneMinutofvideo = 150
let leftStorage = totaliphonestorega - iPhonesstoregaused
let minutsofvideotofilliphone = leftStorage/oneMinutofvideo
let user = "you can record \(minutsofvideotofilliphone) more minutes of video."
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ let song = "\(refrain)\n\(refrain)\nYes, \(refrain)"

//:
//:[Previous](@previous) | page 15 of 16 | [Next: Exercise: Displaying Values](@next)

let mySchoolName = "ASTRA SCHOOL"
let myrefrain = "laaa llllaaaa\(schoolName)laallllaaaa"

let mysong = "\(refrain)\n\(refrain)\nYes, \(refrain)"


Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ let newline = "Making new lines"

//:
//:[Previous](@previous) | page 13 of 16 | [Next: Exercise: A Restaurant](@next)
let thingsIHaveLeared = """
\(constants)
\(unicode)
\(combining)
\(interpolation)
\(escaping)
\(newline)
"""
print (thingsIHaveLeared)


Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,17 @@ let goalieReportString = "At the game yesterday, \(goalieName) had \(firstHalfSa
//: Next you’ll see a few more tricks with strings.
//:
//:[Previous](@previous) | page 9 of 16 | [Next: The Great Escape](@next)
let name = "me And huda"
let number = 600
let adjective = "a butful"
let noun = "dress"
let noun2 = "max"
let place = "shop"
let positiveEmotion = "happy"
let negativeEmotion = "sad"
let noun3 = "stock"

let fullStory: String = """
Today was a big day for \(name). They had finally saved up \(number) dollars and were going to buy a \(adjective + noun). They went to the \(noun2 + place) feeling very \(positiveEmotion). But then they felt \(negativeEmotion). They were all out of \(noun3)!
"""
print(fullStory)
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ let reason = "tasty"
//: On the next page, see what happens with long strings.
//:
//:[Previous](@previous) | page 7 of 16 | [Next: Viewing Playground Results](@next)
let FavoriteFood = "pizza"
let Reason = "tasty"

let welcomeS = "Ilike \(favoriteFood), because it is \(reason)"