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

complet the tasks #2

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,4 @@
//: Next, learn how programmers can leave notes in code.
//:
//:[Previous](@previous) | page 3 of 7 | [Next: Comments](@next)
(100+10)/2
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@
//: 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




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/1
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)
*/

7
8
9


Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
(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 numberOfTicketPrice = 10
let RoomRentalFee = 1000
let PosterCost = 40

let TotalTicketValue = numberOfTickets * numberOfTicketPrice
let TotalExpenses = RoomRentalFee + PosterCost
let TotalIncomeOfShow = (numberOfTickets * numberOfTicketPrice)-(RoomRentalFee + PosterCost)
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
Another reason that naming things and only setting a value once is useful is that it lets you decide on the correct way of calculating something, then change the values and check the answers.
*/
// Values you should edit
let ticketsSold = 1000
let ticketPrice = 1
let printingCosts = 20
let advertising = 50
let ticketsSold = 50
let ticketPrice = 10
let printingCosts = 200
let advertising = 3
/*:
- callout(Exercise): You’ve done enough work for free for your friend. For this venture, your friend will give you a cut of the profits in return for your help. Your friend will give you a tenth of the profits. The jackpot is half of the total ticket sales money. Try changing the numbers above - tickets sold, ticket price, printing or advertising costs and see if you can get your cut up to 100 or more.

Expand All @@ -31,3 +31,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 @@ -15,6 +15,14 @@
- callout(Exercise): How many minutes of video will it take to fill the phone?\
_Hint_: Do all of your calculations in megabytes (MB).
*/
let sizeGB = 8
let sizeMB = 1000
let usedSize = 3
let totalSizeInMB = sizeGB*sizeMB
let usedSizeInMB = usedSize*sizeMB
let oneMin = 150
let totalSizeLeft = totalSizeInMB - usedSizeInMB
let minutes = totalSizeLeft/oneMin



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,31 @@ let brushTeeth = 3

//: - 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.



//: - callout(Exercise): Add up the constants again, but this time in separate groups: one group for things you have to do and another group for things you like to do.\
//:\
//: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.



/*:
See what happens to your total time spent getting ready if you tweak the durations of the different activities. How short of a shower would you have to take in order to have more time to message your friends? Or go for a longer run? How much more time would you need if you decided to spend as long as you wanted doing all the activities you like best?

Change the numbers until you’ve got a design for your ideal morning. What would have to change in order for you to be able to actually spend your morning time this way?
*/





//:[Previous](@previous) | page 13 of 14 | [Next: Exercise: Good Names](@next)

let BrushTeeth=1
let uploadPhotos=2
let shower=3
let goJogging=4
let total = brushTeeth+uploadPhotos+shower+goJogging
//love things
let drinkcoffe=1
let swimming=2
let eatchoclata=3
let total2=drinkcoffe+swimming+eatchoclata
//hat thangs
let sleeplate=5
let Ironing=7
let total3=sleeplate+Ironing
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +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 countoOrang = 14
let countwatermelons = 3
let orangeweigh = 100
let watermelonsweigh = 200
let truckorange = countoOrang*orangeweigh
let truckwatermelons = countwatermelons*watermelonsweigh
let trucktotal = truckorange + truckwatermelons
let eachside = trucktotal / 2
let lefthandside = eachside / orangeweigh
let righthandsid = countoOrang - lefthandside



Expand Down
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 numberOfDogs2 = 6 + 2

let numberOfCats2 = 5 - 1

let numberOfTurtles2 = 2 + 1

let numberOfHamsters2 = 1 + 1

let potbelliedpig = 1
let fish = 1
let snak=1
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
1

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

// Total Number Of Mammals
6 + 5 + 1
Expand All @@ -28,3 +28,5 @@
//: Next you’ll find out how to do that.
//:
//:[Previous](@previous) | page 3 of 14 | [Next: Naming Things](@next)
//value
5+0
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'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@ let finishedMessage = username + " " + likesYourPostMessage
//:Type each line of code below the relevant comment below.
// Declare a firstName constant


// Declare a lastName constant


// Combine the strings into a fullName constant


// Combine your first name with 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)
// Declare a firstName constant
let FirstName = "Reema"

// Declare a lastName constant
let LastName = " Mousa Alatawi "

// Combine the strings into a fullName constant
let FullName = FirstName + LastName

// Combine your first name with likesYourPostMessage
let FinishedMessage = FirstName+" "+likesYourPostMessage
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ let traditionalGreeting = "Hello, world!"
// Declare a favoriteMovie constant



// Declare a favoriteSong constant


//: Next, take a string-based trip around the world.
//:
//:[Previous](@previous) | page 3 of 16 | [Next: Unicode](@next)
// Declare a favoriteMovie constant
let FavoritMovie = "Hi "


// Declare a favoriteSong constant
let FavoritSong = "helloworld"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@

_Hint:_ Do all of your calculations in megabytes.
*/
let sizeGB = 8
let sizeMB = 1000
let usedSize = 3
let totalSizeInMB = sizeGB*sizeMB
let usedSizeInMB = usedSize*sizeMB
let oneMin = 150
let totalSizeLeft = totalSizeInMB - usedSizeInMB
let minutes = totalSizeLeft/oneMin

print("You can record \(minutes )more minutes of video.")



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ 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.
*/


var result="Declaring string constants"+"Unicode characters (😎)"+"Combining strings using "+"String interpolation (aka Fill in the Blanks)"+"Escape characters for \"special powers\""+"Making new lines"
print(result)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ let goalieReportString = "At the game yesterday, \(goalieName) had \(firstHalfSa
*/
// Add your version of the story below



//:
//:
//: Next you’ll see a few more tricks with strings.
//:
//:[Previous](@previous) | page 9 of 16 | [Next: The Great Escape](@next)
// Add your version of the story below
let name="Reeema"
let number = 15
let adjective = "Chocolate"
let place = "supermarket"
let positive="happy"
let negative="sad"
let noun="supermarket"
let storyIs = "Today was a big day for \(name). They had finally saved up \(number) dollars and were going to buy a \(adjective) . They went to the \(place) feeling very \(positive) But then they felt \(negative). They were all out of \(noun)"
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ let welcomeString = "Hello \(firstName), welcome to \(city)"
//: “I like _____ because it is _____.”
//:
// Change this to your favorite food
let favoriteFood = "pie"

// Change this to why you like it
let reason = "tasty"

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


//: On the next page, see what happens with long strings.
//:
//:[Previous](@previous) | page 7 of 16 | [Next: Viewing Playground Results](@next)
// Change this to your favorite food
let favoriteFood = "pie"

// Change this to why you like it
let reason = "tasty"

// Define a string below in the pattern "I like ___ because it is ___."
let WelcomeString = "I Like " + favoriteFood+" " + "becousa it's " + reason
2 changes: 1 addition & 1 deletion 03 Strings/Strings.playground/contents.xcplayground
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='Characters'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ func rowTheBoat() {
To actually run the code, you have to _call_ the function. Typing the name of the function will call the function. Uncomment the line below:
*/
// rowTheBoat()
/*:
When you've called a function in a playground, you'll see results appear in the sidebar. Calling the `rowTheBoat` function will print text in the console area below, too.

- callout(Exercise): Write your own function that prints something to the console, then call your new function. Pay attention to the example above so that you know where all of the parentheses `()` and braces `{}` should go.
What happens if you call your function more than once?

*/







//: Next, learn about how to think about tasks and divide them up in a way that makes sense.
//:
//: [Previous](@previous) | page 4 of 12 | [Next: Breaking It Down](@next)
func greeting(){
print("helloworld")
print("hievryone")

}
greeting()



Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ rowTheBoat()
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.











//: Next, learn about making larger groups of tasks.
//:
//: [Previous](@previous) | page 5 of 12 | [Next: Functions Within Functions](@next)

func crocodileScream(){
merrilyDream()

}

rowTheBoat()
merrilyDream()
breatheBetweenVerses()
rowTheBoat()
crocodileScream()
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,31 @@ verseThree()

[Previous](@previous) | page 9 of 12 | [Next: Wrapup](@next)
*/

print("\n\n--- Exercise ---")

func rowTheBoat2() {
print("Ride, ride, ride your bik")
print("With your cycling team")
}

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

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

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

verseOne2()
breatheBetweenVerses()
verseTwo2()
breatheBetweenVerses()
verseThree2()
Loading