Differences between revisions 1 and 22 (spanning 21 versions)
Revision 1 as of 2006-06-05 23:06:30
Size: 36
Editor: xdsl-2354
Comment:
Revision 22 as of 2009-02-08 02:10:06
Size: 1923
Editor: cpe-98-149-157-145
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Dupa jasiu.
----
CategoryEditors
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface. This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************
    
IDLE 2.6
>>> print 'hello world'
hello world
>>> name = raw_input('What is your name?\n') # \n is a newline
What is your name?
print 'Hi', name
>>> my_list = ['john', 'pat', 'gary', 'michael']
for i, name in enumerate(my_list):
    print "iteration %i is %s" % (i, name)

>>> def greet(name):
    print 'hello', name
greet('Jack')
greet('Jill')
greet('Bob')
import re
for test_string in ['555-1212', 'ILL-EGAL']:
    if re.match(r'^\d{3}-\d{4}$', test_string):
        print test_string, 'is a valid US local phone number'
    else:
        print test_string, 'rejected'
prices = {'apple': 0.40, 'banana': 0.50}
my_purchase = {
    'apple': 1,
    'banana': 6}
grocery_bill = sum(prices[fruit] * my_purchase[fruit]
                   for fruit in my_purchase)
print 'I owe the grocer $%.2f' % grocery_bill
#!/usr/bin/env python
# This program adds up integers in the command line
import sys
try:
    total = sum(int(arg) for arg in sys.argv[1:])
    print 'sum =', total
except ValueError:
    print 'Please supply integer arguments'
# indent your Python code to put into an email
import glob
# glob supports Unix style pathname extensions
python_files = glob.glob('*.py')
for fn in sorted(python_files):
    print ' ------', fn
    for line in open(fn):
        print ' ' + line.rstrip()
    print

Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information.

  • *************************************************************** Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet.
  • ***************************************************************

IDLE 2.6 >>> print 'hello world' hello world >>> name = raw_input('What is your name?\n') # \n is a newline What is your name? print 'Hi', name >>> my_list = ['john', 'pat', 'gary', 'michael'] for i, name in enumerate(my_list):

  • print "iteration %i is %s" % (i, name)

>>> def greet(name):

  • print 'hello', name

greet('Jack') greet('Jill') greet('Bob') import re for test_string in ['555-1212', 'ILL-EGAL']:

  • if re.match(r'^\d{3}-\d{4}$', test_string):
    • print test_string, 'is a valid US local phone number'
    else:
    • print test_string, 'rejected'

prices = {'apple': 0.40, 'banana': 0.50} my_purchase = {

  • 'apple': 1, 'banana': 6}

grocery_bill = sum(prices[fruit] * my_purchase[fruit]

  • for fruit in my_purchase)

print 'I owe the grocer $%.2f' % grocery_bill #!/usr/bin/env python # This program adds up integers in the command line import sys try:

  • total = sum(int(arg) for arg in sys.argv[1:]) print 'sum =', total

except ValueError:

  • print 'Please supply integer arguments'

# indent your Python code to put into an email import glob # glob supports Unix style pathname extensions python_files = glob.glob('*.py') for fn in sorted(python_files):

  • print '


', fn

  • for line in open(fn):
    • print ' ' + line.rstrip()
    print

Audio (last edited 2022-02-11 15:26:49 by mytja)

Unable to edit the page? See the FrontPage for instructions.