Through exercise 7, excepting my billion dots.

This commit is contained in:
Josh Mudge 2018-09-15 17:19:03 -06:00
parent 056494f2d9
commit bc5c9c0b77
9 changed files with 55 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
out.txt

View File

View File

View File

View File

View File

25
2/ex6.py Normal file
View File

@ -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.

29
ex7.py Normal file
View File

@ -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.