Starting with Python

getting started with this data-oriented programming language
2025-11-03 12:04
// updated 2025-11-06 20:58

For this article, I shall defer installation of Python to this Codecademy article and start promptly with programming basics:

  • commenting
  • defining functions
  • outputting text

"Hello, world"

In the following starter code, we shall observe a few things:

# helloworld.py - this is a comment

def main():
  print('hello world - this prints the stuff in the main function')
  secondary_function()

def secondary_function():
  print('prints when calling this function from main')
  tertiary_function()

def tertiary_function():
  print('prints when calling this function from secondary_function')

if __name__ == '__main__':
  main()
  • commenting
    • most with programming experience (and without Python experience) might gather that the first line represents a comment (starting with # to denote its role as a comment)
  • indentation consistency
    • in Python, we must indent to help both the human and the computer reading the code
  • def keyword
    • used to define a function
  • main function
    • when the program runs, it will call this function (unless otherwise specified)
  • print function
    • when the program runs, it will output the contents inside the brackets
  • if statement
    • in this context, we use this statement to determine whether
      • the program will run on its own (__main__), or
      • as an imported package in another script
newer (in textbook-python) ➡️
Python input and output 🐍
⬅️ older (in code)
📜 Jonolist
newer (in code) ➡️
Python input and output 🐍
⬅️ older (posts)
📜 Jonolist
newer (posts) ➡️
Python input and output 🐍