From 13fba0a48568b021211b8a103a1d4c95a9826689 Mon Sep 17 00:00:00 2001 From: TrashPandit Date: Wed, 23 Oct 2019 17:24:05 -0400 Subject: [PATCH 1/2] fixed your wording and the code --- basic_examples/python_booleans.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/basic_examples/python_booleans.py b/basic_examples/python_booleans.py index b006e8b..5699b00 100644 --- a/basic_examples/python_booleans.py +++ b/basic_examples/python_booleans.py @@ -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.") From dea1c9480fbcc900ab39c18d23f3a7989a443f40 Mon Sep 17 00:00:00 2001 From: TrashPandit Date: Wed, 23 Oct 2019 18:32:56 -0400 Subject: [PATCH 2/2] I fixed the code --- basic_examples/python_lists.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/basic_examples/python_lists.py b/basic_examples/python_lists.py index 0251055..cb51d6e 100755 --- a/basic_examples/python_lists.py +++ b/basic_examples/python_lists.py @@ -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)