diff --git a/python/lp3thw/Exercise04/ex4.py b/python/lp3thw/Exercise04/ex4.py index e69de29..b42c28d 100644 --- a/python/lp3thw/Exercise04/ex4.py +++ b/python/lp3thw/Exercise04/ex4.py @@ -0,0 +1,15 @@ +cars = 100 +space_in_a_car = 4.0 +drivers = 30 +passengers = 90 +cars_not_driven = cars - drivers +cars_driven = drivers +carpool_capacity = cars_driven * space_in_a_car +average_passengers_per_car = passengers / cars_driven + +print("There are %d cars available" %cars) +print("There are only %d drivers available" %drivers) +print("There will be %d empty cars today" %cars_not_driven) +print("We can transport %.1f people today" %carpool_capacity) +print("We have %d to carpool today" %passengers) +print("We have to put about %.1f in each car" %average_passengers_per_car) diff --git a/python/lp3thw/Exercise05/ex5.py b/python/lp3thw/Exercise05/ex5.py new file mode 100644 index 0000000..a4d693f --- /dev/null +++ b/python/lp3thw/Exercise05/ex5.py @@ -0,0 +1,18 @@ +myName = "Ganome" +myAge = 35 +myHeight = 72 +myWeight = 180 +myEyes = "Blue" +myTeeth = "white" +myHair = "Brown" + +print(f"Let's talk about {myName}.") +print(f"He's {myHeight} inches tall.") +print(f"He's {myWeight} pounds heavy.") +print(f"Actually that's not too heavy.") +print(f"Hes got {myEyes} eyes and {myHair} hair.") +print(f"His teeth are usuallyy {myTeeth} depending on the coffee.") + +#tricky line +total = myAge + myHeight + myWeight +print(f"If i add {myAge}, {myHeight}, and {myWeight} I get {total}.") \ No newline at end of file diff --git a/python/lp3thw/Exercise06/ex6.py b/python/lp3thw/Exercise06/ex6.py new file mode 100644 index 0000000..d21dac2 --- /dev/null +++ b/python/lp3thw/Exercise06/ex6.py @@ -0,0 +1,21 @@ +typesOfPeople = 10 +x = f"There are {typesOfPeople} types of people" + +binary = "binary" +doNot = "don't" +y = f"Those who know {binary} and those who {doNot}." + +print(x) +print(y) + +print(f"I said: {x}") +print(f"I also said: '{y}'") #notice that we can wrap our {} variable in quotes and they still work + +hilarious = False +jokeEvaluation = "Isn't that joke so funny! {}" +print(jokeEvaluation.format(hilarious)) + +w = "This is the left side of ..." +e = "A string with a right side." + +print(w + e) diff --git a/python/lp3thw/Exercise07/ex7.py b/python/lp3thw/Exercise07/ex7.py new file mode 100644 index 0000000..47866f7 --- /dev/null +++ b/python/lp3thw/Exercise07/ex7.py @@ -0,0 +1,22 @@ +print("Mary had a little lamb.") +print("Its fleece was white as {}.".format('snow')) +print("And everywhere that Mary went.") +print(". " * 10) + +end1 = "C" +end2 = "h" +end3 = "e" +end4 = "e" +end5 = "s" +end6 = "e" +end7 = "B" +end8 = "u" +end9 = "r" +end10 = "g" +end11 = "e" +end12 = "r" + +#The comment at the end of the next line is what tells the print command to not start a new line! end=' ' +print(end1 + end2 + end3 + end4 + end5 + end6)# , end=' ') +print(end7 + end8 + end9 + end10 + end11 + end12) + diff --git a/python/lp3thw/Exercise08/ex8.py b/python/lp3thw/Exercise08/ex8.py new file mode 100644 index 0000000..f1a6ed2 --- /dev/null +++ b/python/lp3thw/Exercise08/ex8.py @@ -0,0 +1,12 @@ +formatter = "{} {} {} {}" + +print(formatter.format(1, 2, 3, 4)) +print(formatter.format("one", "two", "three", "four")) +print(formatter.format(True, False, False, True)) +print(formatter.format(formatter, formatter, formatter, formatter)) +print(formatter.format( + "MultiLine input", + "Is Horrendously Ugly", + "To code", + "And to read!" +)) \ No newline at end of file diff --git a/python/lp3thw/Exercise09/ex9.py b/python/lp3thw/Exercise09/ex9.py new file mode 100644 index 0000000..82a76d7 --- /dev/null +++ b/python/lp3thw/Exercise09/ex9.py @@ -0,0 +1,12 @@ +days = "Mon Tue Wed Thu Fri Sat Sun" +months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJuly\nAug" + +print("Here are the days: ", days) +print("Here are the months: ", months) + +print( """ +There's something going on here. +With the three double-quites. +We'ss be able to typse as much as we like. +Even 4 lines if we want. or 5. or 6. +""") \ No newline at end of file diff --git a/python/lp3thw/Exercise10/Escape-Sequences.txt b/python/lp3thw/Exercise10/Escape-Sequences.txt new file mode 100644 index 0000000..3948e45 --- /dev/null +++ b/python/lp3thw/Exercise10/Escape-Sequences.txt @@ -0,0 +1,16 @@ +Escape SequencesThis is all of the escape sequences Python supports. You may not use many of these, but memorize +their format and what they do anyway. Try them out in some strings to see if you can make them work.Escape What it does. +\\Backslash (\) +\'Single-quote (') +\"Double-quote (") +\aASCII bell (BEL) +\bASCII backspace (BS) +\fASCII formfeed (FF) +\nASCII linefeed (LF) +\N{name}Character named name in the Unicode database (Unicode only)\rCarriage return (CR) +\tHorizontal tab (TAB) +\uxxxxCharacter with 16-bit hex value xxxx +\UxxxxxxxxCharacter with 32-bit hex value xxxxxxxx +\vASCII vertical tab (VT) +\000Character with octal value000 +\xhhCharacter with hex value hh \ No newline at end of file diff --git a/python/lp3thw/Exercise10/ex10.py b/python/lp3thw/Exercise10/ex10.py new file mode 100644 index 0000000..5f5af6c --- /dev/null +++ b/python/lp3thw/Exercise10/ex10.py @@ -0,0 +1,15 @@ +tabbyCat = "\tI'm Tabbed in." +persianCat = "I'm Split\non a line." +backslashCat = "I'm \\ a \\ cat." + +fatCat = """ +I'll do a list: +\t* Cat Food +\t* Fishies +\t* Catnit\n\t* Grass +""" + +print(tabbyCat) +print(persianCat) +print(backslashCat) +print(fatCat) \ No newline at end of file diff --git a/python/lp3thw/Exercise11/ex11.py b/python/lp3thw/Exercise11/ex11.py new file mode 100644 index 0000000..a7ef2ee --- /dev/null +++ b/python/lp3thw/Exercise11/ex11.py @@ -0,0 +1,8 @@ +print("How old are you?", end=' ') +age = input() +print("How tall are you?", end=' ') +height = input() +print("How much do you weigh?", end=' ') +weight = input() + +print(f"So you are {age} years old, {height} tall and {weight} heavy.") \ No newline at end of file diff --git a/python/lp3thw/Exercise12/ex12.py b/python/lp3thw/Exercise12/ex12.py new file mode 100644 index 0000000..8ca35aa --- /dev/null +++ b/python/lp3thw/Exercise12/ex12.py @@ -0,0 +1,6 @@ +age = input("How old are you? ") +height = input("How tall are you?") +weight = input("How much do you weight?") + + +print(f"So, you're {age} old, {height} tall, and {weight} heavy/") \ No newline at end of file