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 want that hit RETURN." | |
| 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
| 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 want that hit RETURN." | |
| 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
| from sys import argv | |
| script, filename = argv | |
| txt = open(filename) | |
| print "Here's your file %r:" % filename | |
| print txt.read() | |
| print "Type the filename again:" |
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
| #LPTHW Exercise 14 | |
| from sys import argv | |
| script, user_name = argv | |
| prompt = '> ' | |
| print "Hi %s, I'm the %s script." % (user_name, script) | |
| print "I'd like to ask you a few questions." |
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
| #LPTHW - Exercise 13 | |
| 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 |
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
| #LPTHW Exercise 12 | |
| 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 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
| #LPTHW Exercise 11 | |
| print "How old are you?", | |
| age = raw_input() | |
| print "How tall are you?", | |
| height = raw_input() | |
| print "How much do you weigh?", | |
| 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
| 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 | |
| \t* Catnip\n\t* Grass | |
| """ |
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
| # Here's some new strange stuff, remember type it exactly. | |
| days = "Mon Tue Wed Thu Fri Sat Sun" | |
| months = "Jan\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. |
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
| 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) | |
| print formatter % ( | |
| "I had this thing.", | |
| "That you could type up right.", | |
| "But it didn't sing.", |