0% found this document useful (0 votes)
7 views24 pages

Lab 1-Share

DD

Uploaded by

anjalipandeyms
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)
7 views24 pages

Lab 1-Share

DD

Uploaded by

anjalipandeyms
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
You are on page 1/ 24

MANAV RACHNA INTERNATIONAL INSTITUTE OF RESEARCH AND STUDIES

BCS-DS-588

DATA SCIENCE
WITH PYTHON LAB

Rashima Mahajan, Professor CSE 1


BCS-DS-588: DATA SCIENCE WITH PYTHON LAB

Course Outcomes: The students will be able to-


BCS-DS-588.1 Understand and implement the basics of programming in Python.
BCS-DS -588.2 Explain and implement the Collections in Python.
BCS-DS -588.3 Apply Object Oriented Programming concepts on various data sets.
BCS-DS -588.4 Apply the Numpy package for numerical calculations in Python.
BCS-DS -588.5 Analyze loading and preprocessing of data using Pandas.
BCS-DS -588.6 Implement various data visualization tools of Python on real world data.

Max. Marks :100 Viva- I 30%


Viva- II 30%
Continuous Evaluation : 50
File/Records 20%
End Term Examination : 50 Class Work/ Performance 20%

2
Rashima Mahajan, Professor CSE
List of Practicals:

1. Programs for basic operations in Python


2. Programs based on various control structures
3. Programs based on functions and recursion
4. Programs based on various data structures of Python like list, tuple, dictionary etc.
5. Programs based on various oops features
6. Programs based on numPy library (computation and processing of arrays)
7. Programs based on Pandas library (data analysis and manipulation)
8. Programs to work with various datasets-excel, csv, html etc
9. Programs to work with visualization using matplot (graphical plotting), Seaborn (Statistical Data
Visualization) etc
10. Small case study to handle a dataset

Rashima Mahajan, Professor CSE 3


Software Installation/ Online Cloud Based

✓ Anaconda – Runs on Local Server: It comes with a lot of packages by default, so it takes up a lot of space.

✓ Google Colab – Runs entirely On the cloud

Anaconda Repository

Rashima Mahajan, Professor CSE 4


Anaconda

Anaconda (or Anaconda Navigator) is an open-source platform that provides data science
toolkits and inbuilt packages for performing various data science tasks.

Some examples of the best python


•It provides more than 8000+ DM/ML Packages. packages for data science available on
•It is easy to use. anaconda are:
•It helps to maintain production-ready projects. •Programming Language: Python and R
•It provides tested and regularly updated packages. •Data Processing: Numpy and Pandas
•Data Visualization: Matplotlib and Seaborn
•Data Modelling: Scikit-learn and Tensorflow
•IDE: Spyder and Jupyter Notebook

Rashima Mahajan, Professor CSE 5


Anaconda----Trusted Open Source Packages

Rashima Mahajan, Professor CSE 6


Rashima Mahajan, Professor CSE 7
Rashima Mahajan, Professor CSE 8
Colab

Rashima Mahajan, Professor CSE 9


Colab, or "Colaboratory", allows users to write and execute Python in your
browser, with:
•Zero configuration required
•Access to GPUs free of charge
•Easy sharing
•Need to have a google account

Colab notebook is not a static web page, but an interactive environment


that let users write and execute code.

Rashima Mahajan, Professor CSE 10


Code Cell in Colab

Here is a code cell with a short Python script that computes a value, stores it in a variable, and
prints the result:

Rashima Mahajan, Professor CSE 11


Need to have a google account as it’s a product of google
Sign in ---google account

Rashima Mahajan, Professor CSE 12


Rashima Mahajan, Professor CSE 13
Rashima Mahajan, Professor CSE 14
Opening .ipynb file

Use open of Upload notebook

Rashima Mahajan, Professor CSE 15


Building Blocks of Python

1. Python Keywords 6. Variables

2. Identifiers 7. Data Types

3. Comments in Python 8. Conversion between Data Types

4. Python Indentation 9. Python Input/Output

5. Python Statement 10. Operators

Rashima Mahajan, Professor CSE 16


1. Programs for basic operations in Python

a. Define three variables a, b and c. Assign an value 2 to variable a, value 13.27 to variable b and value 3+2j to variable c.
Print the type of the variables.

# integer variable.
a=2
print("The type of variable having value", a, " is ", type(a))

# float variable.
b=13.27
print("The type of variable having value", b, " is ", type(b))

# complex variable.
c=3+2j
print("The type of variable having value", c, " is ", type(c))

Rashima Mahajan, Professor CSE 17


b. Create a string as string1=‘Amazing’. Print:
▪ Complete String
▪ First character of the string
▪ characters starting from 3rd to 5th
▪ string starting from 3rd character
▪ string two times
▪ Concatenate ‘Test’ with ‘Amazing’
▪ string1[-7 : -3]
▪ string1[1:6:2]
▪ string1[-7:-3:3]
▪ string1[: : -2]
▪ len(string1)

Indexing: [start: stop: step]


Start included, Stop not included as it is stop-1
Step has default value 1
18
Otherwise it will take the step of mentioned one Rashima Mahajan, Professor CSE
c. Take 2 variables a and b, assign them values 21 and 10, respectively. Print:
▪ Addition of these 2 variables a and b
▪ Subtraction
▪ Multiplication a = 21 b = 10
▪ Division # Addition
print ("a + b : ", a + b)
▪ Modulus # Subtraction
▪ Exponent print ("a - b : ", a - b)
# Multiplication
▪ Floor Division print ("a * b : ", a * b)
# Division
print ("a / b : ", a / b)
# Modulus
print ("a % b : ", a % b)
Floor division will divide the
# Exponent
first argument by the second
print ("a ** b : ", a ** b)
and round the result down to
# Floor Division
the nearest whole number
print ("a // b : ", a // b)

Rashima Mahajan, Professor CSE 19


d. Take 2 variables a and b, assign them values 4 and 5, respectively. Print output of all
comparison operators:
▪ Equal a=4b=5

▪ Not equal # Equal

▪ Greater than print ("a == b : ", a == b)

▪ Less than # Not Equal

▪ Greater than or equal to print ("a != b : ", a != b)

▪ Less than or equal to # Greater Than


print ("a > b : ", a > b)
# Less Than
print ("a < b : ", a < b)
# Greater Than or Equal to
print ("a >= b : ", a >= b)
# Less Than or Equal to
print ("a <= b : ", a <= b)
Rashima Mahajan, Professor CSE 20
d. Take 2 variables a and b, assign them values 4 and 5, respectively. Print output of all
comparison operators:
▪ Equal a=4b=5

▪ Not equal # Equal

▪ Greater than print ("a == b : ", a == b)

▪ Less than # Not Equal

▪ Greater than or equal to print ("a != b : ", a != b)

▪ Less than or equal to # Greater Than


print ("a > b : ", a > b)
# Less Than
print ("a < b : ", a < b)
# Greater Than or Equal to
print ("a >= b : ", a >= b)
# Less Than or Equal to
print ("a <= b : ", a <= b)
Rashima Mahajan, Professor CSE 21
e. Write a program to find the area of a circle:

Rashima Mahajan, Professor CSE 22


f. Write a program to find the volume of a sphere with radius 6:

Algorithm:
Step 1: Read radius ‘r’ from user
Step 2: Calculate volume = pi*r*r*r*4/3

Rashima Mahajan, Professor CSE 23


g. Write a program to convert celsius into fahrenheit:

Algorithm:
Step 1: Get the Celsius temperature from user
Step 2: Calculate Fahrenheit = (Celsius * 9/5) + 32

Rashima Mahajan, Professor CSE 24

You might also like