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

finsh homework #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
finsh homework
عبدالعزيز البلوي authored and عبدالعزيز البلوي committed Oct 5, 2021
commit 00450ca1fa71e058461c882c1ad53b498b058145
Binary file added .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -20,3 +20,8 @@
//: Next, learn how programmers can leave notes in code.
//:
//:[Previous](@previous) | page 3 of 7 | [Next: Comments](@next)
22+55+9
11-2-3
4*81
80/22
(12+33+11)/4
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@
//:
//: A comment starts with two slashes `//` :
// This is a comment; it does not affect the code
34 + 56 + 230
34 + 56 + 230//add
//: Because comments are ignored, no result is displayed in the results bar for that line of code.
// 200 + 34 + 45
200 + 34 + 45
//: - experiment:\
//: Try _commenting out_ the calculation `34 + 56 + 230` by adding two slashes to the beginning of the calculation.\
//:Try _uncommenting_ the calculation `200 + 34 + 45` by deleting the two slashes.\
@@ -19,3 +19,4 @@
//: Take a deep breath and move on to the next page.
//:
//:[Previous](@previous) | page 4 of 7 | [Next: When Things Go Wrong 😰](@next)
// addition
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
//: This playground page, for example, has an error in it.
//:
//: 👈 Notice the red error symbol to the left of the line below. This is how a playground tells you where a problem is.
1000 / 0
1000 / 2
//: Since there is an error, the playground stops running your code.\
//: Notice that there are no results displayed in the sidebar. 👉
2 + 2
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ Next, find out how to put the results sidebar to better use.

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



12
43
3
7
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//: ## Exercise: Putting on a Show
//: Your friend is done with the pet show. With your help, it was a big success. Now your friend is putting on a concert. Tickets are for sale at $10 per ticket. The room rental is $50. Making posters for the show costs $40. Help your friend figure out if the show is going to make money or lose money.
// Number Of Tickets
//Number Of Tickets
150

// Ticket Price
@@ -22,7 +22,13 @@
(150 * 10) - (1000 + 40)
//: - callout(Exercise): Using the code above as a reference, use let statements to define constants to better solve your friend’s problem.\
//:Add your code below. To help you get started, the constant `numberOfTickets` is already defined.
let numberOfTickets = 150

//:
//:[Previous](@previous) | page 10 of 14 | [Next: Exercise: Lottery Tickets](@next)
let numberOfTickets = 150
let ticketPrice = 10
let roomRentalFee = 1000
let PosterCost = 40
let totalTicketvalue = numberOfTickets * ticketPrice
let totalExpenses = roomRentalFee + PosterCost
let TotalIncomeOfShow = totalTicketvalue - totalExpenses
Original file line number Diff line number Diff line change
@@ -31,3 +31,22 @@ 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)
let ticketsSold2 = 3400
let ticketPrice2 = 4
let printingCosts2 = 45
let advertising2 = 77
// Total takings
let totalTakings2 = ticketPrice * ticketsSold

// Jackpot
let jackpot2 = totalTakings / 2

// Expenses
let totalExpenses2 = printingCosts + advertising

// Profit
let profit2 = totalTakings - jackpot - totalExpenses

// Distribution
let programmersCut2 = profit / 10 // This is the answer you want to get over 100! 👉
let friendsCut2 = profit - programmersCut
Original file line number Diff line number Diff line change
@@ -21,3 +21,10 @@


//:[Previous](@previous) | page 12 of 14 | [Next: Exercise: Fixing Your Morning](@next)
let iphonegb = 8
let megabytes = 1000
let iphonegbsize = 3
let iphonement = (iphonegb - iphonegbsize )
let videotakes = 150
let totalvideotakes = ( iphonement * megabytes )/videotakes

Original file line number Diff line number Diff line change
@@ -7,8 +7,16 @@
*/
let brushTeeth = 3
// Add more here...
let uploadPhotos=10
let chooseClothes=15
let shower=20
let goJogging = 30
let finishHomework = 30
let fixLunch = 45


//: - 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.
let totl = brushTeeth+uploadPhotos+chooseClothes+shower+goJogging+finishHomework+fixLunch



@@ -17,6 +25,9 @@ let brushTeeth = 3
//:If there are things you don’t have to do and don't like to do, make a third group and go ahead and sum that one, too. \
//:\
//:Make a new constant for each group.
let Onadailybasis=chooseClothes+shower+goJogging+finishHomework

let youwanttodoit=brushTeeth+uploadPhotos+fixLunch



Original file line number Diff line number Diff line change
@@ -24,7 +24,16 @@ let rhso = co - lhso


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

