Python (programming language)

Python (programming language)
ParadigmMulti-paradigm: object-oriented,[1] procedural (imperative), functional, structured, reflective
Designed byGuido van Rossum
DeveloperPython Software Foundation
First appeared20 February 1991; 33 years ago (1991-02-20)[2]
Stable release3.13.1[3] Edit this on Wikidata / 3 December 2024; 28 days ago (3 December 2024)
Typing disciplineDuck, dynamic, strong typing;[4] gradual (since 3.5, but ignored in CPython)[5]
OSWindows, Linux/UNIX, macOS and more[6]
LicensePython Software Foundation License
Filename extensions.py, .pyi, .pyc, .pyd, .pyo (prior to 3.5),[7] .pyw, .pyz (since 3.5)[8]
Websitewww.python.org
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 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]

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 use

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.

Syntax

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]

Statements and control flow

Python's statements include:

  • The assignment statement, or the = sign. In Python, the statement x = 2 means that the name x is set to the integer 2. Names can be changed 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++.
  • The if statement, which runs a block of code if certain conditions are met, along with else and elif (a contraction of else if from other programming languages). The elif statement runs a block of code if the previous conditions are not met, but the conditions for the elif statement are met. The else statement runs a block of code if none of the previous conditions are met.
  • The for statement, which iterates over an iterable object such as a list and binds each element of that object to a variable to use in that block of code, which creates a for loop.
  • The while statement, which runs a block of code as long as certain conditions are met, which creates a while loop.
  • The def statement, which defines a function or method.
  • The pass statement, which means "do nothing."
  • The class statement, which allows the user to create their own type of objects like what integers and strings are.
  • The import statement, which imports Python files for use in the user's code.
  • The print statement, which outputs various things to the console.

Expressions

Python's expressions include some that are similar to other programming languages and others that are not.

  • Addition, subtraction, multiplication, and division, represented by +, -. *, and /.
  • Exponents, represented by **.
  • To compare two values, Python uses ==.
  • Python uses the words "and", "or", and "not" for its boolean expressions.
  • To check if a value is in a list, Python uses "in"

Example

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):
    return "Hello, " + name

print(greeting("Reader"))

When called, this function returns "Hello, Reader", which is then printed to the screen.

