OneCompiler

Hslip21

129
<!DOCTYPE html> <html> <head> <title>High Temperatures</title> </head> <body> <?php // Create an array of 15 high temperatures $highTemps = array(68, 72, 75, 70, 78, 82, 79, 84, 77, 73, 76, 80, 85, 74, 81);
// Calculate the average high temperature
$averageTemp = array_sum($highTemps) / count($highTemps);

// Find the five warmest high temperatures
$warmestTemps = array_slice($highTemps, -5);

// Displaying the results
echo "<h2>High Temperatures</h2>";
echo "<p>High Temperatures: " . implode(', ', $highTemps) . "</p>";
echo "<p>Average High Temperature: $averageTemp</p>";
echo "<p>Five Warmest High Temperatures: " . implode(', ', $warmestTemps) . "</p>";
?>
</body> </html>

Q2]
a]
import pandas as pd
import matplotlib.pyplot as plt

Importing the dataset

iris_data = pd.read_csv("iris.csv")

Creating a bar plot for the frequency of the three species

species_counts = iris_data['species'].value_counts()
species_counts.plot(kind='bar', color=['blue', 'green', 'orange'])

Adding labels and title

plt.xlabel('Species')
plt.ylabel('Frequency')
plt.title('Frequency of Iris Species')

Display the plot

plt.show()

B]
import pandas as pd
import matplotlib.pyplot as plt

Importing the dataset

iris_data = pd.read_csv("iris.csv")

Creating histograms for each species

for species in iris_data['species'].unique():
plt.hist(iris_data[iris_data['species'] == species]['sepal_length'], alpha=0.5, label=species)

Adding labels and title

plt.xlabel('Sepal Length')
plt.ylabel('Frequency')
plt.title('Histogram of Sepal Length for Iris Species')

Adding a legend

plt.legend()

Display the plot

plt.show()