Practical Manual for Python Programming
Practical Manual for Python Programming
• Aim: To familiarize students with Python IDEs and write basic scripts for simple
applications.
• Theory:
• Python Program:
# Area of a Circle
• Theory:
• Python Program:
print("Irrigation Required.")
else:
Lab 3: Manipulating and Analyzing Agricultural Datasets Using Lists, Tuples, and Dictionaries
• Aim: To manipulate and analyze agricultural datasets using Python’s built-in data
structures.
• Theory:
• Python Program:
crops = {
# Accessing data
crop = "Mango"
• Aim: To write Python programs that read and process crop data from text files.
• Theory:
• Python Program:
print(line.strip())
• Theory:
• Python Program:
import pandas as pd
# Creating a DataFrame
df = pd.DataFrame(data)
print(df)
print(high_yield)
Practical Manual for Python Programming
• Theory:
• Python Program:
plt.xlabel('Year')
plt.show()
Practical Manual for Python Programming
• Aim: To design a class for farm equipment and simulate operations using Object-Oriented
Programming.
• Theory:
• Python Program:
class FarmEquipment:
self.name = name
self.type_of_equipment = type_of_equipment
def operate(self):
# Creating an object
tractor.operate()
Practical Manual for Python Programming
• Aim: To automate data collection by writing scripts to scrape weather data for a specific
region.
• Theory:
• Python Program:
import requests
url = 'https://weather-website.com'
response = requests.get(url)
• Aim: To import and export crop production data from Excel files.
• Theory:
o Using Python libraries (e.g., openpyxl, pandas) to work with Excel files
• Python Program:
import pandas as pd
df = pd.read_excel('crop_data.xlsx')
print(df)
df.to_excel('processed_crop_data.xlsx', index=False)
Practical Manual for Python Programming
Lab 10: Introduction to NumPy: Array Operations for Statistical Analysis of Soil Data
• Theory:
• Python Program:
import numpy as np
mean = np.mean(soil_data)
std_dev = np.std(soil_data)
• Aim: To perform basic image processing and analyze leaf images for disease detection.
• Theory:
• Python Program:
import cv2
image = cv2.imread('leaf_image.jpg')
cv2.waitKey(0)
cv2.destroyAllWindows()
Practical Manual for Python Programming
Lab 12: Simple GUI Application: Developing a Crop Irrigation Scheduling Tool Using Tkinter
• Aim: To develop a graphical user interface (GUI) application for crop irrigation scheduling.
• Theory:
o Event-driven programming
• Python Program:
import tkinter as tk
def irrigation_schedule():
moisture_level = int(entry.get())
label_result.config(text="Irrigation Required.")
else:
root = tk.Tk()
root.title('Irrigation Scheduling')
label.pack()
entry = tk.Entry(root)
entry.pack()
button.pack()
label_result.pack()
root.mainloop()
Practical Manual for Python Programming
Lab 13: Time Series Analysis of Crop Production Data Using Python
• Aim: To perform time series analysis of crop production data using Python.
• Theory:
• Python Program:
import pandas as pd
df = pd.DataFrame(data)
plt.xlabel('Year')
plt.show()
Practical Manual for Python Programming
• Aim: To build a simple machine learning model for crop yield prediction.
• Theory:
• Python Program:
import numpy as np
model = LinearRegression()
model.fit(years, yields)
predicted_yield = model.predict(np.array([[2023]]))
Lab 15: GIS Data Processing: Plotting Spatial Data Related to Crop Distribution
• Aim: To process GIS data and plot spatial data related to crop distribution.
• Theory:
• Python Program:
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot()
plt.show()
Practical Manual for Python Programming
Lab 16: Final Project: Developing a Python Application for a Specific Agricultural Problem
• Theory: