Python vs Java

I recently completed the JavaScript and Java courses on Codecademy*. (Tableau has a JavaScript API that can be harnessed to create really cool stuff.) But, as soon as I figured out Java, I needed to brush up on Python for an upcoming Data Science course.

Transitioning between the two is notoriously tricky. I found myself adding so many unnecessary characters that I decided to build a table to look at them side by side.


Python Java
Comment # //
Multiline Comment “”” /*
Boolean True true
Character n/a ‘A’
String “A” or ‘A’ “A”
x = 1

x = “A”

Legal illegal
Concatenation x = 3

s = “The answer is ” + str(x)

int x = 3

String s = “The answer is ” +  x;

Functions def square(x):

return x*x

public static int square(int x){

return x*x


If if x > 0:

  print ‘positive’

elif x < 0:

  print ‘negative’


  print ‘zero’

if (x > 0) {


} else if (x < 0) {


} else {



Boolean Operators and or not &&, ||, !
Loops for w in words:

   w = w.upper()

   print w

for i in range(2, 9, 3):

   print i

for (String w: words) {

   w = w.toUppercase();



for (int i = 2; i < 9; i +=3)


Dictionaries map = dict()

map[‘Jose’] = ‘773-000-1234’ map[‘Mary’] = ‘312-555-9999’

print map[‘Jose’]  

for key in map:

   print key

   print map[key]

Map<String, String> map = new HashMap<String, String>();

map.put(“Jose”, “773-000-1234”);

map.put(“Mary”, “312-555-9999”);


for (String key : map.keySet()) {




From <>

*The new Learn ___ courses seem crappy. The projects are behind a paywall, and the exercises seem much, much easier than legacy ones.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s