Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions basic_examples/python_booleans.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
print "Python has 10 type of booleans", True, " and ", False
print "They are normally the result of comparisons"
print ("Python has 2 types of booleans, True, and , False")
print ("They are normally the result of comparisons")

num = 8
if num < 10:
print num, " is less than 10"
print (num, " is less than 10")
else:
print num, " is not less than 10"
print (num, " is not less than 10")


print "What we just saw are conditional statements.
print "It's ok if you do not understand them, we will look into them in greater details very soon."
print ("What we just saw are conditional statements.")
print ("It's ok if you do not understand them, we will look into them in greater details very soon.")
21 changes: 11 additions & 10 deletions basic_examples/python_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@
jvm_langs = ['Java', 'Jython', 'Groovy', 'Scala', 'Jruby']

#How many JVM langs do you know ?
print 'I know of ', jvm_langs.__len__(), 'langs that can run on the JVM'

print ('I know of ' + str(jvm_langs.__len__()) + ' langs that can run on the JVM')
#It's not a good idea to directly us __xxx__ methods
#A better way is. Remember there is usually a top level function which
#is the idoimatic way to access the __xxx__method
print 'I know of ', len(jvm_langs), 'langs that can run on the JVM'
print ('I know of ' + str(len(jvm_langs)) + ' langs that can run on the JVM')

print 'Oops I forgot Clojure'
print ('Oops I forgot Clojure')
jvm_langs.append('Clojure')

#Let's iterate across the list
for lang in jvm_langs:
print lang
print (lang)

#Can we get the 3rd element of the list ?
print "The 3rd JVM language is ", jvm_langs[2]
print "The first 3 JVM languages are ", jvm_langs[:3]
print "The 2nd to 4th JVM languages are ", jvm_langs[1:4]
print ("The 3rd JVM language is " + jvm_langs[2])
#Lists start indexing at the number 0, so the 1st element is [0]
print ("The first 3 JVM languages are " + str(jvm_langs[:3]))
#This goes from the first element until the 3rd and prints them
print ("The 2nd to 4th JVM languages are " + str(jvm_langs[1:4]))

print "let's sort these languages"
print ("let's sort these languages")
jvm_langs.sort()
print jvm_langs
print(jvm_langs)