[PIPython] Sorgenti personali
Simone Cansella
scansella
Mer 19 Gen 2005 12:44:21 CET
Rimosso contenuto di tipo multipart/alternative-------------- parte successiva --------------
def print_menu():
print '1. Print Phone Numbers'
print '2. Add Phone Number'
print '3. Remove a Phone Number'
print '4. Lookup a Phone Number'
print '5. Quit'
print
numbers = {}
menu_choice = 0
print_menu()
while menu_choice != 5:
menu_choice = input("Type in a number (1-5):")
if menu_choice == 1:
print "Telephone Numbers:"
for x in numbers.keys():
print "Name: ",x," \tNumber: ",numbers[x]
print
elif menu_choice == 2:
print "Add Name and Number"
name = raw_input("Name:")
phone = raw_input("Number:")
numbers[name] = phone
elif menu_choice == 3:
print "Remove Name and Number"
name = raw_input("Name:")
if numbers.has_key(name):
del numbers[name]
else:
print name," was not found"
elif menu_choice == 4:
print "Lookup a Number"
name = raw_input ("Name:")
if numbers.has_key(name):
print "The Number is", numbers[name]
else:
print name," was not found"
elif menu_choice != 5:
print_menu()
-------------- parte successiva --------------
number = 78
guess = 0
while guess != number :
guess = input ("Guess a number: ")
if guess > number :
print "Too hig"
elif guess < number :
print "Too low"
print "Just right"
-------------- parte successiva --------------
print "Halt!"
s = raw_input("Chi va là? ")
b = input("quanti anni hai?: ")
f = input("quanto pesi?: ")
t = input("quanto sei alto?: ")
print s, "Questa e la tua carta d'identita: ", "Nome:", s, "Eta:", b, "Peso:", f, "Altezza:", t,
print "Ben entrato nella nostra comunita"
-------------- parte successiva --------------
a = 0
b = 1
count = 0
max_count = 20
while count < max_count:
count = count + 1
old_a = a
a = b
b = old_a + b
print old_a,
print
-------------- parte successiva --------------
while 1 == 1:
print 2
print 2*2
print 2*2*2
print 2*2*2*2
print 2*2*2*2*2
print 2*2*2*2*2*2
print 2*2*2*2*2*2*2
-------------- parte successiva --------------
a = range(1,1)
b = range(1,2)
c = range(1,3)
d = range(1,4)
e = range(1,5)
f = range(1,6)
g = range(1,7)
h = range(1,8)
i = range(1,9)
j = range(1,10)
for count in a:
print count
print
for count in b:
print count
print
for count in c:
print count
print
for count in d:
print count
print
for count in e:
print count
print
for count in f:
print count
print
for count in g:
print count
print
for count in h:
print count
print
for count in i:
print count
print
for count in j:
print count
print
More information about the Python
mailing list