Python and Kotlin: A comparison of the language basics

In this table I will compare some basic programming syntax and conventions between the Python and Kotlin programming languages. Programming element Python Kotlin Commenting code: # This is a comment // This is a comment Multi-line comments: “”” This is a comment. This is a comment, too. This is a comment, too. “”” /* This … Continue reading Python and Kotlin: A comparison of the language basics

Python: How to play a video (with sound) in Pygame

When creating a game in Pygame, the trick to getting a video with sound to play is to place pygame.mixer.quit() right after pygame.init(). This is because pygame.mixer doesn’t play well with pygame.movie. For example: pygame.init() pygame.mixer.quit() Here is what that looks like in the context of a larger block of code: import pygame FPS = … Continue reading Python: How to play a video (with sound) in Pygame

Python: How to open and read .csv documents

Unlike text documents, which Python has a native open() function for: Python: How to open and read text documents Opening and reading .csv files requires importing the csv module and using a csv.reader(). For example, this code will open and read the first 10 lines in a .csv file: import csv csv_path = r’C:\Users\Chris\Desktop\Python Scripts\Python … Continue reading Python: How to open and read .csv documents

Python: How to install WinPython and Jupyter Notebook

To use Python with a Jupyter Notebook for Data Science and other projects, you will first need to make sure you have Python 3 and Jupyter Notebook installed. There are Jupyter Notebook installation instructions here: https://jupyter.readthedocs.io/en/latest/install.html This site recommends installing Anaconda, which bundles installation of Python 3 with Jupyter Notebook, which is just fine. However, … Continue reading Python: How to install WinPython and Jupyter Notebook