This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "Mary had a little lamb." | |
print "Its fleece was white as %s." % 'snow' | |
print "And everywhere that Mary went." | |
print "." * 10 # what'd that do? | |
end1 = "C" | |
end2 = "h" | |
end3 = "e" | |
end4 = "e" | |
end5 = "s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
formatter= "%r %r %r %r" | |
print formatter % (1, 2, 3, 4) | |
print formatter % ("one", "two", "three", "four") | |
print formatter % (True, False, False, True) | |
print formatter % (formatter, formatter, formatter, formatter) | |
print formatter % ( | |
"I had this thing.", | |
"That could type up right.", | |
"But it didn't sing.", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here's some new strange stuff, remember type it exactly. | |
days= "Mon Tue Wed Thu Fri Sat Sun" | |
months= "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" | |
print "Here are the days: ", days | |
print "Here are the months: ", months | |
print """ | |
There's something going on here. | |
With the three double-quotes. | |
We'll be able to type as much as we like. | |
Even 4 lines if we want, or 5, or 6. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "I am 6'2\" tall." #escape double-quote inside string | |
print 'I am 6\'2" tall.' #escape single-quote inside string | |
tabby_cat = "\tI'm tabbed in." | |
persian_cat = "I'm split\non a line." | |
backslash_cat = "I'm \\ a \\ cat." | |
fat_cat = ''' | |
I'll do a list: | |
\t* Cat food | |
\t* Fishies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y = raw_input("Name? ") | |
age = raw_input("How old are you? ") | |
height = raw_input("How tall are you? ") | |
weight = raw_input("How much do you weigh? ") | |
print "So, you're %r old, %r tall and %r heavy." % ( | |
age, height, weight) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
script, first, second, third = argv | |
print "What's this app's name?", script | |
print "What's your name human?", first | |
print "How tall you at?", second | |
print "What it weigh? (the it is you)", third | |
print "wait what is your name? ", | |
name = raw_input () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
script, user_name = argv | |
prompt = 'type that shit out son! ' | |
print "Hi%s, I'm the %s script." % (user_name, script) | |
print "I'd like to ask you a few questions." | |
print "Do you like me %s?" % user_name | |
likes = raw_input(prompt) | |
print "Where do you live %s?" % user_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#says what we are opening from where | |
from sys import argv | |
#here's what the two things we are importing will be | |
script, filename = argv | |
#variable txt means open that file | |
txt= open(filename) | |
#uses modulus to call out the filename | |
print "Here's your file %r:" % filename | |
#prints the file | |
print txt.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
script, filename = argv | |
print "We're going to erase %r." % filename | |
print "If you don't want that, hit CTRL-C (^C)." | |
print "If you do want that, hit RETURN." | |
raw_input("?") | |
print "Opening the file..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
from os.path import exists | |
script, from_file, to_file = argv | |
print "Copying from %s to %s" % (from_file, to_file) | |
#we could do these two on one line too, how? | |
in_file = open(from_file) | |
indata = in_file.read() | |
print "The input file is %d bytes long" % len(indata) | |
print "Does the output file exist? %r" % exists(to_file) |
NewerOlder