1.1. ActiveCode Examples in Python¶
One of the most important things that you can do when you are learning a programming language is to write programs. Unfortunately, typical textbooks allow you to read about programming, but don’t allow you to practice. We have created a unique tool called activecode that allows you to write, modify, and execute programs right in the text itself (right from the web browser). Although this is certainly not the way real programs are written, it provides an excellent environment for learning a programming language like Python since you can experiment with the language as you are reading.
Take a look at the activecode interpreter in action. If we take a simple Python program and make it active, you will see that it can be executed directly by pressing the run button. Try pressing the run button below.
Now try modifying the activecode program shown above. First, modify the string in the first print statement by changing the word adds to the word multiplies. Now press run. You can see that the result of the program has changed. However, it still prints “30” as the answer. Modify the total calculation by changing the addition symbol, the “+”, to the multiplication symbol, “*”. Press run to see the new results (note that you should also fix the total initialization for a correct claculation). You can do this as many times as you like. You can even start completely over by simply deleting all the code from the window.
If you are a registered user and have logged in, any changes you make are automatically saved, and the history slider allows you to go back to any previous version of your program. Note that these saved programs can be accessed from anywhere if you have logged in. However, if you are working anonymously, then you will lose your work at the end of the session.
Click on the “Show Source” button below to see what the reStructuredText (rst) looks like for the activecode above. You can author ebook content in rst.
.. activecode:: codeexample1
:coach:
:prim_comp: ASSIGNMENT
print("My first program adds a list of numbers")
myList = [2, 4, 6, 8, 10]
total = 0
for num in myList:
total = total + num
print(total)
<listing xml:id="program-activecode-python">
<caption>An interactive Python program, using <pubtitle>Runestone</pubtitle></caption>
<program xml:id="python-hello-world" interactive='activecode' language="python">
<input>
print("My first program adds a list of numbers")
myList = [2, 4, 6, 8, 10]
total = 0
for num in myList:
total = total + num
print(total)
</input>
</program>
</listing>
Activecode is even capable of executing graphical programs that use the built in Python turtle module. The program shown below is a very interesting graphics program that uses the turtle and the idea of recursion to construct a type of fractal called a Sierpinski Triangle. Once you run the program, try experimenting with the number of triangle levels. You can find this on line 39 (it is currently set to 3). Try 4! Try some other changes and see what happens (maybe change a few of the colors or make the level 2). If you ever want to go back to the original example, simply reload the page in the browser. One of the great things about activecode is that you can experiment as much as you want. This can be very helpful as you are learning to program.
.. activecode:: codeexample2 :nocodelens: :hidecode: :autorun: import turtle def drawTriangle(points,color,myTurtle): myTurtle.fillcolor(color) myTurtle.up() myTurtle.goto(points[0][0],points[0][1]) myTurtle.down() myTurtle.begin_fill() myTurtle.goto(points[1][0],points[1][1]) myTurtle.goto(points[2][0],points[2][1]) myTurtle.goto(points[0][0],points[0][1]) myTurtle.end_fill() def getMid(p1,p2): return ( (p1[0]+p2[0]) / 2, (p1[1] + p2[1]) / 2) def sierpinski(points,degree,myTurtle): colormap = ['blue','red','green','white','yellow', 'violet','orange'] drawTriangle(points,colormap[degree],myTurtle) if degree > 0: sierpinski([points[0], getMid(points[0], points[1]), getMid(points[0], points[2])], degree-1, myTurtle) sierpinski([points[1], getMid(points[0], points[1]), getMid(points[1], points[2])], degree-1, myTurtle) sierpinski([points[2], getMid(points[2], points[1]), getMid(points[0], points[2])], degree-1, myTurtle) def main(): myTurtle = turtle.Turtle() myWin = turtle.Screen() myPoints = [[-100,-50],[0,100],[100,-50]] sierpinski(myPoints,3,myTurtle) myWin.exitonclick() main()
1.2. Event Driven Programming¶
This little program illustrates how to use events in python and turtle graphics. You can “drive” the turtle around the canvas using the arrow keys and by clicking the mouse. The turtle will leave a trail as it moves.
1.3. Image Processing¶
We have a special image library that we wrote for skulpt that lets you access images pixel by pixel. This is a great way to practice nested iteration and to learn about the many different filters provided by services like Instagram, and others.
Click on the reveal to see the rst for the datafile directive.
.. datafile:: golden_gate.png
:image:
:fromfile: golden_gate.png
You can use images in many ways. If you have an image in your page and it has an id tag you can use that. If you have a full URL to an image you can use that. But the best thing to do if you are writing a book is to use the .. datafile::
directive, this ensures that the image is available from anywhere in the book.
Click on the reveal to show the source for the activecode above.
.. activecode:: act_ip_1
:nocodelens:
import image
img = image.Image("golden_gate.png")
win = image.ImageWin(img.getWidth(), img.getHeight())
img.draw(win)
img.setDelay(1,15) # setDelay(1, 2000) will speed up a lot # img.setDelay(delay, number of pixels between delay)
for row in range(img.getHeight()):
for col in range(img.getWidth()):
p = img.getPixel(col, row)
newred = p.red * 1.4
newgreen = p.green * .75
newblue = p.blue * 1.1
newpixel = image.Pixel(newred, newgreen, newblue)
img.setPixel(col, row, newpixel)
img.draw(win)
win.exitonclick()
1.4. Graphs and Charts¶
Using a simple Altair-like wrapper around the vega library, we can draw some nice charts and graphs. We only implement a subset of altair but you can do most of the basic plots. bar, scatter, line, point, heatmaps are all possible. If you see something from the Altair Gallery that does not work let us know, or have a look at the code On github and make PR 😀!
A key difference between our baby Altair and the real Altair is that we do not use DataFrames. We use a simple Data object. You can create a data object with a bunch of named parameters and lists of values as shown below. Or from a dictionary or even from a JSON object.
.. activecode:: alt_kiva_bar1
:nocodelens:
import altair
data = altair.Data(customer=['Alice', 'Bob', 'Claire'], cakes=[5,9,7], flavor=['chocolate', 'vanilla', 'strawberry'])
print(data)
chart = altair.Chart(data)
mark = chart.mark_bar()
enc = mark.encode(x='customer:N',y='cakes',color='flavor:N')
enc.display()
1.5. Unit Tests for Python Code¶
Its nice to be able to have students solve a particular problem by writing some code, its even better if you can give them some feedback and provide some tests for them. Much of the unittest
module from Python is available in the unittest
module for activecode. Take a look:
Click the Show Source button to see the source code for the above example.
.. activecode:: units1
:nocodelens:
def add(a,b):
return 4
from unittest.gui import TestCaseGui
class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(add(2,2),4,"A feedback string when the test fails")
self.assertAlmostEqual(add(2.0,3.0), 5.0, 1, "Try adding your parmeters")
myTests().main()
Before you go on, fix the add function in the activecode box. The full complement of assertXXX functions is available. You can see the list Here. Now, for an introductory course exposing the inner workings of the unittest class may lead to more confusion that anything.
1.7. DOM Access¶
Python programs written in activecode windows can now import the document
module. This document module
allows access to basic elements of the web page, including the new text entry box called
text1 like this one. Try running the program, then change
the value in the text entry box and run it again.
.. activecode:: tftest1
:nocodelens:
import document
t = document.getElementById('text1')
print('value = ', t.value)
1.8. Server Side Python¶
If the JOBE server has pandas installed we can even use pandas right in the text and have it process data from a file. Just use the option :language: python3.
Here is the file it will read from.
Country,Ctry,Code,CodeNum,Region,Population,Area,Pop. Density,Coastline,Net migration,Infant mortality,GDP,Literacy,Phones,Arable,Crops,Other,Climate,Birthrate,Deathrate,Agriculture,Industry,Service Afghanistan,Afghanistan,AFG,4,ASIA (EX. NEAR EAST) ,31056997,647500,48.0,0.00,23.06,163.07,700,36.0,3.2,12.13,0.22,87.65,1,46.6,20.34,0.38,0.24,0.38 Albania ,Albania,ALB,8,EASTERN EUROPE ,3581655,28748,124.6,1.26,-4.93,21.52,4500,86.5,71.2,21.09,4.42,74.49,3,15.11,5.22,0.232,0.188,0.579 Algeria ,Algeria,DZA,12,NORTHERN AFRICA ,32930091,2381740,13.8,0.04,-0.39,31,6000,70.0,78.1,3.22,0.25,96.53,1,17.14,4.61,0.101,0.6,0.298 American Samoa ,American Samoa,ASM,16,OCEANIA ,57794,199,290.4,58.29,-20.71,9.27,8000,97.0,259.5,10,15,75,2,22.46,3.27,,, Andorra ,Andorra,AND,20,WESTERN EUROPE ,71201,468,152.1,0.00,6.6,4.05,19000,100.0,497.2,2.22,0,97.78,3,8.71,6.25,,, Angola ,Angola,AGO,24,SUB-SAHARAN AFRICA ,12127071,1246700,9.7,0.13,0,191.19,1900,42.0,7.8,2.41,0.24,97.35,,45.11,24.2,0.096,0.658,0.246 Anguilla ,Anguilla,AIA,660,LATIN AMER. & CARIB ,13477,102,132.1,59.80,10.76,21.03,8600,95.0,460.0,0,0,100,2,14.17,5.34,0.04,0.18,0.78 Antigua & Barbuda ,Antigua & Barbuda,ATG,28,LATIN AMER. & CARIB ,69108,443,156.0,34.54,-6.15,19.46,11000,89.0,549.9,18.18,4.55,77.27,2,16.93,5.37,0.038,0.22,0.743 Argentina ,Argentina,ARG,32,LATIN AMER. & CARIB ,39921833,2766890,14.4,0.18,0.61,15.18,11200,97.1,220.4,12.31,0.48,87.21,3,16.73,7.55,0.095,0.358,0.547 Armenia ,Armenia,ARM,51,C.W. OF IND. STATES ,2976372,29800,99.9,0.00,-6.47,23.28,3500,98.6,195.7,17.55,2.3,80.15,4,12.07,8.23,0.239,0.343,0.418 Aruba ,Aruba,ABW,533,LATIN AMER. & CARIB ,71891,193,372.5,35.49,0,5.89,28000,97.0,516.1,10.53,0,89.47,2,11.03,6.68,0.004,0.333,0.663 Australia ,Australia,AUS,36,OCEANIA ,20264082,7686850,2.6,0.34,3.98,4.69,29000,100.0,565.5,6.55,0.04,93.41,1,12.14,7.51,0.038,0.262,0.7 Austria ,Austria,AUT,40,WESTERN EUROPE ,8192880,83870,97.7,0.00,2,4.66,30000,98.0,452.2,16.91,0.86,82.23,3,8.74,9.76,0.018,0.304,0.678 Azerbaijan ,Azerbaijan,AZE,31,C.W. OF IND. STATES ,7961619,86600,91.9,0.00,-4.9,81.74,3400,97.0,137.1,19.63,2.71,77.66,1,20.74,9.75,0.141,0.457,0.402 Bahamas ,Bahamas,BHS,44,LATIN AMER. & CARIB ,303770,13940,21.8,25.41,-2.2,25.21,16700,95.6,460.6,0.8,0.4,98.8,2,17.57,9.05,0.03,0.07,0.9 Bahrain ,Bahrain,BHR,48,NEAR EAST ,698585,665,1050.5,24.21,1.05,17.27,16900,89.1,281.3,2.82,5.63,91.55,1,17.8,4.14,0.005,0.387,0.608 Bangladesh ,Bangladesh,BGD,50,ASIA (EX. NEAR EAST) ,147365352,144000,1023.4,0.40,-0.71,62.6,1900,43.1,7.3,62.11,3.07,34.82,2,29.8,8.27,0.199,0.198,0.603 Barbados ,Barbados,BRB,52,LATIN AMER. & CARIB ,279912,431,649.5,22.51,-0.31,12.5,15700,97.4,481.9,37.21,2.33,60.46,2,12.71,8.67,0.06,0.16,0.78 Belarus ,Belarus,BLR,112,C.W. OF IND. STATES ,10293011,207600,49.6,0.00,2.54,13.37,6100,99.6,319.1,29.55,0.6,69.85,4,11.16,14.02,0.093,0.316,0.591 Belgium ,Belgium,BEL,56,WESTERN EUROPE ,10379067,30528,340.0,0.22,1.23,4.68,29100,98.0,462.6,23.28,0.4,76.32,3,10.38,10.27,0.01,0.24,0.749 Belize ,Belize,BLZ,84,LATIN AMER. & CARIB ,287730,22966,12.5,1.68,0,25.69,4900,94.1,115.7,2.85,1.71,95.44,2,28.84,5.72,0.142,0.152,0.612 Benin ,Benin,BEN,204,SUB-SAHARAN AFRICA ,7862944,112620,69.8,0.11,0,85,1100,40.9,9.7,18.08,2.4,79.52,2,38.85,12.22,0.316,0.138,0.546 Bermuda ,Bermuda,BMU,60,NORTHERN AMERICA ,65773,53,1241.0,194.34,2.49,8.53,36000,98.0,851.4,20,0,80,2,11.4,7.74,0.01,0.1,0.89 Bhutan ,Bhutan,BTN,64,ASIA (EX. NEAR EAST) ,2279723,47000,48.5,0.00,0,100.44,1300,42.2,14.3,3.09,0.43,96.48,2,33.65,12.7,0.258,0.379,0.363 Bolivia ,Bolivia,BOL,68,LATIN AMER. & CARIB ,8989046,1098580,8.2,0.00,-1.32,53.11,2400,87.2,71.9,2.67,0.19,97.14,1.5,23.3,7.53,0.128,0.352,0.52 Bosnia & Herzegovina ,Bosnia & Herzegovina,BIH,70,EASTERN EUROPE ,4498976,51129,88.0,0.04,0.31,21.05,6100,,215.4,13.6,2.96,83.44,4,8.77,8.27,0.142,0.308,0.55 Botswana ,Botswana,BWA,72,SUB-SAHARAN AFRICA ,1639833,600370,2.7,0.00,0,54.58,9000,79.8,80.5,0.65,0.01,99.34,1,23.08,29.5,0.024,0.469,0.507 Brazil ,Brazil,BRA,76,LATIN AMER. & CARIB ,188078227,8511965,22.1,0.09,-0.03,29.61,7600,86.4,225.3,6.96,0.9,92.15,2,16.56,6.17,0.084,0.4,0.516 British Virgin Is. ,British Virgin Is.,VGB,92,LATIN AMER. & CARIB ,23098,153,151.0,52.29,10.01,18.05,16000,97.8,506.5,20,6.67,73.33,2,14.89,4.42,0.018,0.062,0.92 Brunei Darussalam ,Brunei Darussalam,BRN,96,ASIA (EX. NEAR EAST) ,379444,5770,65.8,2.79,3.59,12.61,18600,93.9,237.2,0.57,0.76,98.67,2,18.79,3.45,0.036,0.561,0.403 Bulgaria ,Bulgaria,BGR,100,EASTERN EUROPE ,7385367,110910,66.6,0.32,-4.58,20.55,7600,98.6,336.3,40.02,1.92,58.06,3,9.65,14.27,0.093,0.304,0.603 Burkina Faso ,Burkina Faso,BFA,854,SUB-SAHARAN AFRICA ,13902972,274200,50.7,0.00,0,97.57,1100,26.6,7.0,14.43,0.19,85.38,2,45.62,15.6,0.322,0.196,0.482 Myanmar ,Myanmar,MMR,104,ASIA (EX. NEAR EAST) ,47382633,678500,69.8,0.28,-1.8,67.24,1800,85.3,10.1,15.19,0.97,83.84,2,17.91,9.83,0.564,0.082,0.353 Burundi ,Burundi,BDI,108,SUB-SAHARAN AFRICA ,8090068,27830,290.7,0.00,-0.06,69.29,600,51.6,3.4,35.05,14.02,50.93,2,42.22,13.46,0.463,0.203,0.334 Cambodia ,Cambodia,KHM,116,ASIA (EX. NEAR EAST) ,13881427,181040,76.7,0.24,0,71.48,1900,69.4,2.6,20.96,0.61,78.43,2,26.9,9.06,0.35,0.3,0.35 Cameroon ,Cameroon,CMR,120,SUB-SAHARAN AFRICA ,17340702,475440,36.5,0.08,0,68.26,1800,79.0,5.7,12.81,2.58,84.61,1.5,33.89,13.47,0.448,0.17,0.382 Canada ,Canada,CAN,124,NORTHERN AMERICA ,33098932,9984670,3.3,2.02,5.96,4.75,29800,97.0,552.2,4.96,0.02,95.02,,10.78,7.8,0.022,0.294,0.684 Cape Verde ,Cape Verde,CPV,132,SUB-SAHARAN AFRICA ,420979,4033,104.4,23.93,-12.07,47.77,1400,76.6,169.6,9.68,0.5,89.82,3,24.87,6.55,0.121,0.219,0.66 Cayman Islands ,Cayman Islands,CYM,136,LATIN AMER. & CARIB ,45436,262,173.4,61.07,18.75,8.19,35000,98.0,836.3,3.85,0,96.15,2,12.74,4.89,0.014,0.032,0.954 Central African Republic ,Central African Republic,CAF,140,SUB-SAHARAN AFRICA ,4303356,622984,6.9,0.00,0,91,1100,51.0,2.3,3.1,0.14,96.76,2,33.91,18.65,0.55,0.2,0.25 Chad ,Chad,TCD,148,SUB-SAHARAN AFRICA ,9944201,1284000,7.7,0.00,-0.11,93.82,1200,47.5,1.3,2.86,0.02,97.12,2,45.73,16.38,0.335,0.259,0.406 Chile ,Chile,CHL,152,LATIN AMER. & CARIB ,16134219,756950,21.3,0.85,0,8.8,9900,96.2,213.0,2.65,0.42,96.93,3,15.23,5.81,0.06,0.493,0.447 China ,China,CHN,156,ASIA (EX. NEAR EAST) ,1313973713,9596960,136.9,0.15,-0.4,24.18,5000,90.9,266.7,15.4,1.25,83.35,1.5,13.25,6.97,0.125,0.473,0.403 Colombia ,Colombia,COL,170,LATIN AMER. & CARIB ,43593035,1138910,38.3,0.28,-0.31,20.97,6300,92.5,176.2,2.42,1.67,95.91,2,20.48,5.58,0.125,0.342,0.533 Comoros ,Comoros,COM,174,SUB-SAHARAN AFRICA ,690948,2170,318.4,15.67,0,74.93,700,56.5,24.5,35.87,23.32,40.81,2,36.93,8.2,0.4,0.04,0.56 "Congo, Dem. Rep. ","Congo, Dem. Rep.",COD,180,SUB-SAHARAN AFRICA ,62660551,2345410,26.7,0.00,0,94.69,700,65.5,0.2,2.96,0.52,96.52,2,43.69,13.27,0.55,0.11,0.34 Congo,Congo,COG,178,SUB-SAHARAN AFRICA ,3702314,342000,10.8,0.05,-0.17,93.86,700,83.8,3.7,0.51,0.13,99.36,2,42.57,12.93,0.062,0.57,0.369 Cook Islands ,Cook Islands,COK,184,OCEANIA ,21388,240,89.1,50.00,,,5000,95.0,289.9,17.39,13.04,69.57,2,21,,0.151,0.096,0.753 Costa Rica ,Costa Rica,CRI,188,LATIN AMER. & CARIB ,4075261,51100,79.8,2.52,0.51,9.95,9100,96.0,340.7,4.41,5.88,89.71,2,18.32,4.36,0.088,0.299,0.614 Côte d'Ivoire ,Côte d'Ivoire,CIV,384,SUB-SAHARAN AFRICA ,17654843,322460,54.8,0.16,-0.07,90.83,1400,50.9,14.6,9.75,13.84,76.41,2,35.11,14.84,0.279,0.171,0.55 Croatia ,Croatia,HRV,191,EASTERN EUROPE ,4494749,56542,79.5,10.32,1.58,6.84,10600,98.5,420.4,26.09,2.27,71.65,,9.61,11.48,0.07,0.308,0.622 Cuba ,Cuba,CUB,192,LATIN AMER. & CARIB ,11382820,110860,102.7,3.37,-1.58,6.33,2900,97.0,74.7,33.05,7.6,59.35,2,11.89,7.22,0.055,0.261,0.684 Cyprus ,Cyprus,CYP,196,NEAR EAST ,784301,9250,84.8,7.01,0.43,7.18,19200,97.6,,7.79,4.44,87.77,3,12.56,7.68,0.037,0.198,0.765 Czech Republic ,Czech Republic,CZE,203,EASTERN EUROPE ,10235455,78866,129.8,0.00,0.97,3.93,15700,99.9,314.3,39.8,3.05,57.15,3,9.02,10.59,0.034,0.393,0.573 Denmark ,Denmark,DNK,208,WESTERN EUROPE ,5450661,43094,126.5,16.97,2.48,4.56,31100,100.0,614.6,54.02,0.19,45.79,3,11.13,10.36,0.018,0.246,0.735 Djibouti ,Djibouti,DJI,262,SUB-SAHARAN AFRICA ,486530,23000,21.2,1.37,0,104.13,1300,67.9,22.8,0.04,0,99.96,1,39.53,19.31,0.179,0.225,0.596 Dominica ,Dominica,DMA,212,LATIN AMER. & CARIB ,68910,754,91.4,19.63,-13.87,14.15,5400,94.0,304.8,6.67,20,73.33,2,15.27,6.73,0.177,0.328,0.495 Dominican Republic ,Dominican Republic,DOM,214,LATIN AMER. & CARIB ,9183984,48730,188.5,2.64,-3.22,32.38,6000,84.7,97.4,22.65,10.33,67.02,2,23.22,5.73,0.112,0.306,0.582 Timor-Leste,Timor-Leste,TLS,626,ASIA (EX. NEAR EAST) ,1062777,15007,70.8,4.70,0,47.41,500,58.6,,4.71,0.67,94.62,2,26.99,6.24,0.085,0.231,0.684 Ecuador ,Ecuador,ECU,218,LATIN AMER. & CARIB ,13547510,283560,47.8,0.79,-8.58,23.66,3300,92.5,125.6,5.85,4.93,89.22,2,22.29,4.23,0.07,0.312,0.618 Egypt ,Egypt,EGY,818,NORTHERN AFRICA ,78887007,1001450,78.8,0.24,-0.22,32.59,4000,57.7,131.8,2.87,0.48,96.65,1,22.94,5.23,0.149,0.357,0.493 El Salvador ,El Salvador,SLV,222,LATIN AMER. & CARIB ,6822378,21040,324.3,1.46,-3.74,25.1,4800,80.2,142.4,31.85,12.07,56.08,2,26.61,5.78,0.099,0.302,0.599 Equatorial Guinea ,Equatorial Guinea,GNQ,226,SUB-SAHARAN AFRICA ,540109,28051,19.3,1.06,0,85.13,2700,85.7,18.5,4.63,3.57,91.8,2,35.59,15.06,0.03,0.906,0.062 Eritrea ,Eritrea,ERI,232,SUB-SAHARAN AFRICA ,4786994,121320,39.5,1.84,0,74.87,700,58.6,7.9,4.95,0.03,95.02,1.5,34.33,9.6,0.102,0.254,0.643 Estonia ,Estonia,EST,233,BALTICS ,1324333,45226,29.3,8.39,-3.16,7.87,12300,99.8,333.8,16.04,0.45,83.51,3,10.04,13.25,0.04,0.294,0.666 Ethiopia ,Ethiopia,ETH,231,SUB-SAHARAN AFRICA ,74777981,1127127,66.3,0.00,0,95.32,700,42.7,8.2,10.71,0.75,88.54,2,37.98,14.86,0.475,0.099,0.426 Faroe Islands ,Faroe Islands,FRO,234,WESTERN EUROPE ,47246,1399,33.8,79.84,1.41,6.24,22000,,503.8,2.14,0,97.86,,14.05,8.7,0.27,0.11,0.62 Fiji ,Fiji,FJI,242,OCEANIA ,905949,18270,49.6,6.18,-3.14,12.62,5800,93.7,112.6,10.95,4.65,84.4,2,22.55,5.65,0.089,0.135,0.776 Finland ,Finland,FIN,246,WESTERN EUROPE ,5231372,338145,15.5,0.37,0.95,3.57,27400,100.0,405.3,7.19,0.03,92.78,3,10.45,9.86,0.028,0.295,0.676 France ,France,FRA,250,WESTERN EUROPE ,60876136,547030,111.3,0.63,0.66,4.26,27600,99.0,586.4,33.53,2.07,64.4,4,11.99,9.14,0.022,0.214,0.764 French Guiana ,French Guiana,GUF,254,LATIN AMER. & CARIB ,199509,91000,2.2,0.42,6.27,12.07,8300,83.0,255.6,0.14,0.05,99.81,2,20.46,4.88,0.066,0.156,0.778 French Polynesia ,French Polynesia,PYF,258,OCEANIA ,274578,4167,65.9,60.60,2.94,8.44,17500,98.0,194.5,0.82,5.46,93.72,2,16.68,4.69,0.031,0.19,0.769 Gabon ,Gabon,GAB,266,SUB-SAHARAN AFRICA ,1424906,267667,5.3,0.33,0,53.64,5500,63.2,27.4,1.26,0.66,98.08,2,36.16,12.25,0.061,0.592,0.348 Gambia ,Gambia,GMB,270,SUB-SAHARAN AFRICA ,1641564,11300,145.3,0.71,1.57,72.02,1700,40.1,26.8,25,0.5,74.5,2,39.37,12.25,0.308,0.142,0.549 Georgia ,Georgia,GEO,268,C.W. OF IND. STATES ,4661473,69700,66.9,0.44,-4.7,18.59,2500,99.0,146.6,11.44,3.86,84.7,3,10.41,9.23,0.172,0.275,0.553 Germany ,Germany,DEU,276,WESTERN EUROPE ,82422299,357021,230.9,0.67,2.18,4.16,27600,99.0,667.9,33.85,0.59,65.56,3,8.25,10.62,0.009,0.296,0.695 Ghana ,Ghana,GHA,288,SUB-SAHARAN AFRICA ,22409572,239460,93.6,0.23,-0.64,51.43,2200,74.8,14.4,16.26,9.67,74.07,2,30.52,9.72,0.366,0.246,0.387 Gibraltar ,Gibraltar,GIB,292,WESTERN EUROPE ,27928,7,3989.7,171.43,0,5.13,17500,,877.7,0,0,100,,10.74,9.31,,, Greece ,Greece,GRC,300,WESTERN EUROPE ,10688058,131940,81.0,10.37,2.35,5.53,20000,97.5,589.7,21.1,8.78,70.12,3,9.68,10.24,0.054,0.213,0.733 Greenland ,Greenland,GRL,304,NORTHERN AMERICA ,56361,2166086,0.0,2.04,-8.37,15.82,20000,,448.9,0,0,100,1,15.93,7.84,,, Grenada ,Grenada,GRD,308,LATIN AMER. & CARIB ,89703,344,260.8,35.17,-13.92,14.62,5000,98.0,364.5,5.88,29.41,64.71,2,22.08,6.88,0.054,0.18,0.766 Guadeloupe ,Guadeloupe,GLP,312,LATIN AMER. & CARIB ,452776,1780,254.4,17.19,-0.15,8.6,8000,90.0,463.8,11.24,3.55,85.21,2,15.05,6.09,0.15,0.17,0.68 Guam ,Guam,GUM,316,OCEANIA ,171019,541,316.1,23.20,0,6.94,21000,99.0,492.0,9.09,16.36,74.55,2,18.79,4.48,,, Guatemala ,Guatemala,GTM,320,LATIN AMER. & CARIB ,12293545,108890,112.9,0.37,-1.67,35.93,4100,70.6,92.1,12.54,5.03,82.43,2,29.88,5.2,0.227,0.188,0.585 Guernsey ,Guernsey,GGY,831,WESTERN EUROPE ,65409,78,838.6,64.10,3.84,4.71,20000,,842.4,,,,3,8.81,10.01,0.03,0.1,0.87 Guinea ,Guinea,GIN,324,SUB-SAHARAN AFRICA ,9690222,245857,39.4,0.13,-3.06,90.37,2100,35.9,2.7,3.63,2.58,93.79,2,41.76,15.48,0.237,0.362,0.401 Guinea-Bissau ,Guinea-Bissau,GNB,624,SUB-SAHARAN AFRICA ,1442029,36120,39.9,0.97,-1.57,107.17,800,42.4,7.4,10.67,8.82,80.51,2,37.22,16.53,0.62,0.12,0.26 Guyana ,Guyana,GUY,328,LATIN AMER. & CARIB ,767245,214970,3.6,0.21,-2.07,33.26,4000,98.8,143.5,2.44,0.15,97.41,2,18.28,8.28,0.37,0.203,0.427 Haiti ,Haiti,HTI,332,LATIN AMER. & CARIB ,8308504,27750,299.4,6.38,-3.4,73.45,1600,52.9,16.9,28.3,11.61,60.09,2,36.44,12.17,0.28,0.2,0.52 Honduras ,Honduras,HND,340,LATIN AMER. & CARIB ,7326496,112090,65.4,0.73,-1.99,29.32,2600,76.2,67.5,9.55,3.22,87.23,2,28.24,5.28,0.139,0.312,0.549 Hong Kong ,Hong Kong,HKG,344,ASIA (EX. NEAR EAST) ,6940432,1092,6355.7,67.12,5.24,2.97,28800,93.5,546.7,5.05,1.01,93.94,2,7.29,6.29,0.001,0.092,0.906 Hungary ,Hungary,HUN,348,EASTERN EUROPE ,9981334,93030,107.3,0.00,0.86,8.57,13900,99.4,336.2,50.09,2.06,47.85,3,9.72,13.11,0.037,0.312,0.651 Iceland ,Iceland,ISL,352,WESTERN EUROPE ,299388,103000,2.9,4.83,2.38,3.31,30900,99.9,647.7,0.07,0,99.93,3,13.64,6.72,0.086,0.15,0.765 India ,India,IND,356,ASIA (EX. NEAR EAST) ,1095351995,3287590,333.2,0.21,-0.07,56.29,2900,59.5,45.4,54.4,2.74,42.86,2.5,22.01,8.18,0.186,0.276,0.538 Indonesia ,Indonesia,IDN,360,ASIA (EX. NEAR EAST) ,245452739,1919440,127.9,2.85,0,35.6,3200,87.9,52.0,11.32,7.23,81.45,2,20.34,6.25,0.134,0.458,0.408 Iran ,Iran,IRN,364,ASIA (EX. NEAR EAST) ,68688433,1648000,41.7,0.15,-0.84,41.58,7000,79.4,276.4,8.72,1.39,89.89,1,17,5.55,0.116,0.424,0.46 Iraq ,Iraq,IRQ,368,NEAR EAST ,26783383,437072,61.3,0.01,0,50.25,1500,40.4,38.6,13.15,0.78,86.07,1,31.98,5.37,0.073,0.666,0.261 Ireland ,Ireland,IRL,372,WESTERN EUROPE ,4062235,70280,57.8,2.06,4.99,5.39,29600,98.0,500.5,15.2,0.03,84.77,3,14.45,7.82,0.05,0.46,0.49 Isle of Man ,Isle of Man,IMN,833,WESTERN EUROPE ,75441,572,131.9,27.97,5.36,5.93,21000,,676.0,9,0,91,3,11.05,11.19,0.01,0.13,0.86 Israel ,Israel,ISR,376,NEAR EAST ,6352117,20770,305.8,1.31,0.68,7.03,19800,95.4,462.3,16.39,4.17,79.44,3,17.97,6.18,0.026,0.317,0.657 Italy ,Italy,ITA,380,WESTERN EUROPE ,58133509,301230,193.0,2.52,2.07,5.94,26700,98.6,430.9,27.79,9.53,62.68,,8.72,10.4,0.021,0.291,0.688 Jamaica ,Jamaica,JAM,388,LATIN AMER. & CARIB ,2758124,10991,250.9,9.30,-4.92,12.36,3900,87.9,124.0,16.07,10.16,73.77,2,20.82,6.52,0.049,0.337,0.615 Japan ,Japan,JPN,392,ASIA (EX. NEAR EAST) ,127463611,377835,337.4,7.87,0,3.26,28200,99.0,461.2,12.19,0.96,86.85,3,9.37,9.16,0.017,0.258,0.725 Jersey ,Jersey,JEY,832,WESTERN EUROPE ,91084,116,785.2,60.34,2.76,5.24,24800,,811.3,0,0,100,3,9.3,9.28,0.05,0.02,0.93 Jordan ,Jordan,JOR,400,NEAR EAST ,5906760,92300,64.0,0.03,6.59,17.35,4300,91.3,104.5,2.67,1.83,95.5,1,21.25,2.65,0.033,0.287,0.68 Kazakhstan ,Kazakhstan,KAZ,398,C.W. OF IND. STATES ,15233244,2717300,5.6,0.00,-3.35,29.21,6300,98.4,164.1,7.98,0.05,91.97,4,16,9.42,0.067,0.386,0.547 Kenya ,Kenya,KEN,404,SUB-SAHARAN AFRICA ,34707817,582650,59.6,0.09,-0.1,61.47,1000,85.1,8.1,8.08,0.98,90.94,1.5,39.72,14.02,0.163,0.188,0.651 Kiribati ,Kiribati,KIR,296,OCEANIA ,105432,811,130.0,140.94,0,48.52,800,,42.7,2.74,50.68,46.58,2,30.65,8.26,0.089,0.242,0.668 "Korea, North ","Korea, North",PRK,408,ASIA (EX. NEAR EAST) ,23113019,120540,191.8,2.07,0,24.04,1300,99.0,42.4,20.76,2.49,76.75,3,15.54,7.13,0.3,0.34,0.36 "Korea, South ","Korea, South",KOR,410,ASIA (EX. NEAR EAST) ,48846823,98480,496.0,2.45,0,7.05,17800,97.9,486.1,17.18,1.95,80.87,3,10,5.85,0.033,0.403,0.563 Kuwait ,Kuwait,KWT,414,NEAR EAST ,2418393,17820,135.7,2.80,14.18,9.95,19000,83.5,211.0,0.73,0.11,99.16,1,21.94,2.41,0.004,0.479,0.516 Kyrgyzstan ,Kyrgyzstan,KGZ,417,C.W. OF IND. STATES ,5213898,198500,26.3,0.00,-2.45,35.64,1600,97.0,84.0,7.3,0.35,92.35,2.5,22.8,7.08,0.353,0.208,0.439 Laos ,Laos,LAO,418,ASIA (EX. NEAR EAST) ,6368481,236800,26.9,0.00,0,85.22,1700,66.4,14.1,3.8,0.35,95.85,2,35.49,11.55,0.455,0.287,0.258 Latvia ,Latvia,LVA,428,BALTICS ,2274735,64589,35.2,0.82,-2.23,9.55,10200,99.8,321.4,29.67,0.47,69.86,3,9.24,13.66,0.04,0.261,0.699 Lebanon ,Lebanon,LBN,422,NEAR EAST ,3874050,10400,372.5,2.16,0,24.52,4800,87.4,255.6,16.62,13.98,69.4,,18.52,6.21,0.12,0.21,0.67 Lesotho ,Lesotho,LSO,426,SUB-SAHARAN AFRICA ,2022331,30355,66.6,0.00,-0.74,84.23,3000,84.8,23.7,10.87,0.13,89,3,24.75,28.71,0.163,0.443,0.394 Liberia ,Liberia,LBR,430,SUB-SAHARAN AFRICA ,3042004,111370,27.3,0.52,0,128.87,1000,57.5,2.3,3.95,2.28,93.77,2,44.77,23.1,0.769,0.054,0.177 Libya ,Libya,LBY,434,NORTHERN AFRICA ,5900754,1759540,3.4,0.10,0,24.6,6400,82.6,127.1,1.03,0.19,98.78,,26.49,3.48,0.076,0.499,0.425 Liechtenstein ,Liechtenstein,LIE,438,WESTERN EUROPE ,33987,160,212.4,0.00,4.85,4.7,25000,100.0,585.5,25,0,75,4,10.21,7.18,0.06,0.39,0.55 Lithuania ,Lithuania,LTU,440,BALTICS ,3585906,65200,55.0,0.14,-0.71,6.89,11400,99.6,223.4,45.22,0.91,53.87,,8.75,10.98,0.055,0.325,0.62 Luxembourg ,Luxembourg,LUX,442,WESTERN EUROPE ,474413,2586,183.5,0.00,8.97,4.81,55100,100.0,515.4,23.28,0.4,76.32,,11.94,8.41,0.01,0.13,0.86 Macao ,Macao,MAC,446,ASIA (EX. NEAR EAST) ,453125,28,16183.0,146.43,4.86,4.39,19400,94.5,384.9,0,0,100,2,8.48,4.47,0.001,0.072,0.927 Macedonia ,Macedonia,MKD,807,EASTERN EUROPE ,2050554,25333,80.9,0.00,-1.45,10.09,6700,,260.0,22.26,1.81,75.93,3,12.02,8.77,0.118,0.319,0.563 Madagascar ,Madagascar,MDG,450,SUB-SAHARAN AFRICA ,18595469,587040,31.7,0.82,0,76.83,800,68.9,3.6,5.07,1.03,93.91,2,41.41,11.11,0.276,0.165,0.559 Malawi ,Malawi,MWI,454,SUB-SAHARAN AFRICA ,13013926,118480,109.8,0.00,0,103.32,600,62.7,7.9,23.38,1.49,75.13,2,43.13,19.33,0.342,0.158,0.499 Malaysia ,Malaysia,MYS,458,ASIA (EX. NEAR EAST) ,24385858,329750,74.0,1.42,0,17.7,9000,88.7,179.0,5.48,17.61,76.91,2,22.86,5.05,0.084,0.48,0.436 Maldives ,Maldives,MDV,462,ASIA (EX. NEAR EAST) ,359008,300,1196.7,214.67,0,56.52,3900,97.2,90.0,13.33,16.67,70,2,34.81,7.06,0.2,0.18,0.62 Mali ,Mali,MLI,466,SUB-SAHARAN AFRICA ,11716829,1240000,9.5,0.00,-0.33,116.79,900,46.4,6.4,3.82,0.03,96.15,2,49.82,16.89,0.45,0.17,0.38 Malta ,Malta,MLT,470,WESTERN EUROPE ,400214,316,1266.5,62.28,2.07,3.89,17700,92.8,505.0,28.13,3.13,68.74,,10.22,8.1,0.03,0.23,0.74 Marshall Islands ,Marshall Islands,MHL,584,OCEANIA ,60422,11854,5.1,3.12,-6.04,29.45,1600,93.7,91.2,16.67,38.89,44.44,2,33.05,4.78,0.317,0.149,0.534 Martinique ,Martinique,MTQ,474,LATIN AMER. & CARIB ,436131,1100,396.5,31.82,-0.05,7.09,14400,97.7,394.4,10.38,9.43,80.19,2,13.74,6.48,0.06,0.11,0.83 Mauritania ,Mauritania,MRT,478,SUB-SAHARAN AFRICA ,3177388,1030700,3.1,0.07,0,70.89,1800,41.7,12.9,0.48,0.01,99.51,1,40.99,12.16,0.25,0.29,0.46 Mauritius ,Mauritius,MUS,480,SUB-SAHARAN AFRICA ,1240827,2040,608.3,8.68,-0.9,15.03,11400,85.6,289.3,49.26,2.96,47.78,2,15.43,6.86,0.059,0.298,0.643 Mayotte ,Mayotte,MYT,175,SUB-SAHARAN AFRICA ,201234,374,538.1,49.52,6.78,62.4,2600,,49.7,,,,2,40.95,7.7,,, Mexico ,Mexico,MEX,484,LATIN AMER. & CARIB ,107449525,1972550,54.5,0.47,-4.87,20.91,9000,92.2,181.6,12.99,1.31,85.7,1.5,20.69,4.74,0.038,0.259,0.702 Micronesia (Federated States of),Micronesia (Federated States of),FSM,583,OCEANIA ,108004,702,153.9,870.66,-20.99,30.21,2000,89.0,114.8,5.71,45.71,48.58,2,24.68,4.75,0.289,0.152,0.559 Moldova ,Moldova,MDA,498,C.W. OF IND. STATES ,4466706,33843,132.0,0.00,-0.26,40.42,1800,99.1,208.1,55.3,10.79,33.91,,15.7,12.64,0.213,0.233,0.555 Monaco ,Monaco,MCO,492,WESTERN EUROPE ,32543,2,16271.5,205.00,7.75,5.43,27000,99.0,1035.6,0,0,100,,9.19,12.91,0.17,, Mongolia ,Mongolia,MNG,496,ASIA (EX. NEAR EAST) ,2832224,1564116,1.8,0.00,0,53.79,1800,97.8,55.1,0.77,0,99.23,1,21.59,6.95,0.206,0.214,0.58 Montserrat ,Montserrat,MSR,500,LATIN AMER. & CARIB ,9439,102,92.5,39.22,0,7.35,3400,97.0,,20,0,80,2,17.59,7.1,,, Morocco ,Morocco,MAR,504,NORTHERN AFRICA ,33241259,446550,74.4,0.41,-0.98,41.62,4000,51.7,40.4,19.61,2.17,78.22,,21.98,5.58,0.217,0.357,0.426 Mozambique ,Mozambique,MOZ,508,SUB-SAHARAN AFRICA ,19686505,801590,24.6,0.31,0,130.79,1200,47.8,3.5,5.1,0.3,94.6,2,35.18,21.35,0.262,0.348,0.39 Namibia ,Namibia,NAM,516,SUB-SAHARAN AFRICA ,2044147,825418,2.5,0.19,0,48.98,7200,84.0,62.6,0.99,0,99.01,1,24.32,18.86,0.097,0.315,0.588 Nauru ,Nauru,NRU,520,OCEANIA ,13287,21,632.7,142.86,0,9.95,5000,,143.0,0,0,100,2,24.76,6.7,,, Nepal ,Nepal,NPL,524,ASIA (EX. NEAR EAST) ,28287147,147181,192.2,0.00,0,66.98,1400,45.2,15.9,21.68,0.64,77.68,,30.98,9.31,0.38,0.21,0.41 Netherlands ,Netherlands,NLD,528,WESTERN EUROPE ,16491461,41526,397.1,1.09,2.91,5.04,28600,99.0,460.8,26.71,0.97,72.32,3,10.9,8.68,0.021,0.244,0.736 New Caledonia ,New Caledonia,NCL,540,OCEANIA ,219246,19060,11.5,11.83,0,7.72,15000,91.0,252.2,0.38,0.33,99.29,2,18.11,5.69,0.15,0.088,0.762 New Zealand ,New Zealand,NZL,554,OCEANIA ,4076140,268680,15.2,5.63,4.05,5.85,21600,99.0,441.7,5.6,6.99,87.41,3,13.76,7.53,0.043,0.273,0.684 Nicaragua ,Nicaragua,NIC,558,LATIN AMER. & CARIB ,5570129,129494,43.0,0.70,-1.22,29.11,2300,67.5,39.7,15.94,1.94,82.12,2,24.51,4.45,0.165,0.275,0.56 Niger ,Niger,NER,562,SUB-SAHARAN AFRICA ,12525094,1267000,9.9,0.00,-0.67,121.69,800,17.6,1.9,3.54,0.01,96.45,1,50.73,20.91,0.39,0.17,0.44 Nigeria ,Nigeria,NGA,566,SUB-SAHARAN AFRICA ,131859731,923768,142.7,0.09,0.26,98.8,900,68.0,9.3,31.29,2.96,65.75,1.5,40.43,16.94,0.269,0.487,0.244 Northern Mariana Islands ,Northern Mariana Islands,MNP,580,OCEANIA ,82459,477,172.9,310.69,9.61,7.11,12500,97.0,254.7,13.04,4.35,82.61,2,19.43,2.29,,, Norway ,Norway,NOR,578,WESTERN EUROPE ,4610820,323802,14.2,7.77,1.74,3.7,37800,100.0,461.7,2.87,0,97.13,3,11.46,9.4,0.021,0.415,0.564 Oman ,Oman,OMN,512,NEAR EAST ,3102229,212460,14.6,0.98,0.28,19.51,13100,75.8,85.5,0,0.14,99.74,1,36.24,3.81,0.027,0.39,0.583 Pakistan ,Pakistan,PAK,586,ASIA (EX. NEAR EAST) ,165803560,803940,206.2,0.13,-2.77,72.44,2100,45.7,31.8,27.87,0.87,71.26,1,29.74,8.23,0.216,0.251,0.533 Palau ,Palau,PLW,585,OCEANIA ,20579,458,44.9,331.66,2.85,14.84,9000,92.0,325.6,8.7,4.35,86.95,2,18.03,6.8,0.062,0.12,0.818 Panama ,Panama,PAN,591,LATIN AMER. & CARIB ,3191319,78200,40.8,3.18,-0.91,20.47,6300,92.6,137.9,7.36,1.98,90.66,2,21.74,5.36,0.068,0.156,0.776 Papua New Guinea ,Papua New Guinea,PNG,598,OCEANIA ,5670544,462840,12.3,1.11,0,51.45,2200,64.6,10.9,0.46,1.44,98.1,2,29.36,7.25,0.353,0.381,0.266 Paraguay ,Paraguay,PRY,600,LATIN AMER. & CARIB ,6506464,406750,16.0,0.00,-0.08,25.63,4700,94.0,49.2,7.6,0.23,92.17,2,29.1,4.49,0.224,0.207,0.569 Peru ,Peru,PER,604,LATIN AMER. & CARIB ,28302603,1285220,22.0,0.19,-1.05,31.94,5100,90.9,79.5,2.89,0.4,96.71,1.5,20.48,6.23,0.08,0.27,0.65 Philippines ,Philippines,PHL,608,ASIA (EX. NEAR EAST) ,89468677,300000,298.2,12.10,-1.5,23.51,4600,92.6,38.4,18.95,16.77,64.28,2,24.89,5.41,0.144,0.326,0.53 Poland ,Poland,POL,616,EASTERN EUROPE ,38536869,312685,123.3,0.16,-0.49,8.51,11100,99.8,306.3,45.91,1.12,52.97,3,9.85,9.89,0.05,0.311,0.64 Portugal ,Portugal,PRT,620,WESTERN EUROPE ,10605870,92391,114.8,1.94,3.57,5.05,18000,93.3,399.2,21.75,7.81,70.44,3,10.72,10.5,0.053,0.274,0.673 Puerto Rico ,Puerto Rico,PRI,630,LATIN AMER. & CARIB ,3927188,13790,284.8,3.63,-1.46,8.24,16800,94.1,283.1,3.95,5.52,90.53,2,12.77,7.65,0.01,0.45,0.54 Qatar ,Qatar,QAT,634,NEAR EAST ,885359,11437,77.4,4.92,16.29,18.61,21500,82.5,232.0,1.64,0.27,98.09,1,15.56,4.72,0.002,0.801,0.197 Réunion ,Réunion,REU,638,SUB-SAHARAN AFRICA ,787584,2517,312.9,8.22,0,7.78,5800,88.9,380.9,13.6,1.2,85.2,2,18.9,5.49,0.08,0.19,0.73 Romania ,Romania,ROU,642,EASTERN EUROPE ,22303552,237500,93.9,0.09,-0.13,26.43,7000,98.4,196.9,40.82,2.25,56.93,3,10.7,11.77,0.101,0.35,0.549 Russia ,Russia,RUS,643,C.W. OF IND. STATES ,142893540,17075200,8.4,0.22,1.02,15.39,8900,99.6,280.6,7.33,0.11,92.56,,9.95,14.65,0.054,0.371,0.575 Rwanda ,Rwanda,RWA,646,SUB-SAHARAN AFRICA ,8648248,26338,328.4,0.00,0,91.23,1300,70.4,2.7,40.54,12.16,47.3,3,40.37,16.09,0.401,0.229,0.37 Saint Helena ,Saint Helena,SHN,654,SUB-SAHARAN AFRICA ,7502,413,18.2,14.53,0,19,2500,97.0,293.3,12.9,0,87.1,,12.13,6.53,,, Saint Kitts & Nevis ,Saint Kitts & Nevis,KNA,659,LATIN AMER. & CARIB ,39129,261,149.9,51.72,-7.11,14.49,8800,97.0,638.9,19.44,2.78,77.78,2,18.02,8.33,0.035,0.258,0.707 Saint Lucia ,Saint Lucia,LCA,662,LATIN AMER. & CARIB ,168458,616,273.5,25.65,-2.67,13.53,5400,67.0,303.3,6.56,22.95,70.49,2,19.68,5.08,0.07,0.2,0.73 Saint Pierre & Miquelon ,Saint Pierre & Miquelon,SPM,666,NORTHERN AMERICA ,7026,242,29.0,49.59,-4.86,7.54,6900,99.0,683.2,13.04,0,86.96,,13.52,6.83,,, Saint Vincent and the Grenadines ,Saint Vincent and the Grenadines,VCT,670,LATIN AMER. & CARIB ,117848,389,303.0,21.59,-7.64,14.78,2900,96.0,190.9,17.95,17.95,64.1,2,16.18,5.98,0.1,0.26,0.64 Samoa ,Samoa,WSM,882,OCEANIA ,176908,2944,60.1,13.69,-11.7,27.71,5600,99.7,75.2,21.2,24.38,54.42,2,16.43,6.62,0.114,0.584,0.302 San Marino ,San Marino,SMR,674,WESTERN EUROPE ,29251,61,479.5,0.00,10.98,5.73,34600,96.0,704.3,16.67,0,83.33,,10.02,8.17,,, Sao Tome & Principe ,Sao Tome & Principe,STP,678,SUB-SAHARAN AFRICA ,193413,1001,193.2,20.88,-2.72,43.11,1200,79.3,36.2,6.25,48.96,44.79,2,40.25,6.47,0.167,0.148,0.684 Saudi Arabia ,Saudi Arabia,SAU,682,NEAR EAST ,27019731,1960582,13.8,0.13,-2.71,13.24,11800,78.8,140.6,1.67,0.09,98.24,1,29.34,2.58,0.033,0.613,0.354 Senegal ,Senegal,SEN,686,SUB-SAHARAN AFRICA ,11987121,196190,61.1,0.27,0.2,55.51,1600,40.2,22.2,12.78,0.21,87.01,2,32.78,9.42,0.172,0.209,0.619 Serbia ,Serbia,SRB,688,EASTERN EUROPE ,9396411,88361,106.3,0.00,-1.33,12.89,2200,93.0,285.8,33.35,3.2,63.45,,,,0.166,0.255,0.579 Seychelles ,Seychelles,SYC,690,SUB-SAHARAN AFRICA ,81541,455,179.2,107.91,-5.69,15.53,7800,58.0,262.4,2.22,13.33,84.45,2,16.03,6.29,0.032,0.304,0.665 Sierra Leone ,Sierra Leone,SLE,694,SUB-SAHARAN AFRICA ,6005250,71740,83.7,0.56,0,143.64,500,31.4,4.0,6.98,0.89,92.13,2,45.76,23.03,0.49,0.31,0.21 Singapore ,Singapore,SGP,702,ASIA (EX. NEAR EAST) ,4492150,693,6482.2,27.85,11.53,2.29,23700,92.5,411.4,1.64,0,98.36,2,9.34,4.28,0,0.339,0.661 Slovakia ,Slovakia,SVK,703,EASTERN EUROPE ,5439448,48845,111.4,0.00,0.3,7.41,13300,,220.1,30.16,2.62,67.22,3,10.65,9.45,0.035,0.294,0.672 Slovenia ,Slovenia,SVN,705,EASTERN EUROPE ,2010347,20273,99.2,0.23,1.12,4.45,19000,99.7,406.1,8.6,1.49,89.91,,8.98,10.31,0.028,0.369,0.603 Solomon Islands ,Solomon Islands,SLB,90,OCEANIA ,552438,28450,19.4,18.67,0,21.29,1700,,13.4,0.64,2,97.36,2,30.01,3.92,0.42,0.11,0.47 Somalia ,Somalia,SOM,706,SUB-SAHARAN AFRICA ,8863338,637657,13.9,0.47,5.37,116.7,500,37.8,11.3,1.67,0.04,98.29,1,45.13,16.63,0.65,0.1,0.25 South Africa ,South Africa,ZAF,710,SUB-SAHARAN AFRICA ,44187637,1219912,36.2,0.23,-0.29,61.81,10700,86.4,107.0,12.08,0.79,87.13,1,18.2,22,0.025,0.303,0.671 Spain ,Spain,ESP,724,WESTERN EUROPE ,40397842,504782,80.0,0.98,0.99,4.42,22000,97.9,453.5,26.07,9.87,64.06,3,10.06,9.72,0.04,0.295,0.665 Sri Lanka ,Sri Lanka,LKA,144,ASIA (EX. NEAR EAST) ,20222240,65610,308.2,2.04,-1.31,14.35,3700,92.3,61.5,13.86,15.7,70.44,2,15.51,6.52,0.178,0.276,0.545 Sudan ,Sudan,SDN,729,SUB-SAHARAN AFRICA ,41236378,2505810,16.5,0.03,-0.02,62.5,1900,61.1,16.3,6.83,0.18,92.99,2,34.53,8.97,0.387,0.203,0.41 Suriname ,Suriname,SUR,740,LATIN AMER. & CARIB ,439117,163270,2.7,0.24,-8.81,23.57,4000,93.0,184.7,0.37,0.06,99.57,2,18.02,7.27,0.13,0.22,0.65 Swaziland ,Swaziland,SWZ,748,SUB-SAHARAN AFRICA ,1136334,17363,65.5,0.00,0,69.27,4900,81.6,30.8,10.35,0.7,88.95,2.5,27.41,29.74,0.119,0.515,0.366 Sweden ,Sweden,SWE,752,WESTERN EUROPE ,9016596,449964,20.0,0.72,1.67,2.77,26800,99.0,715.0,6.54,0.01,93.45,3,10.27,10.31,0.011,0.282,0.707 Switzerland ,Switzerland,CHE,756,WESTERN EUROPE ,7523934,41290,182.2,0.00,4.05,4.39,32700,99.0,680.9,10.42,0.61,88.97,3,9.71,8.49,0.015,0.34,0.645 Syria ,Syria,SYR,760,NEAR EAST ,18881361,185180,102.0,0.10,0,29.53,3300,76.9,153.8,25.22,4.43,70.35,1,27.76,4.81,0.249,0.23,0.519 Taiwan ,Taiwan,TWN,158,ASIA (EX. NEAR EAST) ,23036087,35980,640.3,4.35,0,6.4,23400,96.1,591.0,24,1,75,2,12.56,6.48,0.018,0.259,0.723 Tajikistan ,Tajikistan,TJK,762,C.W. OF IND. STATES ,7320815,143100,51.2,0.00,-2.86,110.76,1000,99.4,33.5,6.61,0.92,92.47,2,32.65,8.25,0.234,0.286,0.48 Tanzania ,Tanzania,TZA,834,SUB-SAHARAN AFRICA ,37445392,945087,39.6,0.15,-2.06,98.54,600,78.2,4.0,4.52,1.08,94.4,,37.71,16.39,0.432,0.172,0.396 Thailand ,Thailand,THA,764,ASIA (EX. NEAR EAST) ,64631595,514000,125.7,0.63,0,20.48,7400,92.6,108.9,29.36,6.46,64.18,2,13.87,7.04,0.099,0.441,0.46 Togo ,Togo,TGO,768,SUB-SAHARAN AFRICA ,5548702,56785,97.7,0.10,0,66.61,1500,60.9,10.6,46.15,2.21,51.64,2,37.01,9.83,0.395,0.204,0.401 Tonga ,Tonga,TON,776,OCEANIA ,114689,748,153.3,56.02,0,12.62,2200,98.5,97.7,23.61,43.06,33.33,2,25.37,5.28,0.23,0.27,0.5 Trinidad & Tobago ,Trinidad & Tobago,TTO,780,LATIN AMER. & CARIB ,1065842,5128,207.9,7.06,-10.83,24.31,9500,98.6,303.5,14.62,9.16,76.22,2,12.9,10.57,0.007,0.57,0.423 Tunisia ,Tunisia,TUN,788,NORTHERN AFRICA ,10175014,163610,62.2,0.70,-0.57,24.77,6900,74.2,123.6,17.86,13.74,68.4,3,15.52,5.13,0.132,0.318,0.55 Turkey ,Turkey,TUR,792,NEAR EAST ,70413958,780580,90.2,0.92,0,41.04,6700,86.5,269.5,30.93,3.31,65.76,3,16.62,5.97,0.117,0.298,0.585 Turkmenistan ,Turkmenistan,TKM,795,C.W. OF IND. STATES ,5042920,488100,10.3,0.00,-0.86,73.08,5800,98.0,74.6,3.72,0.14,96.14,1,27.61,8.6,0.209,0.38,0.411 Turks & Caicos Islands ,Turks & Caicos Islands,TCA,796,LATIN AMER. & CARIB ,21152,430,49.2,90.47,11.68,15.67,9600,98.0,269.5,2.33,0,97.67,2,21.84,4.21,,, Tuvalu ,Tuvalu,TUV,798,OCEANIA ,11810,26,454.2,92.31,0,20.03,1100,,59.3,0,0,100,2,22.18,7.11,0.166,0.272,0.562 Uganda ,Uganda,UGA,800,SUB-SAHARAN AFRICA ,28195754,236040,119.5,0.00,0,67.83,1400,69.9,3.6,25.88,10.65,63.47,2,47.35,12.24,0.311,0.222,0.469 Ukraine ,Ukraine,UKR,804,C.W. OF IND. STATES ,46710816,603700,77.4,0.46,-0.39,20.34,5400,99.7,259.9,56.21,1.61,42.18,3,8.82,14.39,0.187,0.452,0.361 United Arab Emirates ,United Arab Emirates,ARE,784,NEAR EAST ,2602713,82880,31.4,1.59,1.03,14.51,23200,77.9,475.3,0.6,2.25,97.15,1,18.96,4.4,0.04,0.585,0.375 United Kingdom of Great Britain and Northern Ireland,United Kingdom of Great Britain and Northern Ireland,GBR,826,WESTERN EUROPE ,60609153,244820,247.6,5.08,2.19,5.16,27700,99.0,543.5,23.46,0.21,76.33,3,10.71,10.13,0.005,0.237,0.758 United States of America,United States of America,USA,840,NORTHERN AMERICA ,298444215,9631420,31.0,0.21,3.41,6.5,37800,97.0,898.0,19.13,0.22,80.65,3,14.14,8.26,0.01,0.204,0.787 Uruguay ,Uruguay,URY,858,LATIN AMER. & CARIB ,3431932,176220,19.5,0.37,-0.32,11.95,12800,98.0,291.4,7.43,0.23,92.34,3,13.91,9.05,0.093,0.311,0.596 Uzbekistan ,Uzbekistan,UZB,860,C.W. OF IND. STATES ,27307134,447400,61.0,0.00,-1.72,71.1,1700,99.3,62.9,10.83,0.83,88.34,1,26.36,7.84,0.342,0.229,0.43 Vanuatu ,Vanuatu,VUT,548,OCEANIA ,208869,12200,17.1,20.72,0,55.16,2900,53.0,32.6,2.46,7.38,90.16,2,22.72,7.82,0.26,0.12,0.62 Venezuela ,Venezuela,VEN,862,LATIN AMER. & CARIB ,25730435,912050,28.2,0.31,-0.04,22.2,4800,93.4,140.1,2.95,0.92,96.13,2,18.71,4.92,0.04,0.419,0.541 Vietnam ,Vietnam,VNM,704,ASIA (EX. NEAR EAST) ,84402966,329560,256.1,1.05,-0.45,25.95,2500,90.3,187.7,19.97,5.95,74.08,2,16.86,6.22,0.209,0.41,0.381 Virgin Islands ,Virgin Islands,VIR,850,LATIN AMER. & CARIB ,108605,1910,56.9,9.84,-8.94,8.03,17200,,652.8,11.76,2.94,85.3,2,13.96,6.43,0.01,0.19,0.8 Wallis and Futuna ,Wallis and Futuna,WLF,876,OCEANIA ,16025,274,58.5,47.08,,,3700,50.0,118.6,5,25,70,2,,,,, Western Sahara ,Western Sahara,ESH,732,NORTHERN AFRICA ,273008,266000,1.0,0.42,,,,,,0.02,0,99.98,1,,,,,0.4 Yemen ,Yemen,YEM,887,NEAR EAST ,21456188,527970,40.6,0.36,0,61.5,800,50.2,37.2,2.78,0.24,96.98,1,42.89,8.3,0.135,0.472,0.393 Zambia ,Zambia,ZMB,894,SUB-SAHARAN AFRICA ,11502010,752614,15.3,0.00,0,88.29,800,80.6,8.2,7.08,0.03,92.9,2,41,19.93,0.22,0.29,0.489 Zimbabwe ,Zimbabwe,ZWE,716,SUB-SAHARAN AFRICA ,12236805,390580,31.3,0.00,0,67.69,1900,90.7,26.8,8.32,0.34,91.34,2,28.01,21.84,0.179,0.243,0.57
.. activecode:: pandas
:language: python3
:datafile: country_data.csv
import pandas as pd
df = pd.read_csv('country_data.csv', encoding='latin1')
For this example, we move our PartyAnimal
class into its own file.
Then, we can ‘import’ the PartyAnimal
class in a new file and extend it, as follows:
class PartyAnimal: def __init__(self, nam): self.name = nam print(self.name,'constructed') def party(self, x) : self.x = x self.x = self.x + 1 print(self.name,'party count',self.x)