let Box = 14
let watermelonloads = 3
let orangesweigh = 100
let watermelonsweigh = 200
let traceorangesweigh = Box * orangesweigh
let tracw = watermelonloads * watermelonsweigh
let watermelonransportcar = traceorangesweigh + tracw
let halfaloadofwatermelon = watermelonransportcar / 2
let leftload = halfaloadofwatermelon/orangesweigh
let rightload = Box - leftload



Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
//: Swift will accept names like this without complaint. But imagine coming back to read that code after vacation. Would you remember what `nd` or `n1` meant? And if you gave the playground to other programmers, how would they figure out what those names were supposed to mean?
//:
//: - callout(Just for fun): In Swift, you can use emoji in names. This is not considered good naming practice, but it can be fun. Below is the pet problem redone using emoji for names.
//numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters + numberofpotbellied + numberofish + numberosnake
let 🐶 = 8
let 🐱 = 4
let 🐹 = 2
@@ -26,3 +27,14 @@ 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 numberOfDogs = 8
let numberOfCats = 4
let umberOfHamsters = 2
let numberOfTurtles = 3
let numberosnake = 1
let numberofpotbellied = 1
let numberofish = 1

let totalNumberOfAnimals2 = numberOfDogs + numberOfCats + umberOfHamsters + numberOfTurtles + numberosnake + numberofpotbellied + numberofish

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

let numberOfCats2 = 5 - 1

let numberOfTurtles2 = 2 + 1

let numberOfHamsters2 = 1 + 1
let numberofpotbellied = 1
let numberofish = 1
let numberosnake = 1
let totalNumberOfAnimals2 = numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters + numberofpotbellied + numberofish + numberosnake

let totalNumberOfMammals2 = numberOfDogs + numberOfCats + numberOfHamsters + numberofpotbellied
Original file line number Diff line number Diff line change
@@ -35,3 +35,13 @@ 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 numberOfDogs2 = 6+2

let numberOfCats2 = 5-1

let numberOfTurtles2 = 2+1

let numberOfHamsters2 = 1+1
let totalNumberOfAnimals2 = numberOfDogs + numberOfCats + numberOfTurtles + numberOfHamsters

let totalNumberOfMammals2 = numberOfDogs + numberOfCats + numberOfHamsters
Original file line number Diff line number Diff line change
@@ -34,3 +34,19 @@
//: 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 Dogs
6

// Number Of Cats
5

// Number Of Turtles
2
// Number Of Hamsters
1

// Total Number Of Animals
6 + 5 + 2 + 1

// Total Number Of Mammals
6 + 5 + 1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='ios' display-mode='rendered' executeOnSourceChanges='true'>
<playground version='6.0' target-platform='macos' display-mode='rendered' executeOnSourceChanges='true'>
<pages>
<page name='Introduction'/>
<page name='Pet Problem'/>
Original file line number Diff line number Diff line change
@@ -21,16 +21,16 @@ let finishedMessage = username + " " + likesYourPostMessage
//:Combine your `firstName` and `likesYourPostMessage`\
//:Type each line of code below the relevant comment below.
// Declare a firstName constant

let firstName = "abdualziz"

// Declare a lastName constant

let lastName = "albalwi"

// Combine the strings into a fullName constant

let fullName = firstName + " " + lastName

// Combine your first name with likesYourPostMessage

let postmasege = "likes your post"

//: Next, find out how building strings by adding them can get complicated.
//:
Original file line number Diff line number Diff line change
@@ -8,9 +8,11 @@ let traditionalGreeting = "Hello, world!"
//: The declared string values also appear in the results sidebar. 👉
//: - experiment: Practice by declaring `favoriteMovie` and `favoriteSong` string constants for your favorite movie and song:
// Declare a favoriteMovie constant
let favoriteMovie = "the call"


// Declare a favoriteSong constant
let favoriteSong = "top 100 naems"


//: Next, take a string-based trip around the world.
Original file line number Diff line number Diff line change
@@ -34,3 +34,4 @@ let tableTwoResponse = "Perfect, merci bien."

//:
//:[Previous](@previous) | page 14 of 16 | [Next: Exercise: Go! Fight! Win!](@next)
let serverResponseToTableTwo2 = "Let me make sure I've got this right: \(customerOrderFour),\(customerOrderFive),\(customerOrderSix)"
Original file line number Diff line number Diff line change
@@ -31,3 +31,10 @@
_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 iphonegb = 8
let megabytes = 1000
let iphonegbsize = 3
let iphonement = (iphonegb - iphonegbsize )
let videotakes = 150
let totalvideotakes = ( iphonement * megabytes )/videotakes
let masege = "You can record \(totalvideotakes) more minutes of video."
Original file line number Diff line number Diff line change
@@ -26,3 +26,7 @@ let song = "\(refrain)\n\(refrain)\nYes, \(refrain)"

