def main(): sentence = "All good things come to those who wait." words = ex25.break_words(sentence) print(words) sorted_words = ex25.sort_words(words) print(sorted_words) ex25.print_first_word(sorted_words) ex25.print_last_word(sorted_words) print(sorted_words) sorted_words = ex25.sort_sentence(sentence) print(sorted_words) ex25.print_first_and_last(sentence) ex25.print_first_and_last_sorted(sentence)
def main(): """Exercise 26: Congratulations, Take a Test!""" print "Let's practice everything." print 'You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.' poem = """ \tThe lovely world with logic so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires an explantion \n\t\twhere there is none. """ print "--------------" print poem print "--------------" five = 10 - 2 + 3 - 5 print "This should be five: %s" % five start_point = 10000 beans, jars, crates = secret_formula(start_point) print "With a starting point of: %d" % start_point print "We'd have %d jeans, %d jars, and %d crates." % (beans, jars, crates) start_point = start_point / 10 print "We can also do that this way:" print "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_point) sentence = "All god\tthings come to those who weight." words = ex25.break_words(sentence) sorted_words = ex25.sort_words(words) print_first_word(words) print_last_word(words) print_first_word(sorted_words) print_last_word(sorted_words) sorted_words = ex25.sort_sentence(sentence) print sorted_words print_first_and_last(sentence) print_first_and_last_sorted(sentence)
import ex25 sentence = "All good things come to those who wait." words = ex25.break_words(sentence) words sorted_words = ex25.sort_words(sentence) sorted_words ex25.print_first_word(words) ex25.print_last_word(words) wordsex.25
import ex25 sentence = 'All good thing come to those who wait.' words = ex25.break_words(sentence) print(words) print(ex25.sort_words(words)) ex25.print_first_word(words) ex25.print_last_word(words) print(words) print(ex25.sort_sentence(sentence)) ex25.print_first_and_last(sentence) ex25.print_first_and_last_sorted(sentence)
start_point = 10000 #beans, jars, crates == secret_formula(start-point) beans, jars, crates = secret_formula(start_point) print "With a starting point of: %d" % start_point print "We'd have %d jeans, %d jars, and %d crates." % (beans, jars, crates) start_point = start_point / 10 print "We can also do that this way:" #print "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_pont) print "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_point) sentence = "All god\tthings come to those who weight." words = ex25.break_words(sentence) #此处需要引用到ex25.py里面的方法,所以需要在开头的时候把ex25.py里面的函数导入 sorted_words = ex25.sort_words(words)#导入方式为:import ex25 print_first_word(words) print_last_word(words) #.print_first_word(sorted_words) print_first_word(sorted_words) print_last_word(sorted_words) sorted_words = ex25.sort_sentence(sentence) #prin sorted_words print sorted_words #print_irst_and_last(sentence) NameError: name 'print_irst_and_last' is not defined print_first_and_last(sentence) #print_first_a_last_sorted(senence)
from hello import print_hello import ex25 print_hello() ex25.break_words("sting like a bee") ex25.print_first_and_last("sting like a bee") ex25.print_first_word("sting like a bee") ex25.print_last_word("sting like a bee") ex25.sort_sentence("sting like a bee") ex25.sort_words("sting like a bee")
import ex25 sentence = "The quick brown fox jumps over the lazy dog." words = ex25.break_words(sentence) print ex25.break_words(sentence) print "\n" print ex25.sort_words(words) print "\n" print ex25.print_first_word(words) print "\n" print ex25.print_last_word(words) print "\n" print ex25.sort_sentence(sentence) print "\n" print ex25.print_first_and_last(sentence) print "\n" print ex25.print_first_and_last_sorted(sentence)
crates = jars / 100 return jelly_beans, jars, crates start_point = 10000 beans, jars, crates = secret_formula(start_point) print "With a starting point of: %d" % start_point print "We'd have %d beans, %d jars, and %d crates." % (beans, jars, crates) start_point = start_point / 10 print "We can also do that this way:" print "We'd have %d beans, %d jars, and %d crates." % secret_formula(start_point) sentence = "All good things come to those who wait." words =break_words(sentence) sorted_words =sort_words(words) ex25.print_first_word(words) ex25.print_last_word(words) ex25.print_first_word(sorted_words) ex25.print_last_word(sorted_words) ex25.sorted_words =ex25.sort_sentence(sentence) print sorted_words ex25.print_first_and_last(sentence) ex25.print_first_and_last_sorted(sentence)
import ex25 # no need to add .py print("Hello World!") sentence = "All good things come to those who wait." words = ex25.break_words(sentence) print "(variable)word is now %s:" % (words) # see ['All', 'Good.....] sorted_words = ex25.sort_words(words) # remember to add words print "(variable)sorted_words is now %s:" % (sorted_words) ex25.print_first_word(words) ex25.print_last_word(words) print "after pop twice, (variable)word is now : %s" % (words) ex25.print_first_word(sorted_words) ex25.print_last_word(sorted_words) print "after pop twice (variable)sorted_words is now: %s" % (sorted_words) ex25.print_first_and_last(sentence) ex25.print_first_and_last_sorted(sentence)
return jelly_beans, jars, crates start_point = 10000 beans, jars, crates == secret_formula(start-point) print("With a starting point of: %d % start_point) print("We'd have %d jeans, %d jars, and %d crates.".%(beans, jars, crates)) start_point = start_point / 10 print("We can also do that this way:") print("We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_point)) sentence = "All god\tthings come to those who weight." words = ex25.break_words(sentence) #ex25에서 break_words란 함수를 가져와 사용한다는 의미 sorted_words - ex25.sort_words(words) print_first_word(words) print_last_word(words) .print_first_word(sorted_words) print_last_word(sorted_words) sorted_words = ex25.sort_sentence(sentence) prin sorted_words print_irst_and_last(sentence) print_first_a_last_sorted(sentence)
import ex25 ex25.print_first_word("Lol you got trolled") ex25.sort_words( "lol lol lol you lol lol lol got lol lol lol trolled lol lol lol ! lol lol lol" )
START_POINT = 10000 BEANS, JARS, CRATES = secret_formula(START_POINT) print "With a starting point of: %d" % START_POINT print "We'd have %d beans, %d jars, and %d crates." % (BEANS, JARS, CRATES) START_POINT = START_POINT / 10 print "We can also do that this way:" print "We'd have %d beans, %d jars, and %d crates." % secret_formula( START_POINT) SENTENCE = "All good things come to those who wait." import ex25 WORDS = ex25.break_words(SENTENCE) SORTED_WORDS = ex25.sort_words(WORDS) print_first_word(WORDS) print_last_word(WORDS) print_first_word(SORTED_WORDS) print_last_word(SORTED_WORDS) SORTED_WORDS = ex25.sort_sentence(SENTENCE) print SORTED_WORDS print_first_and_last(SENTENCE) print_first_and_last_sorted(SENTENCE)
import ex25 sentence = "All good things come to those who wait." words = ex25.break_words(sentence) print words sorted_words = ex25.sort_words(words) # s/words/sentence/ and you get: # ...'A', 'a', 'c', 'd', 'e', 'e', 'g', 'g', 'h', 'h', 'h', 'i', 'i', 'l', 'l', 'm', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 's', 's', 't', 't', 't', 't', 'w', 'w'] print sorted_words ex25.print_first_word(sorted_words) ex25.print_last_word(sorted_words) # if you print ^ it adds 'none' below each line print sorted_words sorted_words = ex25.sort_sentence(sentence) print sorted_words ex25.print_first_and_last(sentence) ex25.print_first_and_last_sorted(sentence)
import ex25 sentence = "I am a dog" words = ex25.break_words(sentence) print words print ex25.sort_words(words) print ex25.print_first_word(words) print ex25.print_last_word(words) print ex25.sort_sentence(sentence) print ex25.print_first_and_last(sentence) print ex25.print_first_and_last_sorted(sentence)
import ex25 sentence = "All good things come to those who wait." words = ex25.break_words(sentence) print words sorted_words = ex25.sort_words(words) print sorted_words ex25.print_first_word(words) ex25.print_last_word(words) sorted_words = ex25.sort_sentence(sentence) print sorted_words ex25.print_first_and_last(sentence) ex25.print_first_and_last_sorted(sentence) help(ex25)
import ex25 print(ex25.sort_words(ex25.break_words("gijo varghese")))
jelly_beans = started * 500 jars = jelly_beans / 1000 crates = jars / 100 return jelly_beans, jars, crates start_point = 10000 beans, jars, crates = secret_formula(start_point) print "With a starting point of: %d" % start_point print "We'd have %d beans, %d jars, and %d crates." % (beans, jars, crates) start_point = start_point / 10 print "We can also do that this way:" print "We'd have %d beans, %d jars, and %d crates." % secret_formula(start_point) sentence = "All good things come to those who wait." import ex25 words = ex25.break_words(sentence) sorted_words = ex25.sort_words(words) print_first_word(words) print_last_word(words) print_first_word(sorted_words) print_last_word(sorted_words) print ex25.sort_sentence(sentence) print_first_and_last(sentence) print_first_and_last_sorted(sentence)