Contents
- new_for.py
- sales_tax.py
new_for.py 1/2
[top][prev][next]
print "-------------- xrange(1, 15, 3) ------------"
for a in xrange(1,15,3):
print a
print "-------------- xrange(5, -15, -5) ------------"
for b in xrange(5, -15, -5):
print b
print "-------------- xrange(5, -15, 5) ------------"
for counter in xrange(5, -15, 5):
print counter
print "-------------- xrange(5, 15, 1.5) ------------"
# Note that xrange expects integer values
for counter in xrange(5, 15, 1.5):
print counter
sales_tax.py 2/2
[top][prev][next]
# Compute the cost of an item, plus sales tax
# Demonstrate need for/use of format specifiers
# by Sara Sprenkle 09/21/07
#
SALES_TAX=.05 # the sales tax in VA
value = input("How much does your item cost? ")
tax = value * (1+SALES_TAX)
#print "Your item that cost ($", value, ")"
print "Your item that cost ($%.2f)" % value,
#print "costs $", tax, "with tax"
print "costs $%.2f with tax" % tax
Generated by GNU enscript 1.6.4.