References

  1. "General Python FAQ — Python 3.9.2 documentation". docs.python.org. Archived from the original on 24 October 2012. Retrieved 2021-03-28.
  2. "Python 0.9.1 part 01/21". alt.sources archives. Archived from the original on 11 August 2021. Retrieved 2021-08-11.
  3. Thomas Wouters (3 December 2024). "Python Insider: Python 3.13.1, 3.12.8, 3.11.11, 3.10.16 and 3.9.21 are now available". Retrieved 4 December 2024.
  4. "Why is Python a dynamic language and also a strongly typed language - Python Wiki". wiki.python.org. Archived from the original on 14 March 2021. Retrieved 2021-01-27.
  5. "PEP 483 -- The Theory of Type Hints". Python.org. Archived from the original on 14 June 2020. Retrieved 14 June 2018.
  6. "Download Python". Python.org. Archived from the original on 8 August 2018. Retrieved 2021-05-24.
  7. File extension .pyo was removed in Python 3.5. See PEP 0488 Archived 1 June 2020 at the Wayback Machine
  8. Holth, Moore (30 March 2014). "PEP 0441 -- Improving Python ZIP Application Support". Archived from the original on 26 December 2018. Retrieved 12 November 2015.
  9. "Starlark Language". Archived from the original on 15 June 2020. Retrieved 25 May 2019.
  10. "Why was Python created in the first place?". General Python FAQ. Python Software Foundation. Archived from the original on 24 October 2012. Retrieved 22 March 2007.
  11. "Ada 83 Reference Manual (raise statement)". Archived from the original on 22 October 2019. Retrieved 7 January 2020.
  12. Kuchling, Andrew M. (22 December 2006). "Interview with Guido van Rossum (July 1998)". amk.ca. Archived from the original on 1 May 2007. Retrieved 12 March 2012.
  13. 13.0 13.1 "itertools — Functions creating iterators for efficient looping — Python 3.7.1 documentation". docs.python.org. Archived from the original on 14 June 2020. Retrieved 22 November 2016.
  14. van Rossum, Guido (1993). "An Introduction to Python for UNIX/C Programmers". Proceedings of the NLUUG Najaarsconferentie (Dutch UNIX Users Group). CiteSeerX 10.1.1.38.2023. even though the design of C is far from ideal, its influence on Python is considerable.
  15. 15.0 15.1 "Classes". The Python Tutorial. Python Software Foundation. Archived from the original on 23 October 2012. Retrieved 20 February 2012. It is a mixture of the class mechanisms found in C++ and Modula-3
  16. Lundh, Fredrik. "Call By Object". effbot.org. Archived from the original on 23 November 2019. Retrieved 21 November 2017. 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.
  17. Simionato, Michele. "The Python 2.3 Method Resolution Order". Python Software Foundation. Archived from the original on 20 August 2020. Retrieved 29 July 2014. 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
  18. Kuchling, A. M. "Functional Programming HOWTO". Python v2.7.2 documentation. Python Software Foundation. Archived from the original on 24 October 2012. Retrieved 9 February 2012.
  19. Schemenauer, Neil; Peters, Tim; Hetland, Magnus Lie (18 May 2001). "PEP 255 – Simple Generators". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 5 June 2020. Retrieved 9 February 2012.
  20. Smith, Kevin D.; Jewett, Jim J.; Montanaro, Skip; Baxter, Anthony (2 September 2004). "PEP 318 – Decorators for Functions and Methods". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 3 June 2020. Retrieved 24 February 2012.
  21. "More Control Flow Tools". Python 3 documentation. Python Software Foundation. Archived from the original on 4 June 2016. Retrieved 24 July 2015.
  22. "CoffeeScript". coffeescript.org. Archived from the original on 12 June 2020. Retrieved 3 July 2018.
  23. "The Genie Programming Language Tutorial". Archived from the original on 1 June 2020. Retrieved 28 February 2020.
  24. "Perl and Python influences in JavaScript". www.2ality.com. 24 February 2013. Archived from the original on 26 December 2018. Retrieved 15 May 2015.
  25. Rauschmayer, Axel. "Chapter 3: The Nature of JavaScript; Influences". O'Reilly, Speaking JavaScript. Archived from the original on 26 December 2018. Retrieved 15 May 2015.
  26. "Why We Created Julia". Julia website. February 2012. Archived from the original on 2 May 2020. Retrieved 5 June 2014. We want something as usable for general programming as Python [...]
  27. Ring Team (4 December 2017). "Ring and other languages". ring-lang.net. ring-lang. Archived from the original on 25 December 2018. Retrieved 4 December 2017.
  28. Bini, Ola (2007). Practical JRuby on Rails Web 2.0 Projects: bringing Ruby on Rails to the Java platform. Berkeley: APress. p. 3. ISBN 978-1-59059-881-8.
  29. Lattner, Chris (3 June 2014). "Chris Lattner's Homepage". Chris Lattner. Archived from the original on 25 December 2018. Retrieved 3 June 2014. 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.
  30. "V Documentation". Retrieved 13 January 2024. its design has also been influenced by Oberon, Rust, Swift, Kotlin, and Python.
  31. "Python Humor". Python.org. Retrieved 2020-09-19.
  32. "Python Coding | Data Basecamp". 2021-11-27. Retrieved 2022-08-29.
  33. Yadav, Pramod (2020-10-09). "Top 25 Python Libraries For Data Science Projects – My Programming School". My Programming School. Retrieved 2022-12-22.
  34. Sah, Rocky (2022). "How Python parses white space". Codelivly - A Way For Coders. Archived from the original on 2022-12-14.

Other websites

Read other articles:

Mexican telenovela La que no podía amarGenreTelenovelaCreated byXimena SuárezWritten by Julián Aguilar Janely Lee Vanesa Varela Story byDelia FialloDirected by Alejandro Gamboa Salvador Garcini Creative directorSandra CortésStarring Jorge Salinas José Ron Susana González Ana Brenda Contreras Theme music composerReyli BarbaOpening themeTe dejaré de amar performed by ReyliCountry of originMexicoOriginal languageSpanishNo. of episodes166ProductionExecutive producerJosé Alberto CastroProd...

 

 

Sekretaris Daerah Kabupaten Flores TimurLambang Kabupaten Flores TimurPetahanaPetrus Pedo Maransejak 22 Desember 2023GelarDrs, M.SiDibentuk19 Desember 1958Pejabat pertamaJoakim Bl. de Rosary(Pejabat Sementara)Situs webhttps://florestimurkab.go.id Sekretaris Daerah (Sekda) adalah Jabatan Pimpinan Tinggi Pratama untuk Aparatur Sipil Negara di Kabupaten Flores Timur. Dalam pelaksanaan tugas dan kewajibannya, Sekretaris Daerah bertanggungjawab kepada Bupati Flores Timur. Berikut Daftar Sekre...

 

 

Village and municipality in Slovakia Košice-okolie District in the Kosice Region Kecerovský Lipovec (Slovak pronunciation: [ˈketserɔwskiː ˈlipɔʋets]; Hungarian: Kecerlipóc) is a village and municipality in Košice-okolie District in the Kosice Region of eastern Slovakia. History In historical records, the village was first mentioned in 1229. Geography The village lies at an altitude of 350 metres and covers an area of 15.67 km². It has a population of about 110 people. ...

British TV series or programme HunterGenreCrime dramaCreated byGwyneth HughesWritten byMick FordGwyneth HughesDirected byColm McCarthyStarringHugh BonnevilleJanet McTeerNathan ConstanceAnna KovalEleanor MatsuuraJonathan SlingerGeoffrey StreatfeildHarriet WalterComposerBen BartlettCountry of originUnited KingdomOriginal languageEnglishNo. of series1No. of episodes2ProductionExecutive producersJessica PopeSimon CurtisProducerEmma BensonCinematographyDamian BromleyRunning time60 minutesProducti...

 

 

Theory in evolutionary biology This article is about signalling in evolutionary biology. For the analogous theory in economics, see signalling (economics). For the engineering concept, see signal theory. By stotting (also called pronking), a springbok (Antidorcas marsupialis) signals honestly to predators that it is young, fit, and not worth chasing. Within evolutionary biology, signalling theory is a body of theoretical work examining communication between individuals, both within species an...

 

 

† Человек прямоходящий Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеНадкласс:ЧетвероногиеКлада:АмниотыКлада:Синапсиды�...

Mochamad Nor Didik Andiono Informasi pribadiLahir0 Juli 1965 (umur 58)IndonesiaAlma materAkademi Kepolisian (1988)Karier militerPihak IndonesiaDinas/cabang Kepolisian Negara Republik IndonesiaMasa dinas1988—2023Pangkat Brigadir Jenderal PolisiNRP65070692SatuanIntelkamSunting kotak info • L • B Brigjen. Pol. (Purn.) Drs. Mochamad Nor Didik Andiono, M.H. (lahir Juli 1965) adalah seorang Purnawirawan Polri yang jabatan terakhirnya adalah Analis Kebijakan Utama Bida...

 

 

German opera company This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Hamburg State Opera – news · newspapers · books · scholar · JSTOR (September 2014) (Learn how and when to remove this message) Hamburgische StaatsoperHamburg State OperaThe Opera's front façade on Dammtorstraße in 2010Former namesHamburgi...

 

 

муниципальный районВерхнехавский район Флаг Герб 51°50′20″ с. ш. 39°56′30″ в. д.HGЯO Страна  Россия Входит в Воронежскую область Включает 17 муниципальных образований Адм. центр село Верхняя Хава Глава района Пермяков Антон Геннадьевич Глава администрации В...

Park in the Potomac River, Washington, D.C., U.S. United States historic placeEast Potomac ParkU.S. Historic districtContributing property Location14th Street, Washington Channel, Potomac River, SW Washington, D.C.Coordinates38°52′12″N 77°1′33.6″W / 38.87000°N 77.026000°W / 38.87000; -77.026000Area394.9 acres (159.8 ha)Built1917 (1917)Part ofEast and West Potomac Parks Historic District (ID73000217[1])Designated CPNovember 30, 1973 ...

 

 

Online magazine focusing on science, technology, news, culture, and politics QuilletteEditor-in-chiefClaire LehmannSenior editor, LondonJamie PalmerCanadian editor, TorontoJonathan KayCategoriesPoliticsculturesciencetechnology[1]FounderClaire LehmannFounded2015; 9 years ago (2015)CountryAustraliaBased inSydneyLanguageEnglishWebsitequillette.com Quillette (/kwɪˈlɛt/) is an online magazine founded by Australian journalist Claire Lehmann. The magazine primarily focus...

 

 

Pour les articles homonymes, voir Gargan. Ne doit pas être confondu avec Gargano. Cet article est une ébauche concernant la Haute-Vienne et la montagne. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Mont Gargan Vue du mont Gargan depuis la tour de Masseret. Géographie Altitude 730 m[1] Massif Plateau de Millevaches(Massif central) Coordonnées 45° 37′ 14″ nord, 1° 38′ 5...

