OneCompiler

Hslip9

114

Q1]

<!DOCTYPE html> <html> <head> <title>String Operations</title> </head> <body> <form method="post" action=""> <label for="inputString">Enter a String:</label> <input type="text" name="inputString" required>
<label for="separator">Choose a Separator:</label>
<select name="separator" required>
    <option value="#">#</option>
    <option value="|">|</option>
    <option value="%">%</option>
</select>

<input type="submit" value="Submit">
</form> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $inputString = $_POST["inputString"]; $separator = $_POST["separator"]; // Split the string into separate words using the given separator $words = explode($separator, $inputString); echo "<p>Separated Words: " . implode(", ", $words) . "</p>"; // Replace all occurrences of separator in the given string with another separator $newSeparator = "@"; $modifiedString = str_replace($separator, $newSeparator, $inputString); echo "<p>Modified String: $modifiedString</p>"; // Find the last word in the given string $lastWord = end($words); echo "<p>Last Word: $lastWord</p>"; } ?> </body> </html> Q2] import pandas as pd

Load the dataset

dataset = pd.read_csv('winequality-red.csv')

a) Describing the dataset

description = dataset.describe()
print("Description of the Dataset:\n", description)

b) Shape of the dataset

shape = dataset.shape
print("\nShape of the Dataset:", shape)

c) Display first 3 rows from the dataset

first_three_rows = dataset.head(3)
print("\nFirst 3 Rows of the Dataset:\n", first_three_rows)