From bc5c9c0b778f179bc14067353a9aa3e647b99ed1 Mon Sep 17 00:00:00 2001 From: Josh Mudge Date: Sat, 15 Sep 2018 17:19:03 -0600 Subject: [PATCH] Through exercise 7, excepting my billion dots. --- .gitignore | 1 + ex1.py => 2/ex1.py | 0 ex2.py => 2/ex2.py | 0 ex3.py => 2/ex3.py | 0 ex4.py => 2/ex4.py | 0 ex5.py => 2/ex5.py | 0 2/ex6.py | 25 +++++++++++++++++++++++++ newfile.py => 2/newfile.py | 0 ex7.py | 29 +++++++++++++++++++++++++++++ 9 files changed, 55 insertions(+) create mode 100644 .gitignore rename ex1.py => 2/ex1.py (100%) rename ex2.py => 2/ex2.py (100%) rename ex3.py => 2/ex3.py (100%) rename ex4.py => 2/ex4.py (100%) rename ex5.py => 2/ex5.py (100%) create mode 100644 2/ex6.py rename newfile.py => 2/newfile.py (100%) create mode 100644 ex7.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9cd6546 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +out.txt diff --git a/ex1.py b/2/ex1.py similarity index 100% rename from ex1.py rename to 2/ex1.py diff --git a/ex2.py b/2/ex2.py similarity index 100% rename from ex2.py rename to 2/ex2.py diff --git a/ex3.py b/2/ex3.py similarity index 100% rename from ex3.py rename to 2/ex3.py diff --git a/ex4.py b/2/ex4.py similarity index 100% rename from ex4.py rename to 2/ex4.py diff --git a/ex5.py b/2/ex5.py similarity index 100% rename from ex5.py rename to 2/ex5.py diff --git a/2/ex6.py b/2/ex6.py new file mode 100644 index 0000000..6527cd5 --- /dev/null +++ b/2/ex6.py @@ -0,0 +1,25 @@ +x = "There are %d types of people." % 10 # Create a variable that is a string with a variable of %d which is equal to 10. +binary = "binary" # Create variable that is a string. +do_not = "don't" # Create variable that is a string. +y = "Those who know %s and those who %s." % (binary, do_not) # %s and %s correspond to binary and do_not + +print x # Print variable x +print y # Print variable y + +print "I also said: %r." % x #2: First # Print a string with a variable. +print "I also said: '%s'." % y #2: Second and third # Print a string with the string variable y + +hilarious = False # Set variable hilarious to False +joke_evaluation = "Isn't that joke so funny?! %r" #2: Fourth # Set a variable to a string with a variable yet to be referenced. + +print joke_evaluation % hilarious # print a variable and another variable (referring back to %r) + +w = "This is the left side of..." # A string corresponding to the left side of a bigger string. +e = "a string with a right side." # A string corresponding to the right side of a bigger string. + +print w + e # Add the strings together. + +#1. Done. +#2. Done +#3. You called y (2 strings in a string) and x (1 string in a string) and you called joke_evaluation (line 13 & 15) which has another string in a string for a total of 4self. +#4. diff --git a/newfile.py b/2/newfile.py similarity index 100% rename from newfile.py rename to 2/newfile.py diff --git a/ex7.py b/ex7.py new file mode 100644 index 0000000..7abc484 --- /dev/null +++ b/ex7.py @@ -0,0 +1,29 @@ +print("Mary had a little lamb.") # Print string +print("Its fleece was white as {}.".format('snow')) # Print string with format. +print("And everywhere that Mary went.") # Print string. + +with open('out.txt', 'w') as f: + print("." * 1000000000, file=f) # A little fun with a billion dots. + +end1 = "C" # Set variable to a string. +end2 = "h" # Set variable to a string. +end3 = "e" # Set variable to a string. +end4 = "e" # Set variable to a string. +end5 = "s" # Set variable to a string. +end6 = "e" # Set variable to a string. +end7 = "B" # Set variable to a string. +end8 = "u" # Set variable to a string. +end9 = "r" # Set variable to a string. +end10 = "g" # Set variable to a string. +end11 = "e" # Set variable to a string. +end12 = "r" # Set variable to a string. + + +# watch end = ' ' at the end. try removing it to see what happens. +print(end1 + end2 + end3 + end4 + end5 + end6, end=' ') # Print combined variables without a space in between on the same line as the next set of them with a space in between: +print(end7 + end8 + end9 + end10 + end11 + end12) # Print variables without spaces in between + +#1. Done +#2. Done + +# Break it.