yuvlevental
August 16th, 2007, 11:00 PM
First, the program I will refer to:
print “List of First Five Greek Letters”
greek_letters = [’Beta’, ‘Alpha’, ‘Gamma’, ‘Delta’, ‘Epsilon’]
print “Third value in list is: “, greek_letters[2]
greek_letters[2] = 3
print “Value has been changed. It is now: “, greek_letters[2]
print “Length of list is: “, len(greek_letters)
del greek_letters[2]
print “Third letter has been deleted. Length is now: “, len(greek_letters)
if “Alpha” in greek_letters:
print “Alpha is in the list at the moment.”
else:
print “Alpha is not in the list at the moment.”
print “The current list: “, greek_letters
print ‘Alpha is in position’, greek_letters.index(’Alpha’) + 1
greek_letters.sort()
“List has been sorted alphabetically.”
print “New list: “, greek_letters
print ‘Alpha is in position’, greek_letters.index(’Alpha’) + 1
greek_letters.remove(”Beta”)
print”Beta has been removed.”, greek_letters
The challenge: In the program, the list, variables, ect. is determined. The challenge is to make a program where there a list, which is initially blank, and you can add, remove, print, sort, ect. items to the list. Taken from my lesson here (http://my-python-blog.freehostia.com/?p=19). Email the answer to yuval [dot] imperius [at] gmail [dot] com. You will be credited on the forums (http://my-python-blog.freehostia.com/forum/) and get 40 credits.
print “List of First Five Greek Letters”
greek_letters = [’Beta’, ‘Alpha’, ‘Gamma’, ‘Delta’, ‘Epsilon’]
print “Third value in list is: “, greek_letters[2]
greek_letters[2] = 3
print “Value has been changed. It is now: “, greek_letters[2]
print “Length of list is: “, len(greek_letters)
del greek_letters[2]
print “Third letter has been deleted. Length is now: “, len(greek_letters)
if “Alpha” in greek_letters:
print “Alpha is in the list at the moment.”
else:
print “Alpha is not in the list at the moment.”
print “The current list: “, greek_letters
print ‘Alpha is in position’, greek_letters.index(’Alpha’) + 1
greek_letters.sort()
“List has been sorted alphabetically.”
print “New list: “, greek_letters
print ‘Alpha is in position’, greek_letters.index(’Alpha’) + 1
greek_letters.remove(”Beta”)
print”Beta has been removed.”, greek_letters
The challenge: In the program, the list, variables, ect. is determined. The challenge is to make a program where there a list, which is initially blank, and you can add, remove, print, sort, ect. items to the list. Taken from my lesson here (http://my-python-blog.freehostia.com/?p=19). Email the answer to yuval [dot] imperius [at] gmail [dot] com. You will be credited on the forums (http://my-python-blog.freehostia.com/forum/) and get 40 credits.