OneCompiler

Hslip24

105

Q1]

<!DOCTYPE html> <html> <head> <title>File Content Appender</title> </head> <body> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $firstFileName = $_POST["firstFileName"]; $secondFileName = $_POST["secondFileName"];
    // Read content from the first file
    $firstFileContent = file_get_contents($firstFileName);

    // Append content to the second file
    file_put_contents($secondFileName, $firstFileContent, FILE_APPEND);

    echo "Content from '$firstFileName' has been appended to '$secondFileName'.";
}
?>

<h2>File Content Appender</h2>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
    First File Name: <input type="text" name="firstFileName"><br>
    Second File Name: <input type="text" name="secondFileName"><br>
    <input type="submit" value="Append Content">
</form>
</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()