0% found this document useful (0 votes)
4 views8 pages

Introduction to Python for Data Science

The document serves as supplementary learning material for a Python for Data Science course, covering the basics of Python programming, its features, and installation of Anaconda Navigator. It highlights Python's ease of use, versatility, and its applications in various fields, including web development and data science. Additionally, it provides instructions on launching Jupyter Notebook and using its features, including different cell types and keyboard shortcuts.

Uploaded by

saad.sheriff20
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)
4 views8 pages

Introduction to Python for Data Science

The document serves as supplementary learning material for a Python for Data Science course, covering the basics of Python programming, its features, and installation of Anaconda Navigator. It highlights Python's ease of use, versatility, and its applications in various fields, including web development and data science. Additionally, it provides instructions on launching Jupyter Notebook and using its features, including different cell types and keyboard shortcuts.

Uploaded by

saad.sheriff20
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

Supplementary Learning Material

saadsheriff1895@[Link]
J732KOTCSB

Program: MCA
Specialization: Data Science
Semester: 2
Course Name: Python for Data Science
Course Code: 21VMT5S204
Unit Name: Introduction to Python

Proprietary content. All rights reserved. Unauthorized use or distribution prohibited.

This file is meant for personal use by saadsheriff1895@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Unit 1
INTRODUCTION TO PYTHON
Overview:
Python is used for general purpose programming. It is easy to use and understand. It can be
used on a variety of operating systems. It forms a gateway into the realm of programming. A
lot of start-ups and small businesses use python since it is free of cost and any product is
easy to build with lesser codes. Time management is better with python. The scope of
python is ever increasing, and it becomes important to know the subject when one chooses
to delve into web development or data science.

Learning outcomes:
 Knowing about python
 Features of python
 Installing Anaconda Navigator
 Launching Jupyter notebook
 Basics about Jupyter notebook

saadsheriff1895@[Link]
J732KOTCSB
What happens to be amongst the most in-demand programming languages was in-fact
started as a hobby by its creator Guido Van Rossum to keep him occupied during Christmas.
Today, almost all big companies use python for their services in some way or the other.
Amongst the renowned ones are Google, Pinterest, Netflix, Quora, etc.
First things first, what is Python?
Python is a programming language, just like C, C++ and Java. It is a scripting language. It is a
Object-oriented- this means that its paradigm is based on ‘objects’ and ‘classes’. Python is
dynamically typed, meaning, the interpreter gives the variable a type during runtime based
on its value and it does type checking during the same.

Features of Python:
Python has various features, major ones of which are:

 Easy to understand: The python code is easy to understand because the syntax is
uncomplicated and in English. Python does not use braces for different functions, it
uses indentation which makes the code look clean and neat, thus making it readable.
 High-level language: a high level programming language is that which is user-friendly
and resembles natural human language.
 It is an interpreted language: The python code is executed one line at a time unlike
C++ which is executed all at once. The interpreter displays the output one line at

Proprietary content. All rights reserved. Unauthorized use or distribution prohibited.

This file is meant for personal use by saadsheriff1895@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
once, which means that if there is any error, unless the error is resolved, the code
will not be executed any further.
 Object-oriented program: as mentioned before, an OOP means that python treats it
as an object.
 Open-source: Python is an open source programming language. It’s codes are freely
available for usage. It is an interpreted language that can be used by anybody for any
purpose.
 Platform-independent: Python can be run on platform such as Windows, Linux, Mac.
The code for a program on each of these platforms will be the same.
 Extensible and embeddable: One can run codes from other languages on Python,
which makes it an extensible programming language and the other way around- they
can also run python codes on C++, Java or any other programming language. Hence,
it is also embeddable.
 Large Standard Library: Python has a collection of modules that make it easy for
people to code in it. Modules are sets of code that are pre-written so that one
doesn’t have to re-write commonly used commands every time. Modules can be
used by importing them.
A python file is saved with a .py extension. It is easy, fast and efficient. It has a wide range of
applications some of which are web development, scripting, data science, prototyping and
programming a database. All of python’s features like simplicity, easy of use, flexibility,
portability, development speed and programmer friendliness puts its use above other
saadsheriff1895@[Link]
J732KOTCSBprogramming languages’.

Python IDEs
 What is an IDE?
Integrated Development Environment, in easy words, allows programmers to combine
various parts of a program in a single GUI based application. An IDE ideally constitutes of a
source code editor, build automation tools and debugger. There are some IDEs that are
multi-language, like Eclipse and Visual Studio. IDEs are easy to setup, they make
development faster and easier, thus, saving efforts. IDEs also help correct errors and show
where the code is wrong.
In Python, the most frequently used IDEs include Spyder, Jupyter, PyCharm, IDLE and Atom.
For the course, we will be using Jupyter, which is part of the Anaconda distribution.

 Anaconda Distribution:
Anaconda distribution is a Python and R data science distribution. It is easy to download and
is open source. It has over 7500 packages. A package is a collection of modules. All of it
freely available and Anaconda also provides community support which is available for all
python related queries one has.
Steps to Install Anaconda:

Proprietary content. All rights reserved. Unauthorized use or distribution prohibited.

This file is meant for personal use by saadsheriff1895@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
 Go to the anaconda website. [Link]

On the website, click on download for your respective operating system (i.e., Windows,
Mac, Linux)

 The site should give you a prompt to save the file, select the location where you
saadsheriff1895@[Link]
J732KOTCSB want to place the file.
 Once downloaded, open it. You should see a prompt like this. Click on next.

 Click on ‘I agree’ and do not change any settings/presets that are there. Click on
Next. Specify a destination on the computer. Click Next and it should start the
installation. Once done, click on Next.

Proprietary content. All rights reserved. Unauthorized use or distribution prohibited.

This file is meant for personal use by saadsheriff1895@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
 Click on Next once again. And click on Finish.

saadsheriff1895@[Link]
J732KOTCSB

Once you are done downloading the Anaconda Navigator, you will be redirected to a
website. For tutorials you can glance over the website and explore.

LAUNCHING A JUPYTER NOTEBOOK


 Go on your search bar, and search for the Anaconda Navigator you just downloaded.
It takes a while to open.
 You must see a screen like this:

Proprietary content. All rights reserved. Unauthorized use or distribution prohibited.

This file is meant for personal use by saadsheriff1895@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
These are some of the applications that are part of the Anaconda distribution by default.

 Go to Jupyter Notebook and click on Launch.


 You should be redirected to a website

saadsheriff1895@[Link]
J732KOTCSB

The site’s URL is [Link]

The ‘8888’ part in the URL might change if another notebook is open in the background.
The files shown on the page are ones that are there on your computer

 To open a Jupyter notebook:

Go to New, click on ‘Python 3’ under the Notebook tab.


Once you click Python 3, another tab opens and you can see the Notebook window.

Proprietary content. All rights reserved. Unauthorized use or distribution prohibited.

This file is meant for personal use by saadsheriff1895@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Parts of the notebook window:
 ‘Untitled1’ here is the name of the notebook, you can edit it by double clicking on it
or saving the notebook.
 The checkpoint shows the last time changes were made and saved on the notebook.
 The menu bar is one directly below it, the pane which begins with File. All of those
tabs are used to make changes in the way the notebook works.
saadsheriff1895@[Link]
J732KOTCSB  The Toolbar lies below the Menu bar. It gives icons to select most used operations by
simply clicking on them, such as new notebook for the ‘+’, Run to run the cell, etc.
 The kernel shows the type of kernel the current notebook uses (i.e. here, Python 3).

There are three types of cells in the Jupyter notebook, namely, Code,
Markdown, and Raw Cells.
 The Code cells are used to write the code and program. It has to be properly
indented and must have clear syntax.
 The Markdown cells are used to document what you write, it is descriptive text.
 Raw cells are a place where you can write the output directly. These cells are not
evaluated. They are like comments.
Every cell is a Code cell by default. One can change its type by the drop down on the
Toolbar.

Proprietary content. All rights reserved. Unauthorized use or distribution prohibited.

This file is meant for personal use by saadsheriff1895@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.
Code cell when executed, gives the solution as above. Markdown cell when executed
appears as a note/text.

SHORTCUTS
Operation Shortcut Key
Run Ctrl + Enter
Create a new cell Shift + M
Copy a cell c
Paste cell Shift + v
Delete cell Double click ‘d’
Change type of Cell to: Code Y
Change type of Cell to: Markdown M
Change type of Cell to: Raw Cell R
Save (edit checkpoint) Ctrl + S

saadsheriff1895@[Link]
J732KOTCSB

Proprietary content. All rights reserved. Unauthorized use or distribution prohibited.

This file is meant for personal use by saadsheriff1895@[Link] only.


Sharing or publishing the contents in part or full is liable for legal action.

Common questions

Powered by AI

Python is known for being easy to understand with a simple syntax that uses indentation instead of braces, enhancing readability . It is a high-level, object-oriented, open-source language, making it user-friendly and freely available . Python's platform independence ensures that the same code works on different operating systems like Windows, Linux, and Mac . Its extensibility and embeddability allow integration with other programming languages . The large standard library and support for modules and packages facilitate efficient coding practices, which are crucial in data science and web development for leveraging pre-written code .

Anaconda enhances Python experiences by providing an open-source distribution specifically geared towards data science, including over 7500 packages . It supports the Jupyter Notebook, which allows for interactive computing and is ideal for data analysis and visualization . Anaconda simplifies package management and deployment, which are critical in data science where various libraries need to interoperate seamlessly. It also integrates a suite of IDEs like Spyder and Jupyter, providing a robust ecosystem for developing data science applications . Additionally, Anaconda offers community support, helping users resolve issues efficiently .

Jupyter Notebook is advantageous for Python programming because it supports an interactive mode of writing and executing code with its interface, which combines code execution with visualization in a single document . Its ability to use different cell types, such as Code, Markdown, and Raw cells, allows users to incorporate narrative text, code, and unprocessed data in one place, promoting clear communication and documentation . This feature set is valuable for collaboration as teams can share notebooks with both explanations and code, facilitating peer review and knowledge sharing. Additionally, Jupyter's integration with platforms like Anaconda enhances its utility as a collaborative tool by providing a streamlined environment for running and sharing Python code .

To set up and launch a Jupyter Notebook using Anaconda, first download and install the Anaconda distribution from its website by following the prompts for your operating system . After installation, search for and open Anaconda Navigator . From the Navigator interface, select Jupyter Notebook and click Launch, which will open a new tab in your default web browser . Jupyter Notebooks are essential for Python programmers in data science as they enable interactive computing and offer an integrated environment for writing, testing, and visualizing Python code alongside narrative text and visualizations . This integration is crucial for iterative data analysis, making them invaluable tools in data science workflows .

Python's object-oriented nature structures code into objects and classes, which enables other programming languages to interface with Python code easily through managed and well-defined interfaces . This paradigm supports encapsulation, which can expose specific functionalities to other languages while keeping internal implementations hidden. This organization allows for easy extension and embedding because the Python API can interact with external systems with minimal complexity . The modular architecture of Python's object-oriented features simplifies integration with languages like C++ or Java, facilitating machine communication and code segmentation across different programming environments .

Python's open-source nature lowers the barriers to adoption in tech companies by eliminating licensing costs and enabling unrestricted access to its codebase for modification and redistribution . This open access encourages widespread use and contributions from developers across the globe, leading to a robust community and extensive libraries and frameworks. Companies find value in the customizability and innovation facilitated by open-source projects, which can be tailored to specific organizational needs. Moreover, the open-source model fosters collaboration both within companies and in the broader tech ecosystem, promoting innovation and rapid development cycles essential in the fast-paced tech industry .

Python is considered a high-level language because it abstracts the complexity of machine language, resembling more closely the natural human languages in its syntax and usability . This abstraction allows programmers to write complex functions without needing to manage memory or understand the lower-level details of the CPU. The benefits include improved development speed, as programmers can solve problems more directly and intuitively without dealing with intricate hardware details. Additionally, Python's high-level nature promotes readability and maintainability of code, which enhances collaboration and longevity of codebases across diverse teams and projects .

Because Python is an interpreted language, it executes code line by line and will stop execution if it encounters an error . This mechanism allows for real-time error detection and helps in debugging by identifying issues in specific lines of code without needing to recompile the entire program. This feature is particularly beneficial during development as it allows developers to identify and fix errors quickly, leading to more efficient coding and testing cycles .

Python's large standard library is a significant asset for developers as it provides a wide array of pre-coded solutions for common tasks, reducing the need to write basic functionalities from scratch . This extensive library supports diverse fields such as data analytics, web development, and artificial intelligence by offering modules designed for specific requirements. It enhances development efficiency by minimizing coding time, and accelerates time-to-market for products. The pre-integrated modules also improve code reliability since they have been tested and optimized by the community. Overall, the library's capabilities enable developers to focus on creating new, value-added functionalities rather than re-implementing existing ones, leading to more innovative developments .

Jupyter Notebook includes shortcuts that enhance productivity by speeding up common tasks. For example, 'Ctrl + Enter' runs the current cell, enabling fast testing and modification of code . 'Shift + M' creates a new cell, which simplifies organization while coding . Copying and pasting cells with 'c' and 'Shift + v', respectively, ease the duplication of code snippets . Deleting a cell is quick with a double 'd' key press, allowing for easy removal of unnecessary parts . Changing cell types between Code ('Y'), Markdown ('M'), and Raw Cells ('R') is done with single keystrokes, streamlining documentation and code display in the notebook . These shortcuts allow developers to focus more on coding and less on navigation, thereby enhancing development speed and efficiency.

You might also like