0% found this document useful (0 votes)
9 views5 pages

Python Notes

Python is a high-level, interpreted, and object-oriented programming language known for its readability and simplicity, created by Guido Van Rossum in the late 1980s. It is widely used across various domains such as web development, AI, data science, and education, and has evolved through several versions, with Python 3 being the current standard. Key differences between Python 2 and Python 3 include changes in print syntax, string handling, and integer division.

Uploaded by

245124732305
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Python Notes

Python is a high-level, interpreted, and object-oriented programming language known for its readability and simplicity, created by Guido Van Rossum in the late 1980s. It is widely used across various domains such as web development, AI, data science, and education, and has evolved through several versions, with Python 3 being the current standard. Key differences between Python 2 and Python 3 include changes in print syntax, string handling, and integer division.

Uploaded by

245124732305
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON NOTES

CHAPTER-1
INTRODUCTION AND BASICS OF PYTHON

What is Python?
Python is a high-level, interpreted, interactive, object-oriented, dynamic, and
multi-purpose scripting language which is known for simple syntax and
readability.
i. High-level language: Easy for humans to read and write.
ii. Interpreted: Computer runs the code line by line.
iii. Interactive: We didn’t have to write the full program, we can test code
one line at a time.
iv. Object-oriented: It uses classes and objects to organize programs and
everything in python is treated as an object (numbers, strings, functions
etc.).
v. Dynamic: We don’t need to write datatypes. The same variable can store
different types of values at different times.

History of Python –
➢ The history of python starts with ABC (All Basic Codes) which is a
general-purpose programming language developed in the Netherlands.
➢ Python was created by Guido Van Rossum at Centrum Wiskunde &
Informantica (CWI) in the Netherlands in the late 1980s.
➢ Development started in December 1989 as a hobby project during
Christmas holidays.
➢ Python was influenced by languages like ABC, C, C++, Modula-3,
SmallTalk, UNIX shell and other scripting languages.
➢ The name “Python” was inspired by the British comedy Show “Monty
Python’s Flying Circus”, which Van Rossum was a big fan.

Why python is Popular?


➢ Easy to read and write.
➢ Simple syntax.
➢ Powerful libraries.
➢ Used in Web development, AI, data science, automation, education etc.
➢ Ranked as #1 language among top programming languages worldwide.

Who uses Python?


➢ Tech Companies:
• Google – backend systems, search
• YouTube – backend development
• Instagram – backend using Django
➢ Cloud & Web development:
• Google App Engine
• Netflix
• Spotify
➢ Hardware & Systems:
• Raspberry Pi
• Intel, Cisco, HP, IBM uses python for hardware testing and network
configuration.
➢ Animation & Design:
• Maya – scripting and automation
• Blender – plugins and 3D graphics
➢ Science and Education:
• NASA, JPL
• Universities like MIT, Stanford, Harvard
➢ Finance & FinTech:
• JP Morgan Chase, Goldman Sachs
• Trading Firms
➢ AI & Data Science
• OpenAI
• Meta (Facebook)
• Tesla
Applications of Python:
1. Web Development:
Popular Frameworks like Django, Flask, Pyramid are used for websites
and web applications.
2. Desktop GUI Applications:
Libraries like Tkinter, PyQT, wxPython, Kivy are used for creation of
desktop applications with graphical interfaces for multi-touch apps.
3. Scientific and Numeric Computing:
Libraries like NumPy, Pandas, SciPy, IPython are used.
4. Software Development:
Used in building and testing software. Tools like Buildbot, Apache Gump,
Trac are used.
5. Education:
Easy for beginners and used in schools and colleges.
6. Business Applications:
Used to build business software like E-Commerce systems. Tools like
Odoo, Tryton are used.
7. Game Development:
Libraries like PyGame, PySoy are used for developing games.
8. Database Access:
Python allows easy access to databases like MySQL, PostgreSQL, Oracle,
MS SQL Server.
9. Image Processing:
Libraries like OpenCV, Pillow, scikit-image are used for tasks like editing,
object detection, and face recognition.

Versions of python:
Python is regularly updated to add new features, improve performances, and
fix issues.
➢ Python 1 (Beginning stage)
• It is the first version of python which provided basic features like
variables, functions, modules and used mainly for learning and early
development.
• This series has Python 1.0 – January 1994, Python 1.5 – December
1997 and Python 1.6 – September 2000.
➢ Python 2 (Development Stage)
• This version was widely used for many years which introduced List
comprehensions and better performance. Python 2 support ended
in 2020.
• This series has Python 2.0 – October 2000, Python 2.1 – April
2001, Python 2.2 – December 2001, Python 2.3 – July 2003,
Python 2.4 – November 2004, Python 2.5 – September 2006,
Python 2.6 – October 2008 and Python 2.7 – July 2010.
➢ Python 3 (Modern Stage)
• This version is current and future version. It developed features
like simple and clean syntax, Unicode support, Faster and more
secure which can be used in Web development, AI & Data science,
and Automation.
• This series has Python 3.0 - December 2008, Python 3.1 – June
2009, Python 3.2 – February 2011, Python 3.3 – September 2012,
Python 3.4 – March 2014, Python 3.5 – September 2015, Python
3.6 – December 2016, Python 3.7 – June 2018, Python 3.8 –
October 2019, Python 3.9 – October 2020, Python 3.10 – October
2021, Python 3.11 – October 2022, Python 3.12 – October 2023,
Python 3.13 – October 2024.

Key Differences between Python2 and Python3:


1. Print Statement:
In python2 Print is a statement, e.g – print “Hello”. In python3 print
statement has replaced with function print() which requires parentheses,
e.g – print(“Hello”).
2. Handling of Strings and Bytes:
Python2 mixes text and bytes which is confusing.
e.g – s= “Hello” ->bytes
u= u”Hello” ->Unicode text
Python3 clearly separates text and data.
e.g – s=”Hello” ->Unicode text
b= b”Hello” ->bytes
3. Exception handling:
Python2 – except ZeroDivisionError, e:
Python3 – except ZeroDivisionError as e:
Only syntax changed, “as” keyword improved readability and
consistency.
4. Range function:
In python2, xrange() function is used to generate a range of numbers,
while in python3, it has been replaced by the range() function. Python3
range() is memory efficient and simpler.
5. Integer Division:
In python2 “/” and “//” operator performs integer division. In python3,
the “/” operator performs floating-point division and we use “//”
operator for integer division.
6. Unicode:
In python2, Unicode needs “u” prefix, while in python3, all strings are
Unicode by default.
7. Division of input() and raw_input():
In python2, raw_input() is used to read input from the user, while input()
performs evaluation on the input. In python3, raw_input() has removed
and the input() is used with the same functionality as raw_input() in
python2.
8. Long type:
Python2 has separate long type, e.g – x= 1234567910L, while python3
has no long type and all integers are unlimited.
9. Standard Library:
In python2, some modules are old or poorly organized. In python3, some
modules were removed or changed, so code written in python2 may not
work in python3.

Common questions

Powered by AI

Python's evolution from version 1 introduced fundamental features like basic syntax and structures, setting groundwork in early education and development. Python 2 refined these foundations with improvements in performance and capabilities such as list comprehensions and Unicode support, broadening its appeal to industries like finance and tech. Python 3's modern enhancements like refined syntax, integral Unicode support, and standardized exception handling have further cemented its role in complex domains like AI, web development, and scientific research. Each version bridged gaps and expanded the language’s applicability, reinforcing Python's adaptability and extensive use .

Python is popular due to its simple syntax, powerful libraries, and versatility. It is used extensively in web development with frameworks such as Django and Flask which streamline creating complex web applications. In AI, Python's powerful libraries like TensorFlow, PyTorch, and NumPy allow for advanced machine learning and data science applications. Its readability and ease of learning also make it accessible for both beginners and professionals, contributing to its widespread adoption across industries like finance, tech companies, and scientific research .

Python’s simple syntax and readability make it accessible for beginners, allowing students to focus on learning programming concepts without being overwhelmed by complex language rules. Its interactive shell facilitates immediate feedback and experimentation, enhancing the learning experience. In educational settings, this ease encourages early exposure to programming, which in turn translates into its adoption in professional environments where Python’s practical applications in web development, data science, and automation are highly valued, bridging the gap between learning and professional application .

Python supports scientific and numeric computing through libraries like NumPy and Pandas, which provide extensive functionality for data manipulation and analysis, crucial for scientific research. Libraries such as SciPy and IPython enhance computational capabilities, offering advanced mathematical operations and interactive computing. These tools enable researchers to handle large datasets efficiently and perform complex analyses, fostering innovations in fields like physics, biology, and environmental science. Python's practicality and efficiency in handling numerical data have made it an indispensable tool in modern scientific research .

Key distinctions between Python 2 and Python 3 include syntax changes such as the transition from print statements to print() functions, and modifications in string handling where text and bytes are distinctly separated in Python 3. These changes improve code readability and prevent type-related errors. Python 3's introduction of optimized range() and enhanced integer division '/' and '//' operators, along with native Unicode support for strings, make it more efficient and modern for software development. These improvements encourage developers to adopt current and future standards, impacting software longevity and cross-compatibility .

Python's object-oriented design allows developers to organize code into reusable and modular components through classes and objects. This structure facilitates better management and scaling of complex projects, as it enables encapsulation, inheritance, and polymorphism. These features support code reuse and improve maintenance, making Python a powerful choice for developing large-scale applications in areas like game development, desktop GUI applications, and enterprise solutions .

Python's role in web development, through frameworks like Django and Flask, allows for rapid development cycles and scalable web applications, attracting tech giants like Google and YouTube. In cloud services, Python's versatility and powerful libraries enable seamless integration with cloud infrastructures and services, as demonstrated by its use in platforms like Google App Engine. These capabilities address the dynamic needs of modern technology companies, facilitating quick iterations and reliable deployments, thus driving its widespread adoption across the industry for backend systems and service architectures .

Key factors include Python's high-level syntax that simplifies writing and maintaining scripts, and its dynamic typing which adapts to various contexts without complex type definitions. Its robust standard library and diverse ecosystem support a vast array of automation tools. Additionally, Python's integration capability with other programming languages and its framework support for hardware testing and network configuration make it highly suitable for automation in environments like those used by Intel, Cisco, and HP .

Python's design was influenced by languages such as ABC, C, and Modula-3, which focused on simplicity and readability. This heritage shaped Python into an easy-to-learn language with clear syntax, which is a crucial factor for its adoption in education and academia. The ability to use Python interactively, and its object-oriented features, opened it up to a wide range of applications from scientific computing to web development. Its influence from UNIX shell scripting and other dynamic languages made it a powerful tool for automation tasks and integrated systems .

Python's dynamic nature allows variables to change types without explicit declaration, enhancing flexibility and speeding up development time, which is particularly advantageous in rapid prototyping and scripting. This is contrasted with static languages where variable types must be declared, potentially slowing the development process. In fields like scientific computing and web development, Python's dynamic typing supports a wide range of data manipulations and integrations, accommodating rapidly changing requirements .

You might also like