Python Practical M
Python Practical M
ARTIFICIAL INTELLIGENCE
MAHEK DHANUKA
X A 13
CODE 1 :
# Lists representing heritage and headway
heritage = ['Taj Mahal', 'Agra Fort', 'Ajanta and Ellora Caves', 'Khajuraho
Group of Monuments', 'Hampi']
headway = ['Metro Railway', 'Unified Payment Interface-UPI', 'Chandrayaan-1
and Chandrayaan-3', 'the Mars Orbiter Mission (Mangalyaan)']
# Merge the two lists
heritage_and_headway = heritage + headway
# Display the unified list
print("Celebrating the blend of Heritage and
Headway:",heritage_and_headway)
OUTPUT
Celebrating the blend of Heritage and Headway: ['Taj Mahal', 'Agra Fort',
'Ajanta and Ellora Caves', 'Khajuraho Group of Monuments', 'Hampi', 'Metro
Railway', 'Unified Payment Interface-UPI', 'Chandrayaan-1 and Chandrayaan-
3', 'the Mars Orbiter Mission (Mangalyaan)'
CODE 2:
# Strengths of the two villages
L1 = [111, 513, 15]
L2 = [222, 434, 346]
new_generation = []
for i in range(len(L1)):
new_generation.append(L1[i] + L2[i])
print(new_generation)
OUTPUT:
[333, 947, 505]
CODE 3:
import matplotlib.pyplot as plt
x = [6, 20]
y = [12, 30] plt.plot(x, y, marker='o', linestyle='-',
color='blue')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Chart from (6,12) to (20,30)')
plt.grid(True)
plt.show()
OUTPUT
CODE 4:
import matplotlib.pyplot as plt
pollution = [1, 2, 3, 4]
temperature_impact = [x**3 for x in pollution]
plt.plot(pollution, temperature_impact, marker='o',
linestyle='-', color='red')
plt.xlabel('Pollution Level')
plt.ylabel('Temperature Impact')
plt.title('Cubic Relationship: Pollution vs Temperature
Impact')
plt.grid(True)
plt.show()
OUTPUT
CODE 5:
import numpy as np
import statistics as st
L1 = [200, 505, 450, 520, 505]
mean = np.mean(L1)
median = np.median(L1)
mode = st.mode(L1)
print("Mean:", mean)
print("Median:", median)
print("Mode:", mode)
OUTPUT
Mean: 436.0
Median: 505.0
Mode: 505
CODE 6
import matplotlib.pyplot as plt
ice_cream = ['cream_bell', 'baskin_robbins',
'kwality']
data = [20, 10, 30]
plt.pie(data, labels=ice_cream)
plt.title('Ice Cream Eating Competition Results')
plt.axis('equal')
plt.show()
OUTPUT
CODE 7:
import matplotlib.pyplot as plt
waste_types = ['Plastic', 'Organic', 'Electronic']
waste_values = [25, 40, 15]
plt.pie(waste_values, labels=waste_types)
plt.title('Sources of Waste in the Community')
plt.axis('equal')
plt.show()
OUTPUT
CODE 8
import matplotlib.pyplot as plt
# Dataset A
handcrafted_arts = [75, 65, 85]
folk_music = [60, 75, 90]
# Dataset B
digital_design = [90, 120, 100]
ai_music_generator = [80, 100, 120]
plt.scatter(handcrafted_arts, folk_music, color='green',
label='Traditional (Dataset A)')
plt.scatter(digital_design, ai_music_generator, color='blue',
label='Digital (Dataset B)')
plt.xlabel('Art/Design Scores')
plt.ylabel('Music Scores')
plt.title('Scatter Chart: Traditional vs Digital Creativity')
plt.grid(True)
plt.show()
OUTPUT
CODE 9:
import matplotlib.pyplot as plt
x = [13, 25, 20]
y = [50, 70, 60]
plt.scatter(x, y, color='purple')
plt.xlabel('Community Education Initiatives')
plt.ylabel('Environmental Awareness Level')
plt.title('Impact of Education Initiatives on
Environmental Awareness')
plt.grid(True)
plt.show()
OUTPUT
CODE 10:
import numpy as np
team_strikers = np.array([180, 145, 200])
team_blazers = np.array([170, 160, 190])
combined score= [team_strikers+ team_blazers]
print(combined_score)
OUTPUT
[array([350, 305, 390])]
CODE 11:
Roots=['oral storytelling','handwritten
manuscripts','mechanical clock']
Wings=['digital publishing','Al−generated
content','smartwatches']
timeline = Roots + Wings
print(timeline)
OUTPUT
['oral storytelling', 'handwritten manuscripts',
'mechanical clock', 'digital publishing', 'Al−generated
content', 'smartwatches']
CODE 12:
import matplotlib.pyplot as plt
foods = ['Biryani', 'Pani Puri', 'Papri Chaat']
preferences = [50, 30, 20]
plt.pie(preferences, labels=foods)
plt.title('Most Popular Indian Food Preferences
Among Students')
plt.axis('equal')
plt.show()
OUTPUT