OneCompiler

Hslip25

99

Q1]

<!DOCTYPE html> <html> <head> <title>File Operations</title> </head> <body> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $fileName = $_POST["fileName"];
    // a) Display type of file
    $fileType = mime_content_type($fileName);
    echo "File Type: $fileType <br>";

    // b) Display last modification time of file
    $lastModifiedTime = filemtime($fileName);
    echo "Last Modification Time: " . date("F d Y H:i:s.", $lastModifiedTime) . "<br>";

    // c) Display the size of file
    $fileSize = filesize($fileName);
    echo "File Size: $fileSize bytes <br>";

    // d) Delete the file
    if (unlink($fileName)) {
        echo "File '$fileName' deleted successfully. <br>";
    } else {
        echo "Error deleting the file. <br>";
    }
}
?>

<h2>File Operations</h2>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
    Enter File Name: <input type="text" name="fileName"><br>
    <input type="submit" value="Perform File Operations">
</form>
</body> </html> Q2] A] import numpy as np import matplotlib.pyplot as plt

Generate a random array of 50 integers

np.random.seed(42)
data = np.random.randint(1, 100, 50)

Display using line chart, scatter plot, histogram, and box plot

fig, axes = plt.subplots(2, 2, figsize=(12, 8))

Line chart

axes[0, 0].plot(data, color='green')
axes[0, 0].set_title('Line Chart')

Scatter plot

axes[0, 1].scatter(range(1, 51), data, color='red')
axes[0, 1].set_title('Scatter Plot')

Histogram

axes[1, 0].hist(data, bins=10, color='blue', alpha=0.7)
axes[1, 0].set_title('Histogram')

Box plot

axes[1, 1].boxplot(data, vert=False)
axes[1, 1].set_title('Box Plot')

plt.tight_layout()
plt.show()

B]
import matplotlib.pyplot as plt

Create two lists representing subject names and marks obtained

subjects = ['Math', 'English', 'Science', 'History', 'Art']
marks = [90, 85, 92, 88, 78]

Display data in a pie chart

plt.pie(marks, labels=subjects, autopct='%1.1f%%', startangle=140, colors=['skyblue', 'lightcoral', 'lightgreen', 'lightpink', 'lightyellow'])
plt.title('Marks in Subjects')
plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.

Display the plot

plt.show()