//:
//:[Previous](@previous) | page 15 of 16 | [Next: Exercise: Displaying Values](@next)
let schoolName2 = "university tabok"
let refrain2 = "hmm hmm HMMM hm-hmm \(schoolName2) hmm hmm HMMMMM"

let song2 = "\(refrain2)\n\(refrain)\nYes, \(refrain2)"
Original file line number Diff line number Diff line change
@@ -12,7 +12,15 @@ let newline = "Making new lines"
/*:
- experiment: Make a new string constant that is a list of the things you’ve learned, with each entry on a new line. Make sure you add the result to the playground page so that you can see the list properly.
*/

let constants2 = "They were all outside the university"
let unicode2 = " (😁)"
let combining2 = constants2 + " " + unicode2
let interpolation2 = "\(constants2) \(unicode2)"
let escaping2 = "which university do you study in \"university tabok\""
let newline2 = """
what is your specialty؟
IT
"""



Original file line number Diff line number Diff line change
@@ -15,6 +15,14 @@ let goalieReportString = "At the game yesterday, \(goalieName) had \(firstHalfSa
Sample story: “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 <noun> <place> feeling very <positive emotion>. But then they felt <negative emotion>. They were all out of <noun>!”
*/
// Add your version of the story below
let name = "abdualziz"
let number = 2
let neme2 = "salem"
let place = "supermarket"
let positiveemotion = "hapy"
let negativeemotion = "sad"
let place2 = "supermarket"
let string = "Today was a big day for\(name).They had finally saved up\(number)dollars and were going to buy a\(neme2).They went to the\(place)feeling very\(positiveemotion).But then they felt\(negativeemotion).They were all out of\(place2)"



Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ let favoriteFood = "pie"
let reason = "tasty"

// Define a string below in the pattern "I like ___ because it is ___."

let post = "I like \(favoriteFood), because it is \(reason)"

//: On the next page, see what happens with long strings.
//:
Original file line number Diff line number Diff line change
@@ -26,8 +26,11 @@ func rowTheBoat() {
What happens if you call your function more than once?

*/


func tabuk() {
print("Tuwaiq_Academy")

}
tabuk()



Original file line number Diff line number Diff line change
@@ -28,8 +28,10 @@ merrilyDream()
breatheBetweenVerses()
rowTheBoat()
//: - callout(Exercise): Write a function called `crocodileScream()` for the second two lines of the second verse, and call it to complete the song in the console.


func crocodileScream(){
print("merrilyDream()")
}
crocodileScream()



Original file line number Diff line number Diff line change
@@ -46,3 +46,28 @@ verseThree()

[Previous](@previous) | page 9 of 12 | [Next: Wrapup](@next)
*/
func rowTheBoat2() {
print("Ride, ride, ride your bike")
print("With your cycling team")
}

func verseOne2() {
rowTheBoat2()
merrilyDream()
}

func verseTwo2() {
rowTheBoat2()
crocodileScream()
}

func verseThree2() {
rowTheBoat2()
repetitiveTheme()
}

verseOne2()
breatheBetweenVerses()
verseTwo2()
breatheBetweenVerses()
verseThree2()
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ func laughingSubmarine() {
}

// Write the verse two function below

laughingSubmarine()

//: On the next page, learn about one of the things that can go wrong when using functions of functions.
//:
Original file line number Diff line number Diff line change
@@ -17,3 +17,8 @@ verseThree()

[Previous](@previous) | page 8 of 12 | [Next: Change Something Once](@next)
*/
breatheBetweenVerses()
verseTwo()
verseOne()
verseThree()
breatheBetweenVerses()
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ func merrilyDream() {
func verseOne() {
rowTheBoat()
merrilyDream()
// verseOne()
}

verseOne()
@@ -32,3 +33,6 @@ verseOne()

[Previous](@previous) | page 7 of 12 | [Next: Hiding Complexity](@next)
*/



Original file line number Diff line number Diff line change
@@ -23,3 +23,4 @@

page 1 of 12 | [Next: Calling a Function](@next)
*/
let simple="meet for coffee"
Original file line number Diff line number Diff line change
@@ -9,9 +9,22 @@

Write out the song or meme using `print` statements, then look for patterns and repetition and choose groups of lines to combine into functions. This is a free-form exercise, so you can do whatever you like.
*/



func song () {
print("Row, row, row your boat")
print("Gently down the stream")
}



func breath() {
print(" ~ ")
}
func str (){
song()
breath()
// str()
}
str()



Original file line number Diff line number Diff line change
@@ -5,7 +5,22 @@

Inside one of the functions, make changes that make the whole text mean something different, or make it funnier. You could change a name to your name or a friend’s, change a word to something else that rhymes, or just play around.
*/

func username() {
print("abdualziz")
print("salem")
}



func specialization() {
print(" information ~ tecnology ")
}
func str (){
username()
specialization()
// str()
}
str()