Hslip12
Q1]
<!DOCTYPE html> <html> <head> <title>Arithmetic Operation</title> </head> <body> <form method="post" action="calculate.php"> <label for="num1">Enter the first number:</label> <input type="text" name="num1" required><label for="num2">Enter the second number:</label>
<input type="text" name="num2" required>
<br>
<input type="radio" name="operation" value="add" checked> Addition
<input type="radio" name="operation" value="subtract"> Subtraction
<input type="radio" name="operation" value="multiply"> Multiplication
<input type="radio" name="operation" value="divide"> Division
<br>
<input type="submit" value="Calculate">
</form>
</body>
</html>
Q2]
a]
import numpy as np
import matplotlib.pyplot as plt
Generate a random array of 50 integers
random_array = np.random.randint(1, 100, 50)
Line chart
plt.figure(figsize=(12, 5))
plt.subplot(2, 2, 1)
plt.plot(random_array, label='Random Array', color='blue')
plt.title('Line Chart')
plt.legend()
Scatter plot
plt.subplot(2, 2, 2)
plt.scatter(range(1, 51), random_array, label='Random Array', color='green')
plt.title('Scatter Plot')
plt.legend()
Histogram
plt.subplot(2, 2, 3)
plt.hist(random_array, bins=10, color='orange', edgecolor='black')
plt.title('Histogram')
Box plot
plt.subplot(2, 2, 4)
plt.boxplot(random_array, vert=False, patch_artist=True)
plt.title('Box Plot')
plt.tight_layout()
plt.show()
B]
import pandas as pd
Create data frame
data = {'column_name': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
'salary': [50000, 60000, 75000, 55000, 80000, None, 70000, 65000, None, 72000],
'department': ['HR', 'IT', 'Finance', 'HR', 'IT', 'Finance', 'HR', 'IT', 'Finance', 'HR']}
df = pd.DataFrame(data)
Display the original data frame
print("Original Data Frame:")
print(df)
Add 10 rows with some missing and duplicate values
additional_data = {'column_name': ['K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T'],
'salary': [60000, 70000, 80000, 55000, None, 75000, 65000, 72000, None, 70000],
'department': ['IT', 'HR', 'Finance', 'HR', 'IT', 'Finance', 'HR', 'IT', 'Finance', 'HR']}
df = pd.concat([df, pd.DataFrame(additional_data)], ignore_index=True)
Drop all null and empty values
df = df.dropna()
Display the modified data frame
print("\nModified Data Frame:")
print(df)