Skip to content

Instantly share code, notes, and snippets.

@kaydell
Last active December 24, 2015 08:49
Show Gist options
  • Save kaydell/6772714 to your computer and use it in GitHub Desktop.
Save kaydell/6772714 to your computer and use it in GitHub Desktop.
This gist is a sample of Python code that demonstrates a simpler, easier syntax for beginning programming students to learn more easily. Consider teaching Python for introductory courses, and teaching Java to more advanced students in a more advanced course.
"""
This Python source file demonstrates how Python for-loops
and the main() method are easier for students to understand
than Java is.
About Python: http://www.python.org/about/
Free Python Download: http://www.python.org/download/
It is worth considering teaching beginning students Python
and teach Java in more advanced courses.
"""
# define the main() method
# In Python, it's much easier for beginning students to
# understand the declaration of the main method.
def main():
# In Python, it's much easier for beginning students
# to understand a definite loop:
for i in range(10):
# In Python, the print() statement is easier to
# understand than : System.out.println()
# In Python, indentation is meaningful, meaning that the way
# the code is indented is the way that it is run
print(i);
# call the main method
main()
"""
Conclusion:
Pros:
Python code is easier to understand.
In Python code, indentation is meaningful. Students can't be confused by their indentation implying one thing, but the braces
meaning another thing.
Python is 100% object-oriented
Python is free, and open-source
Cons: Python2 and Python 3 are not compatible, so choose your textbooks accordingly to cover either Python 2 **or** Python 3 -- not both
It's hard to upgrade from Python 2 to Python 3
Python doesn't catch as many errors before running the programs.
Getting the indentation done correctly with tabs or spaces can be difficult.
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment