Syntax Comparison between Python and C++ (Partial Listing)
Syntax  Description Python C++
 including a module/library  import math  #include <cmath>
 assignment operator  =, +=, -=, *=, /=, %=  same
 type integer value  int, long  short, int, long
 type decimal value  float  float, double, long double
 type boolean  bool: True & False or (not 0) & 0  bool: true & false or (!0) & 0
 type character  n/a  char
 type string  str  char mystring[50] or string
 for statement  for i in range(10):  for(i = 0; i < 10; i++){ ... }
 if statement  if x != 3:  if( x != 3 ){ ... }
 while statement  while x != 3:  while( x != 3 ){ ... }
 break out of a loop  break  same
 function definition  def myfunction():  int myfunction(){ ... }
 function call  myfunction()  same
 and operator  and  &&, and
 or operator  or  ||, or
 not operator  not  !, not
 comparison operators  ==, !=, <, <=, >, >=  same
 arithmetic operators  +, -, *, /, //, % (int and float division)  +, -, *, /, %
 comments - single line  #  //
 comments - multiple lines  n/a  /*    */
 pre and post increment/decrement operators  n/a  ++x, x++, --x, x--
 code blocks  indentation  { }
 statement separator  end of line  ;
 constants  n/a  const int interest = 0.018
 Input/Output  input(), print()  cin, cout, and many others.
(Adapted from Dr. Cen Li)