general-purpose programming language From Wikipedia, the free encyclopedia
Python is a programming language. It was made to be open-source and easy to read. A Dutch programmer named Guido van Rossum made Python in 1991. He named it after the television program Monty Python's Flying Circus. Many Python examples and tutorials include jokes from the show.[31]
Paradigm | Multi-paradigm: object-oriented,[1] procedural (imperative), functional, structured, reflective |
---|---|
Designed by | Guido van Rossum |
Developer | Python Software Foundation |
First appeared | 20 February 1991[2] |
Stable release | 3.13.1[3] / 3 December 2024 |
Typing discipline | Duck, dynamic, strong typing;[4] gradual (since 3.5, but ignored in CPython)[5] |
OS | Windows, Linux/UNIX, macOS and more[6] |
License | Python Software Foundation License |
Filename extensions | .py, .pyi, .pyc, .pyd, .pyo (prior to 3.5),[7] .pyw, .pyz (since 3.5)[8] |
Website | www |
Major implementations | |
CPython, PyPy, Stackless Python, MicroPython, CircuitPython, IronPython, Jython | |
Dialects | |
Cython, RPython, Starlark[9] | |
Influenced by | |
ABC,[10] Ada,[11] ALGOL 68,[12] APL,[13] C,[14] C++,[15] CLU,[16] Dylan,[17] Haskell,[18] Icon,[19] Java,[20] Lisp,[21] Modula-3,[15] Perl, Standard ML[13] | |
Influenced | |
Apache Groovy, Boo, Cobra, CoffeeScript,[22] D, F#, Genie,[23] Go, JavaScript,[24][25] Julia,[26] Nim, Ring,[27] Ruby,[28] Swift,[29] V (Vlang)[30] | |
|
Python is an interpreted language. Interpreted languages do not need to be compiled to run. A program called an interpreter runs Python code on almost any kind of computer. This means that a programmer can change the code and quickly see the results. This also means Python is slower than a compiled language like C, because it is not turned into machine code ahead of time. Instead, this happens as the program is running.
Python's developers try to avoid changing the language to make it better until they have a lot of things to change. Also, they try not to make small repairs, called patches, to unimportant parts of CPython, the main version of Python, even if the patches would make it faster. When speed is important, a Python programmer can write some of the program in a different language, like C, or use PyPy, a different kind of Python that uses a just-in-time compiler.
Keeping Python fun to use is an important goal of Python’s developers. It reflects in the language's name, a tribute to the British comedy group Monty Python. Tutorials often take a playful approach, such as referring to spam and eggs instead of the standard foo and bar.
Python is usually used for making websites, automating common tasks, and making charts and graphs. Since it's simple to learn, people who are not computer experts, like bookkeepers and researchers, often learn Python.
Its standard library is made up of many functions that come with Python when it is installed.[32] On the Internet, there are many other libraries libraries have been examined to provide wonderful ends in varied areas like Machine Learning (ML), Deep Learning, etc.[33] These libraries make it a powerful language; it can do many different things.
Some of Python's syntax comes from C, because that is the language that Python was written in. But Python uses whitespace to delimit code: spaces or tabs are used to organize code into groups. This is different from C. In C, there is a semicolon at the end of each line and curly braces ({}) are used to group code. Using whitespace to delimit code makes Python a very easy-to-read language.[34]
Python's statements include:
x = 2
means that the name x is bound to the integer 2. Names can be rebound to many different types in Python, which is why Python is a dynamically typed language. For example, you could now type the statement x = 'spam'
and it would work, but it wouldn't in another language like C or C++.Python's expressions include some that are similar to other programming languages and others that are not.
This is a small example of a Python program. It shows "Hello World!" on the screen.
print("Hello World!")
# This code does the same thing, only it is longer:
ready = True
if ready:
print("Hello World!")
Python also does something called "dynamic variable assignment". This means that when a number or word is made in a program, the user does not have to say what type it is. This makes it easier to reuse variable names, making fast changes simpler. An example of this is shown below. This code will make both a number and a word, and show them both, using only one variable.
x = 1
print(x)
x = "Word"
print(x)
In a "statically typed" language like C, a programmer would have to say whether x
was a number or a word before C would let the programmer set up x
, and after that, C would not allow its type to change from a number to a word.
In Python they have easy to use functions. In a language like C you need to tell if it would give you back a number or word. In Python you don't have to specify the type.
def greeting(name):
print("Hello, " + name)
greeting("Reader")
this function returns "Hello, Reader"
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.