Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def denali (World):
- #Creating end points of the world
- World.append(0)
- World.insert(0,0)
- lengthofW=len(World)
- #List of Indexes/Locations of Continents
- continents=[]
- #Keeps count of the actual nonzero continents
- continentscount=0
- #The list of lists of continents
- continentstwo=[]
- #An average for each continent
- continentsavg=[]
- #List of Mountain Locations
- mountains=[]
- #List of Mountain Heights
- mountainheight=[]
- #For loop that locates all locations at which a 0 precedes a series of numbers (continent beginnings)
- for x in range (0,lengthofW):
- if (World[x] == 0):
- continents.append(x)
- #For and If that checks through continent indexes and makes a list of the #s between ever two indexes
- for x in range (0, len(continents)-1):
- if (x==(len(continents)-1)):
- break
- else:
- continentstwo.append(World[(continents[x]):(continents[x+1])])
- #For and If that finds the average of all the continents now in a list called continentstwo
- for x in range (0, len(continentstwo)):
- avg=0
- count=0
- for y in range (0, len(continentstwo[x])):
- avg+= continentstwo[x][y]
- count+=1
- if (count>1):
- count=count-1
- avg=(avg/count)
- continentsavg.append(avg)
- #Gets a count on the real number of continents (ignores any averages of 0)
- for x in range (0,len(continentsavg)):
- if (continentsavg[x] > 0):
- continentscount+=1
- #Finds the mountains by series of if checking if previous number and next number is less than current number
- for x in range (0,lengthofW):
- if (World[x-1] < World[x]):
- if (World[x] > World[x+1]):
- mountains.append(x)
- mountainheight.append(World[x])
- elif(World[x]==World[x+1]):
- for y in range (x, lengthofW):
- if (World[y]<World[x]):
- mountains.append(x+1)
- mountainheight.append(World[x])
- break
- print (continentscount, " continents")
- for x in range (0, len(mountains)):
- print ("mountain at", ((mountains[x])-1), "has an average elevation", mountainheight[x])
- count=0
- for x in range (0, len(continentsavg)):
- if (continentsavg[x]!=0):
- print ("continent", count , "has an average height of", continentsavg[x])
- count+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement