top of page

Basic Datatypes of Python

  • Writer: Jino Shaji
    Jino Shaji
  • Jan 7, 2015
  • 1 min read

Updated: Jun 9, 2020


Basic Datatypes of Python

•Integers (default for numbers)

z = 5 / 2    # Answer is 2, integer division.

•Floats

x = 3.456

•Strings

Can use “” or ‘’ to specify.   “abc”  ‘abc’  (Same thing.)

Unmatched ones can occur within the string.  “matt’s”

Use triple double-quotes for multi-line strings or strings than contain both ‘ and “ inside of them:  “““a‘b“c”””


Whitespace

             is meaningful in Python: especially indentation and placement of newlines. 

–Use a newline to end a line of code. (Not a semicolon like in C++ or Java.) (Use \ when must go to next line prematurely.)

–No braces { } to mark blocks of code in Python… Use consistent indentation instead.  The first line with a new indentation is considered outside of the block.

–Often a colon appears at the start of a new block.  (We’ll see this later for function and class definitions.)

Recent Posts

See All
Program to Create an investment report.

“””Program: investment.py Author: JINO SHAJI Compute an investment report. 1. The inputs are        starting investment amount       ...

 
 
 

Comments


bottom of page