Hslip30
Q1]
<!DOCTYPE html> <html> <head> <title>Student Competition Information</title> </head> <body> <?php // Assuming you have established a connection to the databaseif ($_SERVER["REQUEST_METHOD"] == "POST") {
$competitionName = $_POST["competitionName"];
// Fetch information of students who secured 1st rank in the specified competition
$query = "SELECT Student.Stud_id, Student.name, Student.class
FROM Student
JOIN StudentCompetition ON Student.Stud_id = StudentCompetition.Stud_id
JOIN Competition ON StudentCompetition.c_no = Competition.c_no
WHERE Competition.c_name = '$competitionName' AND StudentCompetition.rank = 1";
$result = mysqli_query($connection, $query);
if (!$result) {
die("Query failed: " . mysqli_error($connection));
}
// Display the result
echo "<h2>Students who secured 1st rank in $competitionName</h2>";
echo "<table border='1'>";
echo "<tr><th>Student ID</th><th>Name</th><th>Class</th></tr>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>{$row['Stud_id']}</td>";
echo "<td>{$row['name']}</td>";
echo "<td>{$row['class']}</td>";
echo "</tr>";
}
echo "</table>";
mysqli_free_result($result);
}
?>
<h2>Student Competition Information</h2>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Enter Competition Name: <input type="text" name="competitionName">
<input type="submit" value="Show 1st Rank Students">
</form>
</body>
</html>
Q2]
import numpy as np
import matplotlib.pyplot as plt
a. 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. 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 bar chart
plt.bar(subjects, marks, color=['skyblue', 'lightcoral', 'lightgreen', 'lightpink', 'lightyellow'])
plt.xlabel('Subjects')
plt.ylabel('Marks')
plt.title('Subject-wise Marks')
plt.show()