KETAN

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Experiment: 1

Student Name: ketan jain


UID: 22BCS15040
Branch: Computer Science & Engineering Section/Group:
D
Semester: 1 Date: 9/6/2022
Performance:
Subject Name: DISRUPTIVE TECHNOLOGY
Subject Code: 22ECH-102

1. Aim of the practical: Explore data pre-processing packages and AIML


algorithms

2. Tool Used: Google Colaboratory

3. Basic Concept/ Command Description:


Data Analytics
The process of examining datasets to draw conclusions about the information
they contain. Data analytic techniques enable you to take raw data and
uncover patterns to extract valuable insights from it. Many data analytics
techniques use specialized systems and software that integrate machine
learning algorithms, automation and other capabilities.
Data Science
Data science combines the scientific method, math and statistics, specialized
programming, advanced analytics, AI, and even storytelling to uncover and
explain the business insights buried in data. Data science encompasses
preparing data for analysis and processing, performing advanced data
analysis, and presenting the results to reveal patterns and enable stakeholders
to draw informed conclusions.
Dataset
A dataset (or data set) is a collection of data. A dataset corresponds to the
contents of a single database table, or a single statistical data matrix, where
every column of the table represents a particular variable, and each row
corresponds to a given member of the data set in question.
Datasets are not limited to just numbers and text and may include collections
of images or videos.
Google Colab

It is basically a free notebook environment that runs fully in the cloud. It has
features that help you to edit documents like the same way you work with
Google Docs. Colab supports many popular and high-level machine learning
libraries which can be easily loaded in your notebook.

• Write and execute code in Python


• Document the code which supports the mathematical equations
• Create new notebooks
• Upload the existing notebooks
• Share the notebooks with the google link
• Import data from Google Drive
• Save notebooks from/to Google Drive
• Import/Publish notebooks from GitHub
• Import external datasets e.g. from Kaggle
• Integrate PyTorch, TensorFlow, Keras, OpenCV
• Free Cloud service with free GPU and TPU

4. Code:

#------------------------------------------------------------------------
# 1.1: Read a file and print its content line by line
#------------------------------------------------------------------------

# Example 1:

try:
fp = open('/content/textdata.txt') # Open the file in reading mode
for line in fp: # Print line by line
print (line)
fp.close() # Close the file

except:
print("Error!! No such file exist")
# Example 2:
try:
with open('textdata.txt', 'r') as f:
line = f.read()
print (line)

except:
print("Error!! No such file exist")

#------------------------------------------------------------------------
# 1.3: Read from one file, Convert it to upper case and write to other file
#------------------------------------------------------------------------
try:
readFp = open('textdata.txt','r') # Open the file in reading mode
writeFp = open('result.txt','w') # Open the file in writing mode

for line in readFp:


writeFp.write(line.upper())

readFp.close()
writeFp.close()

print ("Writing done !! \nOpen result.txt to view the content")

except:
print("Error !! Unable to open file.")

#------------------------------------------------------------------------
# 1.2: Writing 1 to 10 in file
#------------------------------------------------------------------------

# Example 1:

fp = open('textdata.txt','w') # Open the file in writing mode

for i in range(1,11):
fp.write(str(i) + "\n") # Writing to the file line by line

fp.close()

print ("Writing done !! \nOpen textdata.txt to view the content")

try:
fp = open('textdata.txt','r') # Open the file in reading mode
for line in fp: # Print line by line
print (line)
fp.close() # Close the file

except:
print("Error!! No such file exist")
#------------------------------------------------------------------------
# 1.4: Appending to a file
#------------------------------------------------------------------------
try:
readFp = open('textdata.txt','r') # Open the file in reading mode
writeFp = open('result.txt','a') # Open the file in Append mode

for line in readFp:


writeFp.write(line)

fp = open('result.txt','r') # Open the file in reading mode


for line in fp: # Print line by line
print (line)
fp.close() # Close the file

print("Error!! No such file exist")

readFp.close()
writeFp.close()

print ("Writing done !! \nOpen result.txt to view the content")


except:
print("Error !! Unable to open file.")

#------------------------------------------------------------------------
# 1.5: Creating a file
#------------------------------------------------------------------------
try:
writeFp = open('xyz1.txt','x') # Creating the file
writeFp.close()

print ("Done")

except:
print("Error !! File already exist.")

#------------------------------------------------------------------------
# 1.6: get all the files (and directories) in the current directory - Version 1
#------------------------------------------------------------------------

# Example 1:

import os
allFiles = os.listdir()
print(allFiles)
#------------------------------------------------------------------------
# 1.7: Get the current working directory
#------------------------------------------------------------------------
import os

# Getting the current work directory; similar to pwd in Linux


currentDirName = os.getcwd()

print(currentDirName)

#------------------------------------------------------------------------
# 1.8: Delete a file
#------------------------------------------------------------------------
import os

try:
os.remove("xyz1.txt")
print ("File Deleted !!")
except:
print ("Error !! File not found ")

#------------------------------------------------------------------------
# 1.9:
#------------------------------------------------------------------------
import os
if os.path.exists("textdata.txt"):
os.remove("textdata.txt")
else:
print("The file does not exist")

# Input from user and print it


#------------------------------------------------------------------------
a = input("Enter Anything(Name/Numer): ")
print(a)
print("\nYour Input is -->",a)
print(type(a))

5. Observations, Simulation Screen Shots and Discussions:

1. Read a file and print its content line by line code worked fine.
2. Read from one file, Convert it to upper case and write to other file
successful
3. Writing 1 to 10 in file code worked
4. Appending to a file
5. Creating a file
6. get all the files (and directories) in the current directory - Version 1
7. Get the current working directory
8. Delete a file
9. Check if File exist
6. Result and Summary:

All codes worked fine and multiple codes were executed successfully.

Evaluation Grid (To be filled by Faculty):


Sr. No. Parameters Marks Obtained Maximum Marks
1. Student Performance (task 12
implementation and result evaluation)
2. Viva-Voce 10
3. Worksheet Submission (Record) 8
Signature of Faculty (with Date): Total Marks Obtained: 30

You might also like