Introduction to Python for Java programmers | COMP70050: Introduction to Machine Learning | Department of Computing | Imperial College London home article Introduction to Machine Learning COMP70050 Autumn Term 2021/2022 Introduction to Python for Java programmers The Zen of Python Example Python program Python vs. Java - Main method Python vs. Java - Variable declaration Python vs. Java - Semicolons Python vs. Java - Braces Python vs. Java - Comments Running Python Running Python as a script Running Python interactively Basic built-in data types Everything is an object Reserved words Variables - Java vs. Python Python Variables Objects in Python Operators Assignment operator Lists Accessing Lists Modifying Lists Tuples Strings are sequences Formatting strings Sets Dictionaries Grouping data with dict and tuple Control flow Loops Useful objects for loops List comprehensions Functions Function arguments Built-in functions Object-Oriented Programming in Python Constructor Attributes Methods Magic/Dunder methods Inheritance Encapsulation Encapsulation the Pythonic way What about protected? Python modules Custom modules What's in a __name__? Handling text files Reading CSV files Writing to CSV files Handling JSON files Pickle That's a wrap! Introduction to Python for Java programmers Welcome! I am Josiah, and I will be your guide through this tutorial. This is designed to be a crash course on Python. The aim is to get you up to speed with Python fast! ⚡ I will assume that you already know how to program in Java. Rather than discussing programming concepts from scratch, I will instead introduce you to Python by highlighting its differences to Java, whether it is the differences in their syntax or in their design philosophies. While many fundamental concepts are common between Python and Java, I will aim to highlight when you should not be thinking like a Java programmer when programming in Python. I will assume that you already have a reasonable understanding of imperative programming (variables, loops, control flows, functions) as well as object-oriented programming concepts (classes, methods, object instances, inheritance, encapsulation) in Java. I will not aim to tell you everything about Python, but instead give you just enough information to get you started exploring Python on your own, so that you will be able to work on the practical aspects of the Introduction to Machine Learning course. Most importantly, I will try to guide you on how to think in Python. Also, please do not be alarmed by the number of pages in this tutorial. Each page is actually quite short. This is to keep you focussed! 🎯 Ok, let’s get started! 👨🏫 Next >> Page designed by Josiah Wang Department of Computing | Imperial College London