Professional Documents
Culture Documents
08-Python Programming 3
08-Python Programming 3
Lecture
Python Programming 3
1 1
2 3
3 6
4 10
>>>
for i in range(1,10):
if i==5:
break
print(i)
1
2
3
4
>>>
moredata = "yes"
sum = 0.0
count = 0
while moredata == 'yes':
x = eval(input("Enter a number >> "))
sum = sum + x
count = count + 1
moredata = input("Do you have more numbers (yes or
no)? ")
print("\nThe average of the numbers is", sum / count)
sum = 0.0
count = 0
x = eval(input("Enter a number (negative to quit) >> "))
while x >= 0:
sum = sum + x
count = count + 1
x = eval(input("Enter a number (negative to quit) >> "))
print("\nThe average of the numbers is", sum / count)