Python Forum

Full Version: just a trial. Please wait 5 minutes before deleting this thread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
my question here:just a trial

#file1.py
print("HANDLING LISTS")
L = [1.2, 5.6, 7.8]
L[1]= 8.9
for x in L:print(x, end=' ')
print()  # display a blank line
for x in L:print(x)
x = 'a'
y = 'b'
print('%s....%s' % (x, y))
print("CONSTRUCTION OF A LIST ELEMENT BY ELEMENT")
value=4.5
L=[]
L[:0]=[value]
for x in L:print(x)
value=3.5
L.append(value)
value=7.4
L.append(value)
value=9.4
L.append(value)
L.sort()
for x in L:print(x, end=' ')
print()
print("length of L=", len(L))
print(L)
print("AVERAGE OF THE VALUES OF A LIST")
L=[3.5, 4.5, 7.4, 9.4]
print(L)
print("length of L=", len(L))
sum=0
for x in L:
   sum=sum+x
   print(sum)


print("the sum of the whole is: ", sum)
average=sum/len(L)
print("The average value of the whole is: ", average)
exit()
If you are attempting to use code tags, you'll notice almost all your indentation is wrong. This is most likely due to posting formatted text. When pasting your code between the tags, it is always safe to use the key combination "Ctrl + Shift + V". Also, in your code, remember to use spaces (4 spaces per indentation level) NOT tabs.
(Jun-06-2017, 12:56 PM)sparkz_alot Wrote: [ -> ]you'll notice almost all your indentation is wrong
It's work,indentation is not wrong just a very bad coding style.
Code tag work @sylas,which i think is the point of this post.
Don't write code like this look at PEP-8.