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)
Python 3 tutorial https://docs.python.org/3/tutorial/appetite.html ↩︎
comments powered by Disqus
- Python Tools To Write Better CodeNovember 7, 2017
- Python Language Main Concepts And Summary
- Python notesMay 30, 2016
Python Language Concepts
- Understanding How Python Packages Modules And Imports WorkJanuary 2, 2017
- Python Language Basic ConceptsJune 14, 2016
Python Environment
- Understanding Python 3 virtual environments different approachesJanuary 15, 2019
- Python Projects Isolation Using Virtual EnvironmentsJune 10, 2016
Articles
Subcategories
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
·