This file contains hidden or 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
def add(a, b): | |
print "ADDING %d + %d" % (a, b) | |
return a + b | |
def subtract(a, b): | |
print "SUBTRACTING %d - %d" % (a,b) | |
return a - b | |
def multiply(a, b): | |
print "MULTIPLYING %d * %d" % (a, b) |
This file contains hidden or 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
def add(a, b): | |
print "ADDING %d + %d" % (a, b) | |
return a + b | |
def subtract(a, b): | |
print "SUBTRACTING %d - %d" % (a,b) | |
return a - b | |
def multiply(a, b): | |
print "MULTIPLYING %d * %d" % (a, b) |
This file contains hidden or 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 "The script is called:", script | |
print "Your first variable is:", first | |
print "Your second variable is:", second | |
print "Your third variable is:", third | |
name = raw_input("name? ") | |
snark = " good one %s" % "huh" | |
print name + snark |
This file contains hidden or 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 "How old are you?", | |
age = raw_input () | |
print "How tall are you?", | |
height = raw_input () | |
print "How much do you weight?", | |
weight = raw_input () | |
print "So you're %r old, %r tall and %r heavy." % ( | |
age, height, weight) |
This file contains hidden or 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) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |