PDS Exp 1 To 3
PDS Exp 1 To 3
B.E. Semester 5
(Computer Engineering)
Certificate
Place: __________
Date: __________
Preface
Main motto of any laboratory/practical/field work is for enhancing required skills as well as
creating ability amongst students to solve real time problem by developing relevant competencies
in psychomotor domain. By keeping in view, GTU has designed competency focused outcome-
based curriculum for engineering degree programs where sufficient weightage is given to
practical work. It shows importance of enhancement of skills amongst the students and it pays
attention to utilize every second of time allotted for practical amongst students, instructors and
faculty members to achieve relevant outcomes by performing the experiments rather than having
merely study type experiments. It is must for effective implementation of competency focused
outcome-based curriculum that every practical is keenly designed to serve as a tool to develop
and enhance relevant competency required by the various industry among every student. These
psychomotor skills are very difficult to develop through traditional chalk and board content
delivery method in the classroom. Accordingly, this lab manual is designed to focus on the
industry defined relevant outcomes, rather than old practice of conducting practical to prove
concept and theory.
By using this lab manual students can go through the relevant theory and procedure in advance
before the actual performance which creates an interest and students can have basic idea prior to
performance. This in turn enhances pre-determined outcomes amongst students. Each experiment
in this manual begins with competency, industry relevant skills, course outcomes as well as
practical outcomes (objectives). The students will also achieve safety and necessary precautions
to be taken while performing practical.
This manual also provides guidelines to faculty members to facilitate student centric lab activities
through each experiment by arranging and managing necessary resources in order that the
students follow the procedures with required safety and necessary precautions to achieve the
outcomes. It also gives an idea that how students will be assessed by providing rubrics.
Data Science is about data gathering, analysis and decision-making. Data Science is about finding
patterns in data, through analysis, and make future predictions. By using Data Science, companies
are able to make:
Data Science is used in many industries in the world today, e.g. banking, consultancy, healthcare,
and manufacturing. Python is an open-source, interpreted, high-level language and provides a
great approach to data science, machine learning, and research purposes. It is one of the best
languages for data science to use for various applications & projects. When it comes to dealing
with mathematical, statistical, and scientific functions, Python has great utility.
Utmost care has been taken while preparing this lab manual however always there is chances of
improvement. Therefore, we welcome constructive suggestions for improvement and removal of
errors if any.
Python for Data Science (3150713)
Sr.
Objective(s) of Experiment CO1 CO2 CO3 CO4 CO5
No.
Develop a program to understand the control structures of
1. √
python.
Develop a program to learn different types of structures
2. (list, dictionary, tuples) in python. √
The following industry relevant competency are expected to be developed in the student by
undertaking the practical work of this laboratory.
1. Programming Languages
2. Mathematics, Statistical Analysis, and Probability
3. Data Mining
4. Machine Learning and AI
5. Data Visualization
Index
(Progressive Assessment Sheet)
Total
Python for Data Science (3150713)
Experiment No: 1
Date:
Objectives: (a) To learn and understand the different control structures in Python, such as loops,
conditional statements, and functions.
Theory:
Conditional statements: Conditional statements in Python allow you to execute certain blocks of
code based on whether a certain condition is true or false. The two main types of conditional
statements in Python are "if" statements and "if-else" statements.
Loops: Loops in Python allow you to repeat a block of code multiple times, either for a fixed number
of times or until a certain condition is met. The two main types of loops in Python are "for" loops
and "while" loops.
Functions: Functions in Python allow you to encapsulate blocks of code and reuse them throughout
your program. Functions can accept parameters and return values, making them a powerful tool for
organizing and structuring your code.
Scope: Scope in Python refers to the region of your program where a variable or function is visible
and accessible. Understanding scope is critical for avoiding errors and ensuring that your code is
organized and easy to maintain.
Error handling: Error handling in Python involves detecting and responding to errors that may occur
Python for Data Science (3150713)
during program execution. Proper error handling can help you avoid crashes and ensure that your
program continues to run smoothly.
1. Data validation.
2. Check the data types.
3. Input sanitization.
4. Error Handling and Secure coding practices.
5. Use comments.
6. Test your code.
Procedure:
1. Plan the program structure and flow: Develop a plan for the program structure, including
the control structures that will be included, and the flow of the program logic.
2. Implement the control structures in Python: Write the code to implement the different
control structures in Python, including conditional statements, loops, and functions.
3. Test and debug the program: Conduct thorough testing of the program to ensure that it is
functioning correctly and identify and troubleshoot any errors or bugs.
4. Refine and optimize the program: Refine the program as needed to improve performance
and optimize its functionality, based on user feedback and testing results.
6. Deploy and maintain the program: Deploy the program for use by users, and maintain it by
addressing any issues or bugs that arise and providing updates and new features as needed.
Conclusion:
Python for Data Science (3150713)
Quiz:
1. What is a conditional statement in Python?
2. What is a loop in Python?
3. What is the difference between a "for" loop and a "while" loop in Python?
4. What is a function in Python?
5. What is scope in Python?
Suggested Reference:
1. https://docs.python.org/3/library/
2. https://www.tutorialspoint.com/python/
3. https://www.geeksforgeeks.org/
4. https://realpython.com/
5. https://www.w3schools.com/python/
Rubrics 1 2 3 4 5 Total
Marks
Knowledge of Programming Team work (2) Communication Skill Ethics(2)
subject (2) Skill (2)
Goo Averag Goo Averag Good Satisfactory Good Satisfactory Good Average
d (2) e (1) d (2) e (1) (2) (1) (2) (1) (2) (1)
Python for Data Science (3150713)
Experiment No: 2
Date:
• Basic programming concepts: You should have a good grasp of basic programming concepts
such as variables, data types, conditional statements, loops, and functions.
• Python programming language: You should have a good understanding of Python syntax,
data structures, and standard library functions.
• Sequences: Sequences are ordered collections of elements that can be accessed by their
index or key. You should have a good understanding of the different types of sequences
such as string, tuple, list, dictionary, and set, and their respective properties.
• String manipulation: You should know how to manipulate them using methods such as
slicing, concatenation, and formatting.
• Collection manipulation: Collections such as lists, tuples, dictionaries, and sets can be
manipulated using methods such as append, insert, remove, pop, and sort.
• Iteration: You should know how to use for loops and list comprehensions to iterate over
sequences.
• Conditional statements: You should know how to use conditional statements to check for
specific conditions in sequences.
• Functions: You should know how to define functions that operate on sequences and return
values.
Objectives: (a) To learn how to manipulate and access their elements, iterate over them, perform
conditional operations on them, and use them in functions.
(b) To learn how to select the appropriate sequence type for a given task based on its properties and
performance characteristics.
Theory:
1. In Python programming language, there are four built-in sequence types: strings, lists,
tuples, and ranges. Additionally, Python includes the set and dictionary data structures,
which are implemented as unordered collections of unique and key-value pairs, respectively.
2. The string data type in Python represents a sequence of characters and is immutable,
meaning its contents cannot be changed once it is created. Strings can be manipulated using
various methods such as slicing, concatenation, and formatting.
3. Lists and tuples are similar in many ways, but tuples are immutable, whereas lists are
mutable. Lists and tuples can hold elements of any data type and can be indexed and sliced
like strings. However, lists offer additional methods such as append, insert, remove, and pop
Python for Data Science (3150713)
4. Dictionaries are another important sequence type in Python and are implemented as
unordered collections of key-value pairs. Each element in a dictionary consists of a key and
a corresponding value. Dictionaries can be used to store and retrieve data quickly based on
the key.
5. Sets are collections of unique elements that are unordered and mutable. Sets are often used
to perform set operations such as union, intersection, and difference.
Procedure:
1. Create a string variable using single or double quotes.
Use string methods like upper(), lower(), strip(), split(), join(), and replace() to manipulate the
string as needed.
Use indexing and slicing to access specific characters or substrings within the string.
2. Create a tuple variable using parentheses.
Use indexing and slicing to access specific elements or subsets within the tuple.
Tuples are immutable, so you cannot add, remove or modify elements once created.
3. Create a list variable using square brackets.
Use indexing and slicing to access specific elements or subsets within the list.
Use list methods like append(), insert(), remove(), pop(), extend(), and sort() to modify the list
as needed.
Lists are mutable, so you can add, remove or modify elements once created.
4. Create a dictionary variable using curly braces or the dict() constructor.
Use keys to access values within the dictionary.
Use dictionary methods like keys(), values(), and items() to access different parts of the
dictionary.
Use del or pop() to remove elements from the dictionary.
Use assignment to add or modify elements in the dictionary.
5. Create a set variable using curly braces or the set() constructor.
Use set methods like add(), remove(), pop(), union(), and intersection() to modify or perform
operations on the set.
Sets do not allow duplicate elements, so adding the same element multiple times will only add
it once.
Conclusion:
Python for Data Science (3150713)
Quiz:
1. What method can you use to convert a string to uppercase in Python?
2. What is the difference between a tuple and a list in Python?
3. How do you add an element to a list in Python?
4. How do you access a value in a dictionary using its key in Python?
5. What is a set in Python?
Suggested Reference:
1. https://docs.python.org/3/library/
2. https://www.tutorialspoint.com/python/
3. https://www.geeksforgeeks.org/
4. https://realpython.com/
5. https://www.w3schools.com/python/
Rubrics 1 2 3 4 5 Total
Marks
Knowledge of Programming Team work (2) Communication Skill Ethics(2)
subject (2) Skill (2)
Goo Averag Goo Averag Good Satisfactory Good Satisfactory Good Average
d (2) e (1) d (2) e (1) (2) (1) (2) (1) (2) (1)
Python for Data Science (3150713)
Experiment No: 3
Develop a program that reads a .csv dataset file using Pandas library and display
the following content of the dataset.
a) First five rows of the dataset
b) Complete data of the dataset
c) Summary or metadata of the dataset.
Date:
• Knowledge of Python programming language and its libraries, particularly the Pandas
library.
• Understanding of the structure of .csv files and how to read and manipulate them using
Pandas.
• Familiarity with the different methods and functions available in Pandas, such as "head()",
"print()", "display()", "info()", and "describe()".
• Ability to write and debug code, and troubleshoot errors that may arise when working with
datasets.
• Experience in working with datasets, including data cleaning, data wrangling, and data
analysis.
• Ability to understand the content and structure of datasets, and use them to derive insights
and information.
Practical skills:
• Writing code to load a .csv dataset file into a Pandas DataFrame using the "read_csv()"
function.
• Using the "head()" method to display the first five rows of the dataset.
• Using the "print()" function or "display()" method to display the complete data of the dataset.
• Using the "info()" method or "describe()" method to display the summary or metadata of the
dataset.
• Handling errors and exceptions that may arise when working with datasets.
• Writing clean and efficient code that is easy to read and maintain.
• Testing the program with different datasets to ensure its accuracy and reliability.
Objectives: (a) To read and load the .csv dataset file into a Pandas DataFrame.
(b) To display the first five rows of the dataset using the "head()" method.
(c) To display the complete data of the dataset using the "print()" function or "display()" method.
(d) To display the summary or metadata of the dataset using the "info()" method or "describe()"
method.
Theory:
Pandas is a popular data manipulation library for Python, widely used in data science and machine
learning. It provides a powerful and flexible toolset for working with structured data, including
loading, manipulating, and analyzing datasets in various formats, including .csv files
Python for Data Science (3150713)
Procedure:
1. Import the Pandas library: To use the Pandas library in Python, it is essential to import it
into your program. You can do this by using the "import pandas as pd" statement.
2. Load the dataset: The next step is to load the dataset into a Pandas DataFrame using the
"read_csv()" function. This function takes the path to the .csv file as an argument and returns
a DataFrame object that contains the data from the file.
3. Display the first five rows: To display the first five rows of the dataset, you can use the
"head()" method. This method returns the first five rows of the DataFrame by default, but
you can specify the number of rows you want to display as an argument.
4. Display the complete data: To display the complete data of the dataset, you can use the
"print()" function or "display()" method. This will output the entire DataFrame to the
console or Jupyter Notebook.
5. Display summary or metadata: To display the summary or metadata of the dataset, you can
use the "info()" method or "describe()" method. The "info()" method provides information
about the DataFrame, including the number of rows and columns, data types, and memory
usage. The "describe()" method provides statistical summary of the dataset, including count,
mean, standard deviation, minimum, maximum, and quartiles for each column.
Conclusion:
Python for Data Science (3150713)
Quiz:
1. What library should be used to read a .csv dataset file in Python?
2. Which method is used to read a .csv file using Pandas library?
3. How can you display the first five rows of the dataset using Pandas?
4. How can you display the complete data of the dataset using Pandas?
5. How can you display the summary or metadata of the dataset using Pandas?
Suggested Reference:
1. Official Pandas documentation: https://pandas.pydata.org/docs/
2. "Python for Data Analysis" by Wes McKinney:
https://www.oreilly.com/library/view/python-for-data/9781491957653/
3. "Python Data Science Handbook" by Jake VanderPlas:
https://jakevdp.github.io/PythonDataScienceHandbook/
4. Pandas tutorial by DataCamp: https://www.datacamp.com/community/tutorials/pandas-
tutorial-dataframe-python
Rubrics 1 2 3 4 5 Total
Marks
Knowledge of Programming Team work (2) Communication Skill Ethics(2)
subject (2) Skill (2)
Goo Averag Goo Averag Good Satisfactory Good Satisfactory Good Average
d (2) e (1) d (2) e (1) (2) (1) (2) (1) (2) (1)