Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. def denali (World):
  2.  
  3. #Creating end points of the world
  4. World.append(0)
  5. World.insert(0,0)
  6. lengthofW=len(World)
  7. #List of Indexes/Locations of Continents
  8. continents=[]
  9. #Keeps count of the actual nonzero continents
  10. continentscount=0
  11. #The list of lists of continents
  12. continentstwo=[]
  13. #An average for each continent
  14. continentsavg=[]
  15. #List of Mountain Locations
  16. mountains=[]
  17. #List of Mountain Heights
  18. mountainheight=[]
  19.  
  20.  
  21. #For loop that locates all locations at which a 0 precedes a series of numbers (continent beginnings)
  22. for x in range (0,lengthofW):
  23. if (World[x] == 0):
  24. continents.append(x)
  25.  
  26. #For and If that checks through continent indexes and makes a list of the #s between ever two indexes
  27. for x in range (0, len(continents)-1):
  28. if (x==(len(continents)-1)):
  29. break
  30. else:
  31. continentstwo.append(World[(continents[x]):(continents[x+1])])
  32.  
  33. #For and If that finds the average of all the continents now in a list called continentstwo
  34. for x in range (0, len(continentstwo)):
  35. avg=0
  36. count=0
  37. for y in range (0, len(continentstwo[x])):
  38. avg+= continentstwo[x][y]
  39. count+=1
  40. if (count>1):
  41. count=count-1
  42. avg=(avg/count)
  43. continentsavg.append(avg)
  44.  
  45.  
  46. #Gets a count on the real number of continents (ignores any averages of 0)
  47. for x in range (0,len(continentsavg)):
  48. if (continentsavg[x] > 0):
  49. continentscount+=1
  50.  
  51. #Finds the mountains by series of if checking if previous number and next number is less than current number
  52. for x in range (0,lengthofW):
  53. if (World[x-1] < World[x]):
  54. if (World[x] > World[x+1]):
  55. mountains.append(x)
  56. mountainheight.append(World[x])
  57. elif(World[x]==World[x+1]):
  58. for y in range (x, lengthofW):
  59. if (World[y]<World[x]):
  60. mountains.append(x+1)
  61. mountainheight.append(World[x])
  62. break
  63.  
  64. print (continentscount, " continents")
  65. for x in range (0, len(mountains)):
  66. print ("mountain at", ((mountains[x])-1), "has an average elevation", mountainheight[x])
  67.  
  68.  
  69. count=0
  70.  
  71. for x in range (0, len(continentsavg)):
  72. if (continentsavg[x]!=0):
  73. print ("continent", count , "has an average height of", continentsavg[x])
  74. count+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement