GE8161 PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY Manual
Notes
71 Pages
YB
Contributed by
Yash Baria
Loading
- 1INTRODUCTIONTOPYTHON PROGRAMMINGDownloaded from: annauniversityedu.blogspot.com
Page 1
- 2strelseExpt: 1Date:INTRODUCTION TO PYTHONHistory of PythonThe programming language Python was conceived in the late 1980s, and its implementation was started inDecember 1989 by Guido van Rossum at CWI in the Netherlands as a successor to the ABC(programming language) capable of exception handling and interfacing with the Amoeba operatingsystem. Van Rossum is Python's principal author, and his continuing central role in deciding the directionof Python is reflected in the title given to him by the Python community, Benevolent Dictator for Life(BDFL). Python was named for the BBC TV show Monty Python's Flying Circus.Python 2.0 was released on October 16, 2000, with many major new features, including a cycle- detectinggarbage collector (in addition to reference counting) for memory management and support for Unicode.However, the most important change was to the development process itself, with a shift to a moretransparent and community-backed process.Python 3.0, a major, backwards-incompatible release, was released on December 3, 2008 after a longperiod of testing. Many of its major features have also been backported to the backwards- compatiblePython 2.6 and 2.7.Early historyIn February 1991, van Rossum published the code (labeled version 0.9.0) to alt.sources.Already present atthis stage in development were classes with inheritance, exception handling, functions,and the core datatypes of list , dict , and so on. Also in this initial release was a modulesystem borrowed from Modula-3; Van Rossum describes the module as "one of Python's major programmingunits".[1]Python's exception model also resembles Modula-3's, with the addition ofan clause.[3]In 1994 comp.lang.python, the primary discussion forum for Python, wasformed, marking a milestone in the growth of Python's userbase.VersionDownloaded from: annauniversityedu.blogspot.com
Page 2
- 3filterPython reached version 1.0 in January 1994. The major new features included in this releasewere the functional programming tools lambda , map , and reduce . Van Rossum statedthat "Python acquired lambda, reduce(), filter() and map(), courtesy of a Lisp hacker who missed themand submitted working patches".The last version released while Van Rossum was at CWI was Python 1.2. In 1995, Van Rossum continuedhis work on Python at the Corporation for National Research Initiatives(CNRI) in Reston, Virginiawhence he released several versions.By version 1.4, Python had acquired several new features. Notable among these are the Modula- 3inspired keyword arguments (which are also similar to Common Lisp's keyword arguments) and built-insupport for complex numbers. Also included is a basic form of data hiding by name mangling, though thisis easily bypassed.During Van Rossum's stay at CNRI, he launched the Computer Programming for Everybody (CP4E)initiative, intending to make programming more accessible to more people, with a basic "literacy" inprogramming languages, similar to the basic English literacy and mathematics skills required by mostemployers. Python served a central role in this: because of its focus on clean syntax, it was alreadysuitable, and CP4E's goals bore similarities to its predecessor, ABC. The project was funded by DARPA.As of 2007, the CP4E project is inactive, and while Python attempts to be easily learnable and not tooarcane in its syntax and semantics, reaching out to non-programmers is not an active concern.BeOpenIn 2000, the Python core development team moved to BeOpen.com to form the BeOpenPythonLabs team. CNRI requested that a version 1.6 be released, summarizing Python's development upto the point at which the development team left CNRI. Consequently, the release schedules for 1.6 and 2.0had a significant amount of overlap. Python 2.0 was the only release from BeOpen.com. After Python 2.0was released by BeOpen.com, Guido van Rossum and the other PythonLabs developers joined DigitalCreations.The Python 1.6 release included a new CNRI license that was substantially longer than the CWI licensethat had been used for earlier releases. The new license included a clause stating that theDownloaded from: annauniversityedu.blogspot.com
Page 3
- 4license was governed by the laws of the State of Virginia. The Free Software Foundation argued that thechoice-of-law clause was incompatible with the GNU General Public License. BeOpen, CNRI and theFSF negotiated a change to Python's free software license that would make it GPL-compatible. Python1.6.1 is essentially the same as Python 1.6, with a few minor bug fixes, and with the new GPL-compatiblelicenseVersion 2Python 2.0 introduced list comprehensions, a feature borrowed from the functional programminglanguages SETL and Haskell. Python's syntax for this construct is very similar to Haskell's, apart fromHaskell's preference for punctuation characters and Python's preference for alphabetic keywords. Python2.0 also introduced a garbage collection system capable of collecting reference cycles.Python 2.1 was close to Python 1.6.1, as well as Python 2.0. Its license was renamed Python SoftwareFoundation License. All code, documentation and specifications added, from the time of Python 2.1'salpha release on, is owned by the Python Software Foundation (PSF), a non- profit organization formed in2001, modeled after the Apache Software Foundation. The release included a change to the languagespecification to support nested scopes, like other statically scoped languages. (The feature was turned offby default, and not required, until Python 2.2.)A major innovation in Python 2.2 was the unification of Python's types (types written in C) and classes(types written in Python) into one hierarchy. This single unification made Python's object model purelyand consistently object oriented. Also added were generators which were inspired by Icon.Python 2.6 was released to coincide with Python 3.0, and included some features from that release, aswell as a "warnings" mode that highlighted the use of features that were removed in Python 3.0.Similarly,Python 2.7 coincided with and included features from Python 3.1,which was released on June 26, 2009.Parallel 2.x and 3.x releases then ceased, and Python 2.7 was the last release in the 2.x series. InNovember 2014, it was announced that Python 2.7 would be supported until 2020, but users wereencouraged to move to Python 3 as soon as possible.Version 3Downloaded from: annauniversityedu.blogspot.com
Page 4
- 5Python 3.0 (also called "Python 3000" or "Py3K") was released on December 3, 2008.It was designed torectify fundamental design flaws in the language—the changes required could not be implemented whileretaining full backwards compatibility with the 2.x series, which necessitated a new major versionnumber. The guiding principle of Python 3 was: "reduce feature duplication by removing old ways ofdoing things".Python 3.0 was developed with the same philosophy as in prior versions. However, as Python hadaccumulated new and redundant ways to program the same task, Python 3.0 had an emphasis on removingduplicative constructs and modules, in keeping with "There should be one— and preferably only one —obvious way to do it".Nonetheless, Python 3.0 remained a multi-paradigm language. Coders still had options among object-orientation, structured programming, functional programming and other paradigms, but within such broadchoices, the details were intended to be more obvious in Python 3.0 than they were in Python 2.x.CompatibilityPython 3.0 broke backward compatibility, and much Python 2 code does not run unmodified on Python 3.Python's dynamic typing combined with the plans to change the semantics of certain methods ofdictionaries, for example, made perfect mechanical translation from Python 2.x to Python 3.0 verydifficult. A tool called "2to3" does the parts of translation that can be done automatically. At this, 2to3appeared to be fairly successful, though an early review noted that there were aspects of translation thatsuch a tool would never be able to handle.Prior to the roll- out of Python 3, projects requiringcompatibility with both the 2.x and 3.x series were recommended to have one source (for the 2.x series),and produce releases for the Python 3.x platform using 2to3. Edits to the Python 3.x code werediscouraged for so long as the code needed to run on Python 2.x.This is no longer recommended; as of2012 the preferred alternative is to create a single code base that can run under both Python 2 and 3 usingcompatibility modules.Features of Pythona) SimpleDownloaded from: annauniversityedu.blogspot.com
Page 5
- 6Python is a simple and minimalistic language. Reading a good Python program feels almost like readingEnglish (but very strict English!). This pseudo-code nature of Python is one of its greatest strengths. Itallows you to concentrate on the solution to the problem rather than the syntax i.e. the language itself.b) Easy to LearnAs you will see, Python is extremely easy to get started with. Python has an extraordinarily simple syntaxas already mentioned.c) Free and Open SourcePython is an example of a FLOSS (Free/Libre and Open Source Software). In simple terms, you canfreely distribute copies of this software, read the software's source code, make changes to it, use pieces ofit in new free programs, and that you know you can do these things. FLOSS is based on the concept of acommunity which shares knowledge. This is one of the reasons why Python is so good - it has beencreated and improved by a community who just want to see a better Python.d) High-level LanguageWhen you write programs in Python, you never need to bother about low-level details such as managingthe memory used by your program.e) PortableDue to its open-source nature, Python has been ported (i.e. changed to make it work on) to many manyplatforms. All your Python programs will work on any of these platforms without requiring any changesat all. However, you must be careful enough to avoid any system- dependent features.You can use Python on Linux, Windows, Macintosh, Solaris, OS/2, Amiga, AROS, AS/400, BeOS,OS/390, z/OS, Palm OS, QNX, VMS, Psion, Acorn RISC OS, VxWorks, PlayStation, Sharp Zaurus,Windows CE and PocketPC !Downloaded from: annauniversityedu.blogspot.com
Page 6
- 7f) InterpretedThis requires a little explanation.A program written in a compiled language like C or C++ is translated from the source languagei.e. C/C++ into a language spoken by your computer (binary code i.e. 0s and 1s) using a compiler withvarious flags and options. When you run the program, the linker/loader software just stores the binarycode in the computer's memory and starts executing from the first instruction in the program.When you use an interpreted language like Python, there is no separate compilation and execution steps.You just run the program from the source code. Internally, Python converts the source code into anintermediate form called bytecodes and then translates this into the native language of your specificcomputer and then runs it. All this makes using Python so much easier. You just run your programs - younever have to worry about linking and loading with libraries, etc. They are also more portable this waybecause you can just copy your Python program into another system of any kind and it just works!g) Object OrientedPython supports procedure-oriented programming as well as object-oriented programming. Inprocedure-oriented languages, the program is built around procedures or functions which are nothing butreusable pieces of programs. In object-oriented languages, the program is built around objects whichcombine data and functionality. Python has a very powerful but simple way of doing object-orientedprogramming, especially, when compared to languages like C++ or Java.h) ExtensibleIf you need a critical piece of code to run very fast, you can achieve this by writing that piece of code inC, and then combine that with your Python program.Downloaded from: annauniversityedu.blogspot.com
Page 7
- 8i) EmbeddableYou can embed Python within your C/C++ program to give scripting capabilities for your program'susers.j) Extensive LibrariesThe Python Standard Library is huge indeed. It can help you do various things involving regularexpressions, documentation generation, unit testing, threading, databases, web browsers, CGI, ftp, email,XML, XML-RPC, HTML, WAV files, cryptography, GUI(graphical user interfaces) using Tk, and alsoother system-dependent stuff. Remember, all this is always available wherever Python is installed. This iscalled the "batteries included" philosophy of Python.Besides the standard library, there are various other high-quality libraries such as the Python ImagingLibrary which is an amazingly simple image manipulation library.Version release datesRelease dates for the major and minor versions:Python 1.0 - January 1994Python 1.5 - December 31, 1997Python 1.6 - September 5, 2000Python 2.0 - October 16, 2000Python 2.1 - April 17, 2001Python 2.2 - December 21, 2001Python 2.3 - July 29, 2003Python 2.4 - November 30, 2004Python 2.5 - September 19, 2006Python 2.6 - October 1, 2008Python 2.7 - July 3, 2010Downloaded from: annauniversityedu.blogspot.com
Page 8
- Python 3.0 - December 3, 2008Python 3.1 - June 27, 2009Python 3.2 - February 20, 2011Python 3.3 - September 29, 2012Python 3.4 - March 16, 2014Python 3.5 - September 13, 2015Python 3.6 - December 23, 2016Python is a widely used high-level programming language for general-purpose programming, createdby Guido van Rossum and first released in 1991.Python is a general purpose programming language created in the late 1980s, and named after MontyPython, that's used by thousands of people to do things from testing microchips at Intel, to poweringInstagram, to building video games with the PyGame library.Python is a programming language. It's used for many different applications. It's used in some highschools and colleges as an introductory programming language because Python is easy to learn, but it'salso used by professional software developers at places such as Google, NASA, and Lucasfilm Ltd.When he began implementing Python, Guido van Rossum was also reading the published scripts from“Monty Python's Flying Circus”, a BBC comedy series from the 1970s. Van Rossum thought he neededa name that was short, unique, and slightly mysterious, so he decided to call the language Python.The Python programming language was conceived in the late 1980s, and its implementation was startedin December 1989 by Guido van Rossum at CWI in the Netherlands as a successor to the ABCprogramming language capable of exception handling and interfacing with the Amoeba operating system.Python on a Macintosh running Mac OS X is in principle very similar to Python on any other Unixplatform, but there are a number of additional features such as the IDE and the Package Manager that areworth pointing out. The Mac-specific modules are documented in Mac OS X specific services.9Downloaded from: annauniversityedu.blogspot.com
Page 9
- 10Python is a high-level programming language designed to be easy to read and simple to implement. It isopen source, which means it is free to use, even for commercial applications. Python is considered ascripting language, like Ruby or Perl and is often used for creating Web applications and dynamic WebcontentPython is a widely used high-level programming language for general-purpose programming, created byGuido van Rossum and first released in 1991. CPython, the reference implementation of Python, is opensource software and has a community-based development model, as do nearly all of its variantimplementationsPython is used in GIS programming. It is used as a scripting language for ArcGIS, and for Quantum GIS.Python is true general purpose language. Your question is kind of like asking, what area should you focuson if you want C++ job or Java job.Learning Python is really easy, a breeze if you've learned other object oriented programming languages.... It's recommended to be the first language people learn as it contains all the OO concepts but is easierto read and less strongly typed as C++ or to a lesser extent Java.Apart from Windows, Linux and MacOS, CPython implementation runs on 21 different platforms.IronPython is a .NET framework based Python implementation and it is cabable of running in bothWindows, Linux and in other environments where .NET framework is available.Python is, or can be used as the scripting language in these software products:Abaqus (Finite Element Software)Advantage Framework.Amarok.ArcGIS, a prominent GIS platform, allows extensive modeling using Python.Autodesk Maya, professional 3D modeler allows Python scripting as an alternative to MEL as of version8.5.Downloaded from: annauniversityedu.blogspot.com
Page 10
Download this file to view remaining 61 pages
Related documents:
- Literary Criticism Question bank with Answers - Question Bank
- American History (1776-1945) - MCQ
- HISTORY I 2019 question paper - Question Paper
- Business Law MCQs with Answers - MCQ
- Electromagnetic Waves Notes and MCQs - Notes
- ELE-SSAC-364 (Model Answer 2021-22)
- QP-IFSM-23-ZOOLOGY-PAPER-I - Question Paper
- QP IFSM-23 MECHANICAL ENGINEERING PAPER-II - MCQ
- GE6075 – Professional Ethics Engineering qbank jeppiaar - Question Bank
- INTERNATIONAL FINANCIAL REPORTING STANDARDS - INTERNATIONAL FINANCIAL REPORTING STANDARDS - Notes
- Management Concepts Practices (Syllabus) - Notes
- Business Analytics using R Programming MCQs - MCQ
- Digital Electronics MCQs - MCQ
- MA6351 Transforms and Partial Differential Equations QBank Jeppiaar - Question Bank
- RURAL AND TRIBAL DEVELOPMENT ADMINISTRATION MCQs with ansers - MCQ
- Political Science and International Relations (Paper II) 2019 Question Paper - MCQ
- GE6075 PROFESSIONAL ETHICS IN ENGINEERING qbank - Question Bank
- Chemistry (Paper I) 2017 Question Paper - Question Paper
- QP IFSM-23 GENERAL ENGLISH - Question Paper
- GEOGRAPHY-PAPER-I (2018) - Question Paper