American singer (1926–2023) This article is about the American singer. For other people with the same name, see Tony Bennett (disambiguation). Tony BennettBennett in the 1960sBornAnthony Dominick Benedetto(1926-08-03)August 3, 1926New York City, U.S.DiedJuly 21, 2023(2023-07-21) (aged 96)New York City, U.S.Resting placeCalvary Cemetery, Queens, New York CityOccupations Singer painter Years active1936–2021Spouses Patricia Beech ​ ​(m. 1952; div.&#...

 

 

Lake in Kazakhstan For the lake in Pavlodar Region, see Tuzkol, Bayanaul District. TuzkolТұзкөлView of the lakeTuzkolLocationKegen DepressionCoordinates43°00′N 79°58′E / 43.000°N 79.967°E / 43.000; 79.967Typesalt lakeBasin countriesKazakhstanMax. length5.7 kilometers (3.5 mi)Max. width2.1 kilometers (1.3 mi)Surface area6.6 square kilometers (2.5 sq mi)Max. depth3 meters (9.8 ft)Residence timeUTC+6Shore length116.6 kilome...

 

 

2020年夏季奥林匹克运动会波兰代表團波兰国旗IOC編碼POLNOC波蘭奧林匹克委員會網站olimpijski.pl(英文)(波兰文)2020年夏季奥林匹克运动会(東京)2021年7月23日至8月8日(受2019冠状病毒病疫情影响推迟,但仍保留原定名称)運動員206參賽項目24个大项旗手开幕式:帕维尔·科热尼奥夫斯基(游泳)和马娅·沃什乔夫斯卡(自行车)[1]闭幕式:卡罗利娜·纳亚(皮划艇)&#...

For other people named Robert Foulis, see Robert Foulis (disambiguation). Robert FoulisBorn20 April 1707Glasgow, Scotland, Great BritainDied2 June 1776(1776-06-02) (aged 69)Glasgow, Scotland, Great BritainBurial placeGlasgow, Scotland, United Kingdom Robert Foulis (20 April 1707 – 2 June 1776) was a Scottish printer and publisher. Spartan Lessons; Glasgow: Robert and Andrew Foulis, 1759 (title-page) Biography Publishing Robert Foulis was born the son of a maltman. He was apprenticed to...

 

 

John Augustus ConollyDepiction of the Siege of SebastopolBorn30 May 1829Celbridge, County KildareDied23 December 1888 (aged 59)Curragh, County KildareBuriedMount Jerome Cemetery, DublinAllegiance United KingdomService/branch British ArmyRankLieutenant ColonelUnit49th Regiment of FootColdstream GuardsBattles/warsCrimean WarAwardsVictoria Cross Lieutenant Colonel John Augustus Conolly VC (30 May 1829 – 23 December 1888), born in Celbridge, County Kildare, Ireland, was an Irish recipient...

 

 

Mike Levin Michael Ted Levin (lahir 20 Oktober 1978) adalah seorang politikus Amerika Serikat yang menjabat sebagai anggota DPR sejak 2019. Ia berasal dari Partai Demokrat. Pranala luar Wikimedia Commons memiliki media mengenai Mike Levin. Congressman Mike Levin official U.S. House website Mike Levin for Congress campaign website Biografi di Biographical Directory of the United States Congress Catatan suara dikelola oleh The Washington Post Biografi, catatan suara, dan penilaian kelompok kepe...

This article may require copy editing for grammar, style, cohesion, tone, or spelling. You can assist by editing it. (October 2023) (Learn how and when to remove this message) Religion in Turkey Secularism in Turkey Islam in Turkey Sunni Islam(Hanafi, Shafi'i) Shia Islam(Alevi, Ja'fari, Nusayri) Sufism(Bektashi, Mawlawi, Naqshbandi, Qadiri) Nondenominational Muslim Christianity in Turkey Eastern(Armenian Orthodox, Greek Orthodox, Syriac Orthodox, Turkish Orthodox) Catholic(Latin Catholic, Gr...

 

 

Православний літургійний календар Ґрунтується на Юліанський календар і Новоюліанський календар Календарі Базові поняття Час Минуле Сьогодення Майбутнє Вічність Доба Тиждень Місяць Рік зоряний календарний тропічний Десятиліття Століття Тисячоліття Ера Інтерка�...