Python Programming

Department of Computing, Imperial College London

home

Python for C++ Programmers

  • Chapter 1: Introduction
    • [1.1] Introduction
    • [1.2] The Zen of Python
    • [1.3] Example Python program
    • [1.4] Python vs. C++ - Main function
    • [1.5] Python vs. C++ - Variable declaration
    • [1.6] Python vs. C++ - Semicolons
    • [1.7] Python vs. C++ - Braces
    • [1.8] Python vs. C++ - Comments
    • [1.9] Running Python
    • [1.10] Running Python as a script
    • [1.11] Running Python interactively
  • Chapter 2: Basic data types
  • Chapter 3: Variables and operators
  • Chapter 4: Sequence types
  • Chapter 5: Sets and dictionaries
  • Chapter 6: Control flow
  • Chapter 7: Functions
  • Chapter 8: Object-oriented programming
  • Chapter 9: Modules
  • Chapter 10: Files

Chapter 1: Introduction

Python vs. C++ - Semicolons

face Josiah Wang

Semicolons are optional in Python. Instead, the new line (\n) marks the end of a statement, since it’s better to have one statement per line anyway! It also declutters the code a bit.

Of course, you are welcome to keep the semicolons if you prefer, especially if you plan to program in C++ at the same time as Python!

Simple guessing game - C++ vs Python (semicolons)

Previous Next

Page designed by Josiah Wang

Department of Computing | Imperial College London