| Paradigm | Multi-paradigm: object-oriented, procedural (imperative), functional, structured, reflective |
|---|---|
| Designed by | Guido van Rossum |
| Developer | Python Software Foundation |
| First appeared | 20 February 1991 |
| Stable release | 3.15.2 |
| Typing discipline | Duck, dynamic, strong typing; gradual (since 3.5, but ignored in CPython) |
| OS | Windows, Linux/UNIX, macOS and more |
| License | Python Software Foundation License |
| Filename extensions | .py, .pyi, .pyc, .pyd, .pyo (prior to 3.5), .pyw, .pyz (since 3.5) |
| Website | www |
| Major implementations | |
| CPython, PyPy, Stackless Python, MicroPython, CircuitPython, IronPython, Jython | |
| Dialects | |
| Cython, RPython, Starlark | |
| Influenced by | |
| ABC, Ada, ALGOL 68, APL, C, C++, CLU, Dylan, Haskell, Icon, Java, Lisp, Modula-3, Perl, Standard ML | |
| Influenced | |
| Apache Groovy, Boo, Cobra, CoffeeScript, D, F#, Genie, Go, JavaScript, Julia, Nim, Ring, Ruby, Swift, V (Vlang) | |
| |
Python is an open-source programming language. It was made as a language that is both easy to work on and understand. It was made by a Dutch programmer named Guido van Rossum in 1991, who named it after the television program Monty Python's Flying Circus.
Python is an interpreted language. This means it does not need to be compiled before running. A program called an interpreter runs Python code on almost any computer. This makes Python slower than compiled languages like C, because it is not changed into machine code before running. But this also allows the programmer to change the code and quickly see what happens.
Python is a general-purpose programming language. It can be used for many purposes. Python is often 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.
Python's standard library is made up of many functions that come with Python when it is installed. On the Internet, there are many other libraries which do tasks in varied areas like Machine Learning (ML), Deep Learning, etc.
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 uses whitespace to separate 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.
In Python, the statement myVariable = 42 means that the variable myVariable is set to the integer 42. The type of myVariable is not needed: Python dynamically adapts its type to the given value. For example, replace 42 with the string 'spam'. The statement myVariable = 'spam' would work, but it wouldn't in another language like C or C++.
Python's statements include the following keywords:
if statement runs its first block of code if its condition is met. The optional elif (a contraction of else if) statement runs its block of code if the previous conditions are not met, but its condition is met. The else statement runs the last block of code if none of the previous conditions are met.while statement is a loop. As long as its condition is met, it runs its block of code.for statement is a loop with an index. It iterates over a list and binds each element to the index to use in that block.def statement defines a function or method.pass statement does nothing.class statement allows the users to create their own type of objects like what integers and strings are.import statement imports Python files for use in the user's code.print statement outputs a message to the console.Python's expressions include some operators that are similar to other programming languages and others that are not:
+, subtraction -, multiplication *, and division /.**.==.and, or, and not for its boolean expressions.in.The following Python program shows "Hello World!" on the screen:
print("Hello World!")
A comment starts with # until the end of the line:
print("Hello World!") # displays: Hello World!
In Python variables do not have types that can not be changed. This code will display the number 42 then the string "Hello World!", using the same variable.
myVariable = 42
print(myVariable) # displays: 42
myVariable = "Hello World!"
print(myVariable) # displays: Hello World!
In another language like C, a programmer would have to declare whether myVariable is a number or a string before modify it. An error will occur if one changes a number to a string.
The C language requires the type of the function. In Python, the function does not need a type after :.
def greeting(name):
return "Hello, " + name
When called with the parameter name as "World!", this function returns the string "Hello, World!".
print(greeting("World!")) # displays: Hello, World!
![]() |
even though the design of C is far from ideal, its influence on Python is considerable.
{{cite journal}}: Cite uses deprecated parameter |citeseerx= (help)It is a mixture of the class mechanisms found in C++ and Modula-3
replace "CLU" with "Python", "record" with "instance", and "procedure" with "function or method", and you get a pretty accurate description of Python's object model.
The C3 method itself has nothing to do with Python, since it was invented by people working on Dylan and it is described in a paper intended for lispers
We want something as usable for general programming as Python [...]
The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas. Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list.
its design has also been influenced by Oberon, Rust, Swift, Kotlin, and Python.