Esempio n. 1
0
File: ex26.py Progetto: arante/pyloc
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)
Esempio n. 2
0
    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)
Esempio n. 3
0
import ex25
frase="solo se que nada se"
palabras = ex25.break_words(frase)
print palabras
ex25.print_first_word(palabras)
Esempio n. 4
0
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)
Esempio n. 5
0
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")
Esempio n. 6
0
File: ex26.py Progetto: AksR2/python
    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)
Esempio n. 7
0
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란 함수를 가져와 사용한다는 의미
print(words)
sorted_words = ex25.sort_words(words)
print(sorted_words)

ex25.print_first_word(words)
ex25.print_last_word(words)
ex25.print_first_word(sorted_words)
ex25.print_last_word(sorted_words)
sorted_words = ex25.sort_sentence(sentence)
print(sorted_words)

ex25.print_first_and_last(sentence)

ex25.print_first_and_last_sorted(sentence)
Esempio n. 8
0
import ex25

sentence = "All good things come to those who wait."
print ex25.break_words(sentence)

Esempio n. 9
0
 
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) #Point and not pont
 
sentence = "All good things come to those who wait." #Editet here.
 
words = ex25.break_words(sentence) #Hat to write at the topp import ex25
sorted_words = ex25.sort_words(words)
 
print_first_word(words)
print_last_word(words)
print_first_word(sorted_words) #editet here.
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)
 
 
print "Test \n" + "Idiot" #added idiot here.
Esempio n. 10
0
import ex25 as e

sentence = "All good things come to those who wait."
words = e.break_words(sentence)
print words
Esempio n. 11
0
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)
Esempio n. 12
0
def print_first_and_last(sentence):
    """Prints the first and last words of the sentence."""
    words = break_words(sentence)
    print_first_word(words)
    print_last_word(words)
Esempio n. 13
0
def sort_sentence(sentence):
    """Takes in a full sentence and returns the sorted words."""
    words = break_words(sentence)
    return sort_words(words)
Esempio n. 14
0
import ex25 #imports all methods written in this file
from ex25 import break_words #imports specific method from this file
from ex25 import * #imports all functions from the method

sentence = "All good things come to those who wait"
words = break_words(sentence)  #refers to method within the file
print words

sorted_words = ex25.sort_words(words)
print sorted_words

ex25.print_first_word(words)

ex25.print_last_word(words)

print words #after words have been popped off the array they are no longer there

ex25.print_first_and_last(sentence)
ex25.print_first_and_last_sorted(sentence)