Python Language Main Concepts And Summary

Published:
Last modified:

Why Python?

Python language core concepts1:

  • Python is a programming language that offers much more structure and support for large programs than shell scripts or batch files.
  • Python has high-level data types built in, such as flexible arrays and dictionaries.
  • Python allows you to split your program into modules that can be reused in other Python programs. It comes with a large collection of standard modules that you can use as the basis of your programs
  • Python is an interpreted language, no compilation and linking is necessary. The interpreter can be used interactively.
  • Statement grouping is done by indentation instead of beginning and ending brackets;
  • no variable or argument declarations are necessary.
  • Python is extensible, easy to add a new built-in function or module to the interpreter.

Python Interpreter

Python commands can handle arguments with the sys module. The script name and additional arguments are turned into a list of strings and assigned to the argv variable in the sys module. This list is accessible after executing import sys, for example with sys.argv[0].

Encoding

By default, Python source files are treated as encoded in UTF-8, this is equivalent to having # -*- coding: utf-8 -*- in scripts.

Numbers

Python supports several types of numbers:
int
class int(x=0)
class int(x, base=10)
Return an integer object constructed from a number or string x, or return 0 if no arguments are given
float
class float([x])
Return a floating point number constructed from a number or string x.
Decimal
class decimal.Decimal(value=“0”, context=None)¶
Construct a new Decimal object based from value.
Fraction
[sign] numerator [’/’ denominator]
A Fraction instance can be constructed from a pair of integers, from another rational number, or from a string.

And even complex numbers, (using j or J suffix to indicate the imaginary part e.g. 3+5j)

Uruguay
Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.
comments powered by Disqus


Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 . Terms and Policy.

Powered by SimpleIT Hugo Theme

·