Professional Documents
Culture Documents
SLIP 1
Q. 1) Write a PHP script to keep track of number of times the web page has been accessed
(Use Session Tracking).
Ans:-
.php
<html>
<head>
<title> Number of times the web page has been visited.</title>
</head>
<body>
<?php
session_start();
if(isset($_SESSION['count']))
$_SESSION['count']=$_SESSION['count']+1;
else
$_SESSION['count']=1;
echo "<h3>This page is accessed</h3>".$_SESSION['count'];
?>
print(df.shape)
print(df.isnull().sum)
new_df=df[['Salary','YearsExperience']]
new_df.sample(10)
import numpy as np
X = np.array(new_df[['Salary']])
Y = np.array(new_df[['YearsExperience']])
print(X.shape)
print(Y.shape)
plt.scatter(X,Y,color="red")
plt.title('Salary vs YearsExperience')
plt.xlabel('Salary')
plt.ylabel('YearsExperience')
plt.show()
LinearRegression()
plt.scatter(X_train,Y_train,color="blue")
plt.plot(X_train,regressor.predict(X_train),color="red",linewidth=3)
plt.title('Regression(Test Set)')
plt.xlabel('Salary')
plt.ylabel('YearsExperience')
plt.show()
plt.scatter(X_train,Y_train,color="blue")
plt.plot(X_train,regressor.predict(X_train),color="red",linewidth=3)
plt.title('Regression(training Set)')
plt.xlabel('Salary')
plt.xlabel('YearsExperience')
plt.show()
SLIP 2
Q. 1Write a PHP script to change the preferences of your web page like font style, font size,
font color, background color using cookie. Display selected setting on next web page and
actual implementation (with new settings) on third page (Use Cookies).
Ans:-
HTML file :
<html>
<body>
<form action="slip21_2_1.php" method="get">
<center>
<b>Select font style :</b><input type=text name=s1> <br>
<b>Enter font size : </b><input type=text name=s><br>
<b>Enter font color : </b><input type=text name=c><br>
<b>Enter background color :</b> <input type=text name=b><br>
<input type=submit value="Next">
</center>
</form>
</body>
</html>
<?php
echo "style is ".$_GET['s1']."<br>color is ".$_GET['c']."<br>Background color is ".
$_GET['b']."<br>size is ".$_GET['s'];
setcookie("set1",$_GET['s1'],time()+3600);
setcookie("set2",$_GET['c'],time()+3600);
setcookie("set3",$_GET['b'],time()+3600);
setcookie("set4",$_GET['s'],time()+3600);
?>
<html>
<body>
<form action="slip21_2_2.php">
<input type=submit value=OK>
</form>
</body>
</html>
Ans:-
import numpy as np
import matplotlib.pyplotasplt
Import pandas as pd
df=pd.read_csv(r'C:\Users\HP\Documents\DS\Salary_Data.csv')
df
print('Shape of dataset=',df.shape)
import numpy as np
X = np.array(df[['Height']])
Y = np.array(df[['Weight']])
print(X.shape)
print(Y.shape)
model=LinearRegression()
model.fit(X_train,Y_train)
plt.scatter(X_test,Y_test,color="red")
plt.title('Height vs Weight')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
plt.scatter(X_train,Y_train,color="blue")
plt.plot(X_train,model.predict(X_train),color="red",linewidth=3)
plt.title('Regression(training Set)')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
slip 3
Q. 1) Write a PHP script to accept username and password. If in the first three chances,
username and password entered is correct then display second form with “Welcome
message” otherwise display error message. [Use Session]
Ans:-
HTML file :
<html>
<head>
<script>
function getans()
{
st1=document.getElementById('txtname').value;
st2=document.getElementById('txtpass').value;
ob=new XMLHttpRequest();
ob.onreadystatechange=function()
{
if(ob.readyState==4 && ob.status==200)
{
if(ob.responseText==3)
{
alert("sorry you lost the chances to login");
location="error.html";
}
else if(ob.responseText=="correct")
{
alert("you entered correct details");
}
else alert(ob.responseText);
}
}
ob.open("GET","slip8_Q2.php?n="+st1+"&p="+st2);
ob.send();
}
</script>
</head>
<body>
<input type=text id=txtname placeholder="username"></br>
<input type=password id=txtpass placeholder="password"></br>
<input type="button" onclick="getans()" value="Login">
</body>
</html>
HTML file : error.html
<html>
<body>
<h1>YOu lossed the chances of login</h1>
</body>
</html>
PHP file :
<?php
session_start();
$nm=$_GET['n'];
$ps=$_GET['p'];
if($nm==$ps)
{
echo "correct";
}
else if(isset($_SESSION['cnt']))
{
$x=$_SESSION['cnt'];
$x=$x+1;
$_SESSION['cnt']=$x;
echo $_SESSION['cnt'];
if($_SESSION['cnt']>=3)
$_SESSION['cnt']=1;
}
else
{
$_SESSION['cnt']=1;
echo "1";
}
?>
Q. 2)Create ‘User’ Data set having 5 columns namely: User ID, Gender, Age, Estimated
Salary and Purchased. Build a logistic regression model that can predict whether on the
given parameter a person will buy a car or not.
Ans:-
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv("/root/sampada_vaibhavi/Data Anlytics/dataset/user.csv")
df
x= df.iloc[:, [2,3]].values
y= df.iloc[:, 4].values
x
x= df.iloc[:, [2,3]].values
y= df.iloc[:, 4].values
y
print(x_test)
print(y_pred)
SLIP 4
Q. 1) Write a PHP script to accept Employee details (Eno, Ename, Address) on first page. On
second page accept earning (Basic, DA, HRA). On third page print Employee information
(Eno, Ename, Address, Basic, DA, HRA, Total) [ Use Session]
Ans:-
HTML file :
<html>
<body>
<form action="slip18_2_1.php" method="get">
<center> <h2>Enter Enployee Details :</h2> <br>
<table>
<tr> <td><b>Emp no :</b></td> <td><input type=text name=eno></td> </tr>
<tr> <td><b> Name :</b></td> <td><input type=text name=enm></td> </tr>
<tr> <td><b>Address :</b></td> <td><input type=text name=eadd></td>
</tr>
</table>
<br> <input type=submit value=Show name=submit>
</center>
</form>
</body>
</html>
<?php
session_start();
$eno = $_GET['eno'];
$enm = $_GET['enm'];
$eadd = $_GET['eadd'];
$_SESSION['eno'] = $eno;
$_SESSION['enm'] = $enm;
$_SESSION['eadd'] = $eadd;
?>
<html>
<body>
<form action="slip18_2_2.php" method="post">
<center>
<h2>Enter Earnings of Employee:</h2>
<table>
<tr><td>Basic : </td><td><input type="text" name="e1"></td><tr>
<tr><td>DA : </td><td><input type="text" name="e2"></td></tr>
<tr><td>HRA : </td><td><input type="text" name="e3"></td></tr>
<tr><td></td><td><input type="submit" value=Next></td></tr>
</table>
</center>
</form>
</body>
</html>
<?php
session_start();
$e1 = $_POST['e1'];
$e2 = $_POST['e2'];
$e3= $_POST['e3'];
echo "<h3>Employee Details</h3> ";
echo "Name : ".$_SESSION['eno']."<br>";
echo "Address : ".$_SESSION['enm']."<br>";
echo "Class : ".$_SESSION['eadd']."<br><br>";
$total = $e1+$e2+$e3;
echo "<h2>Total Of Earnings Is : ".$total."</h2>";
?>
Q. 2)Build a simple linear regression model for Fish Species Weight Prediction.
Ans:-
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv("/root/sampada_vaibhavi/Data Anlytics/dataset/fish.csv")
df
print(df.shape)
print(df.isnull().sum())
new_df = df[['Height','Weight']]
new_df.sample(10)
X = np.array(new_df[['Height']])
Y = np.array(new_df[['Weight']])
print(X.shape)
print(Y.shape)
plt.scatter(X,Y,color="green")
plt.title('Height vs Weight')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
plt.scatter(X_test,Y_test,color="red")
plt.plot(X_train,regressor.predict(X_train),color="cyan",linewidth=3)
plt.title('Regression(Test Set)')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
plt.scatter(X_train,Y_train,color="blue")
plt.plot(X_train,regressor.predict(X_train),color="red",linewidth=3)
plt.title('Regression(training Set)')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
SLIP 5
Q. 1) Create XML file named “Item.xml”with item-name, item-rate, item quantity Store the
details of 5 Items of different Types
Ans:-
<ItemDetails>
<Item>
<ItemName>php</ItemName>
<ItemPrice>100</ItemPrice>
<Quantity>10</Quantity>
</Item>
<Item>
<ItemName>java</ItemName>
<ItemPrice>200</ItemPrice>
<Quantity>11</Quantity>
</Item>
<Item>
<ItemName>python</ItemName>
<ItemPrice>300</ItemPrice>
<Quantity>12</Quantity>
</Item>
<Item>
<ItemName>software tool</ItemName>
<ItemPrice>400</ItemPrice>
<Quantity>13</Quantity>
</Item>
<Item>
<ItemName>software tool</ItemName>
<ItemPrice>400</ItemPrice>
<Quantity>13</Quantity>
</Item>
</ItemDetails>
Ans:-
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv("/root/sampada_vaibhavi/Data Anlytics/dataset/iris.csv")
df
x= df.iloc[:, [2,3]].values
y= df.iloc[:, 4].values
x
x= df.iloc[:, [2,3]].values
y= df.iloc[:, 4].values
y
print(x_test)
print(y_pred)
SLIP 6
Q. 1) Write PHP script to read “book.xml” file into simpleXML object. Display
attributes and elements .( simple_xml_load_file() function )
Ans:-
Book.XML
<?xml version="1.0" encoding="utf-8"?>
<ABCBOOK>
<Technical>
<BOOK>
<Book_PubYear>ABC</Book_PubYear>
<Book_Title>pqr</Book_Title>
<Book_Author>400</Book_Author>
</BOOK>
</Technical>
<Cooking>
<BOOK>
<Book_PubYear>ABC</Book_PubYear>
<Book_Title>pqr</Book_Title>
<Book_Author>400</Book_Author>
</BOOK>
</Cooking>
<Yoga>
<BOOK>
<Book_PubYear>ABC</Book_PubYear>
<Book_Title>pqr</Book_Title>
<Book_Author>400</Book_Author>
</BOOK>
</Yoga>
</ABCBOOK>
Book.php
<?php
$xml=simplexml_load_file("Book.xml") or die("cannnot load");
$xmlstring=$xml->asXML();
echo $xmlstring;
?>
Q. 2)Create the following dataset in python & Convert the categorical values
into numeric format.Apply the apriori algorithm on the above dataset to
generate the frequent itemsets and association rules. Repeat the process
with different min_sup values.
TID Item
1 Bread,Milk
2 Bread,Diaper,Beer,Eggs
3 Milk,Diaper,Beer,Coke
4 Bread,Milk,Diaper,Beer
5 Bread,Milk,Diaper,Coke
ans:
import pandas as pd
from mlxtend.frequent_patterns import apriori,association_rules
transactions = [['Bread','Milk'],['Bread','Diaper','Beer','Eggs'],
['Milk','Diaper','Beer','Coke'],
['Bread','Milk','Diaper','Beer'],['Bread','Milk','Diaper','Coke ']]
freq_items = apriori(df,min_support=0.5,use_colnames=True)
print(freq_items)
rules=association_rules(freq_items,metric='support',min_threshold=0.0)
rules=rules.sort_values(['support','confidence'], ascending=[False,False])
print(rules)
slip 7
Q. 1) Write a PHP script to read “Movie.xml” file and print all MovieTitle and
ActorName of file using DOMDocument Parser. “Movie.xml” file should
contain following information with at least 5 records with values.
MovieInfoMovieNo, MovieTitle, ActorName ,ReleaseYear
Ans:-
movies.xml
movies.php
<?php
$xml=simplexml_load_file("movies.xml");
foreach($xml->movie as $mov)
{
echo "movie no=$mov->movno"."<br>";
echo "movie name=$mov->movname"."<br>";
echo "movie actor=$mov->actor"."<br>";
echo "movie year=$mov->movyear"."<br>";
}
?>
Q. 2)Download the Market basket dataset. Write a python program to read
the dataset and display its information. Preprocess the data (drop null values
etc.) Convert the categorical values into numeric format. Apply the apriori
algorithm on the above dataset to generate the frequent itemsets and
association rules.
Ans:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv(' groceries.csv')
df
df.dropna()
df.describe()
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv('/root/sampada_vaibhavi/Data Anlytics/dataset/groceries -
groceries.csv')
df
df.dropna()
df.describe()
rules=association_rules(freq_items,metric='support',min_threshold=0.0005)
rules=rules.sort_values(['support','confidence'],ascending=[False,False])
print(rules)
slip 8
Q. 1) Write a JavaScript to display message ‘Exams are near, have you started preparing for?’
(usealert box ) and Accept any two numbers from user and display addition of two number .(Use
Prompt and confirm box)
Ans:-
alert.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
</head>
<body>
<hr />
<script type="text/javascript">
</script>
</body>
</html>
addition.html
<!doctype html>
<html>
<head>
<script>
</script>
</head>
<body></body>
</html>
Q. 2) Download the groceries dataset. Write a python program to read the dataset and display its
information. Preprocess the data (drop null values etc.) Convert the categorical values into numeric
format. Apply the apriori algorithm on the above dataset to generate the frequent itemsets and
association rules.
Ans:
import numpy as np
import pandas as pd
df = pd.read_csv(' groceries.csv')
df
df.dropna()
df.describe()
import numpy as np
import pandas as pd
df
df.dropna()
df.describe()
te = TransactionEncoder()
te_array=te.fit(df).transform(df)
df = pd.DataFrame(te_array,columns=te.columns_)
df
freq_items=apriori(df,min_support=0.0001,use_colnames=True)
print(freq_items)
rules=association_rules(freq_items,metric='support',min_threshold=0.0005)
rules=rules.sort_values(['support','confidence'],ascending=[False,False])
print(rules)
slip 9
slip 10
Q. 1) Create a HTML fileto insert text before and after a Paragraph using jQuery.
Ans:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
});
});
</script>
</head>
<body>
<button type="button">Insert Text</button>
<div id="container">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu sem tempor, varius quam at,
luctus dui. Mauris magna metus, dapibus nec turpis vel, semper malesuada ante.</p>
<p>Quis quam ut magna consequat faucibus. Pellentesque eget nisi a mi suscipit tincidunt. Ut
tempus dictum risus. Pellentesque viverra sagittis quam at mattis. Suspendisse potenti.</p>
</div>
</body>
</html>
Q. 2)Create the following dataset in python & Convert the categorical values into numeric
format.Apply the apriori algorithm on the above dataset to generate the frequent itemsets
and association rules. Repeat the process with different min_sup values.
TID Items
1 'eggs', 'milk','bread'
2 'eggs', 'apple'
3 'milk', 'bread'
4 'apple', 'milk'
5 'milk', 'apple', 'bread'
Ans:
import pandas as pd
from mlxtend.frequent_patterns import apriori,association_rules
transactions = [['Bread','Milk'],['Bread','Diaper','Beer','Eggs'],
['Milk','Diaper','Beer','Coke'],
['Bread','Milk','Diaper','Beer'],
[ 'Bread','Milk','Diaper','Coke ']]
from mlxtend.preprocessing import TransactionEncoder
te = TransactionEncoder()
te_array=te.fit(transactions).transform(transactions)
df = pd.DataFrame(te_array,columns=te.columns_)
df
freq_items = apriori(df,min_support=0.5,use_colnames=True)
print(freq_items)
rules=association_rules(freq_items,metric='support',min_threshold=0.0)rules=rules.sort_val
ues(['support','confidence'],ascending[False,False])
print(rules)
slip 11
Q. 1) Write a Javascript program to accept name of student, change font color to red, font
size to 18 if student name is present otherwise on clicking on empty text box display image
which changes its size (Use onblur, onload, onmousehover, onmouseclick, onmouseup)
Ans:-
<html>
<head>
<!--Function to do the background color-->
<script language="JavaScript">
var backColor = new Array(); // don't change this
backColor[0] = 'red';
backColor[1] = '#00FF00';
backColor[2] = '#0000FF';
backColor[3] = '#FFFFFF';
function changeBG(whichColor){
document.bgColor = backColor[whichColor];
}
</script>
<!--Function to do the font color-->
<script language="JavaScript">
var fontColor = new Array(); // don't change this
fontColor[0] = 'red';
fontColor[1] = '#00FF00';
fontColor[2] = '#0000FF';
fontColor[3] = '#FFFFFF';
function changefont(whichColor){
document.fgColor = fontColor[whichColor];
}
</script>
<script language="JavaScript">
var fontType = new Array(); // don't change this
fontType[0] = 'Arial';
fontType[1] = 'Verdana';
fontType[2] = 'Tahoma';
function changetype(whichType){
document.fontFamily = fontType[whichColor];
}
</script>
<script language="JavaScript">
var fontSize = new Array(); // don't change this
fontSize[0] = '12';
fontSize[1] = '14';
fontSize[2] = '16';
fontSize[3] = '18';
function changesize(whichSize){
document.fontWeight = fontSize[whichSize];
}
</script>
</head>
<body>
<form>
<center>
<select OnClick="location.href=this.options[this.selectedIndex].value">
<option value = "javascript:changeBG(0);">Red
<option value = "javascript:changeBG(1);">Green
<option value = "javascript:changeBG(2);">Blue
<option value = "javascript:changeBG(3);"> White
</select>
<select OnClick="document.href=this.options[this.selectedIndex].value">
<option value = "javascript:changefont(0);">Red Font
<option value = "javascript:changefont(1);">Green Font
<option value = "javascript:changefont(2);">Blue Font
<option value = "javascript:changefont(3);">White Font
</select>
<select OnClick="document.href=this.options[this.selectedIndex].value">
<option value = "javascript:changetype(0);">Arial
<option value = "javascript:changetype(1);">Verdana
<option value = "javascript:changetype(2);">Tahoma
</select>
<select OnClick="document.href=this.options[this.selectedIndex].value">
<option value = "javascript:changesize(0);">12
<option value = "javascript:changesize(1);">14
<option value = "javascript:changesize(2);">16
<option value = "javascript:changesize(3);">18
</select>
</br>
BLA BLA BLA test font
</form>
</body>
</html>
Q. 2)Create the following dataset in python & Convert the categorical values into numeric
format.Apply the apriori algorithm on the above dataset to generate the frequent itemsets
and associationrules. Repeat the process with different min_sup values.
TID Items
1 butter, bread, milk
2 butter, flour, milk, sugar
3 butter, eggs, milk, salt
4 eggs
5 butter, flour, milk, salt
import pandas as pd
from mlxtend.frequent_patterns import apriori,association_rules
transactions = [['Bread','Milk'],['Bread','Diaper','Beer','Eggs'],
['Milk','Diaper','Beer','Coke'],
['Bread','Milk','Diaper','Beer'],[
'Bread','Milk','Diaper','Coke ']]
from mlxtend.preprocessing import TransactionEncoder
te = TransactionEncoder()
te_array=te.fit(transactions).transform(transactions)
df = pd.DataFrame(te_array,columns=te.columns_)
df
freq_items = apriori(df,min_support=0.5,use_colnames=True)
print(freq_items)
rules=association_rules(freq_items,metric='support',min_threshold=0.0)rules=rules.sort_val
ues(['support','confidence'],ascending[False,False])
print(rules)
slip 12
slip 13
slip 14
slip 15
Q. 1) Write Ajax program to fetch suggestions when is user is typing in a textbox. (eg like
google suggestions. Hint create array of suggestions and matching string will be displayed)
Ans:-
1.html
<html>
<head>
<script>
function showHint(str)
{
if (str.length == 0)
{
document.getElementById("txtHint").innerHTML = "";
return;
}
else
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
document.getElementById("txtHint").innerHTML = this.responseText;
document.getElementById("txtHint1").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "gethint.php?q=" + str, true);
xmlhttp.send();
}
}
</script>
</head>
<body>
<p><b>Start typing a name in the input field below:</b></p>
<form>
First name: <input type="text" onkeyup="showHint(this.value)">
</form>
<p>Name: <span id="txtHint"></span></p>
</body>
</html>
gethint.php
<?php
$q = $_REQUEST["q"];
$hint = "";
if ($q !== "")
{
$hint = $q;
}
echo $hint ;
?>
Q. 2)Create the following dataset in python & Convert the categorical values
into numeric format.Apply the apriori algorithm on the above dataset to
generate the frequent itemsets and association rules. Repeat the process
with different min_sup values.
-->
import pandas as pd
from mlxtend.frequent_patterns import apriori,association_rules
transactions = [['Bread','Milk'],['Bread','Diaper','Beer','Eggs'],
['Milk','Diaper','Beer','Coke'],
['Bread','Milk','Diaper','Beer'],
[ 'Bread','Milk','Diaper','Coke ']]
from mlxtend.preprocessing import TransactionEncoder
te = TransactionEncoder()
te_array=te.fit(transactions).transform(transactions)
df = pd.DataFrame(te_array,columns=te.columns_)
df
freq_items = apriori(df,min_support=0.5,use_colnames=True)
print(freq_items)
rules=association_rules(freq_items,metric='support',min_threshold=0.0)rules=
rules.sort_values(['support','confidence'],ascending[False,False])
print(rules)
slip 16
Q. 1) Write Ajax program to get book details from XML file when user select a
book name. Create XML file for storing details of book(title, author, year,
price).
Ans:-
file.html
<html>
<body>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Press a button !");
if(r==true)
{
ver i;
var mybooks = new Array();
mybooks[0]="Mysql";
mybooks[1]="PHP";
mybooks[2]="Java";
for(i=0;i {
document.write(mybookks[i]+"
");
}
}
else
{
alert("Cancel books cannot br displayed !");
}
}
</script>
</head>
<body>
<input type="button" onclick="show_confirm()" value="List of Books"/>
</body>
</html>
File.xml
slip 17
Q. 1) Write a Java Script Program to show Hello Good Morning message
onload event using alert box and display the Student registration from.
Ans:-
<!DOCTYPE html>
<html>
<body>
<head>
<title>Show good morning good night wish as per time Javascript</title>
</head>
<script type="text/javascript">
document.write("<center><font size=+3 style='color: green;'>");
var day = new Date();
var hr = day.getHours();
if (hr >= 0 && hr < 12) {
document.write("Good Morning!");
} else if (hr == 12) {
document.write("Good Noon!");
} else if (hr >= 12 && hr <= 17) {
document.write("Good Afternoon!");
} else {
document.write("Good Evening!");
}
document.write("</font></center>");
</script>
</html>
</body>
</html>
REGISTRATION FORM
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title>JavaScript Form Validation using a sample registration form</title>
<meta name="keywords" content="example, JavaScript Form Validation,
Sample registration form" />
<meta name="description" content="This document is an example of
JavaScript Form Validation using a sample registration form. " />
<link rel='stylesheet' href='js-form-validation.css' type='text/css' />
<script src="sample-registration-form-validation.js"></script>
</head>
<body onload="document.registration.userid.focus();">
<h1>Registration Form</h1>
Use tab keys to move from one input field to the next.
<form name='registration' onSubmit="return formValidation();">
<ul>
<li><label for="userid">User id:</label></li>
<li><input type="text" name="userid" size="12" /></li>
<li><label for="passid">Password:</label></li>
<li><input type="password" name="passid" size="12" /></li>
<li><label for="username">Name:</label></li>
<li><input type="text" name="username" size="50" /></li>
<li><label for="address">Address:</label></li>
<li><input type="text" name="address" size="50" /></li>
<li><label for="country">Country:</label></li>
<li><select name="country">
<option selected="" value="Default">(Please select a country)</option>
<option value="AF">Australia</option>
<option value="AL">Canada</option>
<option value="DZ">India</option>
<option value="AS">Russia</option>
<option value="AD">USA</option>
</select></li>
<li><label for="zip">ZIP Code:</label></li>
<li><input type="text" name="zip" /></li>
<li><label for="email">Email:</label></li>
<li><input type="text" name="email" size="50" /></li>
<li><label id="gender">Sex:</label></li>
<li><input type="radio" name="msex" value="Male"
/><span>Male</span></li>
<li><input type="radio" name="fsex" value="Female"
/><span>Female</span></li>
<li><label>Language:</label></li>
<li><input type="checkbox" name="en" value="en" checked
/><span>English</span></li>
<li><input type="checkbox" name="nonen" value="noen" /><span>Non
English</span></li>
<li><label for="desc">About:</label></li>
<li><textarea name="desc" id="desc"></textarea></li>
<li><input type="submit" name="submit" value="Submit" /></li>
</ul>
</form>
</body>
</html>
TEXT.CSS
h1 {
margin-left: 70px;
}
form li {
list-style: none;
margin-bottom: 5px;
}
form ul li label{
float: left;
clear: left;
width: 100px;
text-align: right;
margin-right: 10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:14px;
}
form textarea {
float: left;
width: 350px;
height: 150px;
}
[type="submit"] {
clear: left;
margin: 20px 0 0 230px;
font-size:18px
}
p{
margin-left: 70px;
font-weight: bold;
}
formValidation.JS
function formValidation()
{
var uid = document.registration.userid;
var passid = document.registration.passid;
var uname = document.registration.username;
var uadd = document.registration.address;
var ucountry = document.registration.country;
var uzip = document.registration.zip;
var uemail = document.registration.email;
var umsex = document.registration.msex;
var ufsex = document.registration.fsex; if(userid_validation(uid,5,12))
{
if(passid_validation(passid,7,12))
{
if(allLetter(uname))
{
if(alphanumeric(uadd))
{
if(countryselect(ucountry))
{
if(allnumeric(uzip))
{
if(ValidateEmail(uemail))
{
if(validsex(umsex,ufsex))
{
}
}
}
}
}
}
}
}
return false;
}
userid_validation.JS
function userid_validation(uid,mx,my)
{
var uid_len = uid.value.length;
if (uid_len == 0 || uid_len >= my || uid_len < mx)
{
alert("User Id should not be empty / length be between "+mx+" to "+my);
uid.focus();
return false;
}
return true;
}
Q. 2)Consider text paragraph.So, keep working. Keep striving. Never give up.
Fall down seven times, get up eight. Ease is a greater threat to progress than
hardship. Ease is a greater threat to progress than hardship. So, keep moving,
keep growing, keep learning. See you at work.Preprocess the text to remove
any special characters and digits. Generate the summary using extractive
summarization process.
-->
pip install nltk
import nltk
nltk.download('punkt')
from nltk.tokenize import sent_tokenize
from nltk.tokenize import word_tokenize
paragraph_text = """Hello all,Welcome to python programming
academy.python
programming academy is a nice platform to learn new programming skills.It
is difficult to get enrolled in thin academy."""
tokenized_text_data = sent_tokenize(paragraph_text)
tokenized_words = word_tokenize(paragraph_text)
print("Tokenized sentences : \n",tokenized_text_data,"\n")
print("Tokenized words : \n",tokenized_words,"\n")
nltk.download('stopwords')
from nltk.corpus import stopwords
stop_words_data = set(stopwords.words("english"))
print(stop_words_data)
from nltk.tokenize import word_tokenize
from nltk.probability import FreqDist
tokenized_words = word_tokenize(paragraph_text)
frequency_distribution = FreqDist(tokenized_words)
print(frequency_distribution)
print(frequency_distribution.most_common(2))
import matplotlib.pyplot as plt
frequency_distribution.plot(32,cumulative = False)
plt.show()
slip 18
Q. 1) Write a Java Script Program to print Fibonacci numbers on onclick event.
Ans:-
<html>
<head><title>fabonnic series</title>
<script>
function fab(){
var A = 0;
var B = 1;
var C;
var N = document.getElementById("number").value;
document.write(A+"<br />");
document.write(B+"<br />");
document.write(C+"<br />");
}
}
</script>
</head>
<body>
<h2>
Please input any Number<input id="number" value="15">
<button type="button" onclick="fab()">fab</button>
</h2>
</body>
</html>
slip 19
Q. 1) create a student.xml file containing at least 5 student information
Ans:-
6.css
student{
display:block; margin-top:10px; color:Navy;
}
USN{
display:block; margin-left:10px;font-size:14pt; color:Red;
}
name{display:block; margin-left:20px;font-size:14pt; color:Blue;
}
college{
display:block; margin-left:20px;font-size:12pt; color:Maroon;
}
branch{
display:block; margin-left:20px;font-size:12pt; color:Purple;
}
year{
display:block; margin-left:20px;font-size:14pt; color:Green;
}
e-mail{
display:block; margin-left:20px;font-size:12pt; color:Blue;
}
Q. 2)Consider text paragraph."""Hello all, Welcome to Python Programming
Academy. Python Programming Academy is a nice platform to learn new
programming skills. It is difficult to get enrolled in this Academy."""Remove
the stopwords.
-->
slip 20
Q. 1) create a student.xml file containing at least 5 student information
Ans:-
6.css
student{
display:block; margin-top:10px; color:Navy;
}
USN{
display:block; margin-left:10px;font-size:14pt; color:Red;
}
name{display:block; margin-left:20px;font-size:14pt; color:Blue;
}
college{
display:block; margin-left:20px;font-size:12pt; color:Maroon;
}
branch{
display:block; margin-left:20px;font-size:12pt; color:Purple;
}
year{
display:block; margin-left:20px;font-size:14pt; color:Green;
}
e-mail{
display:block; margin-left:20px;font-size:12pt; color:Blue;
}
-->
slip 21
Q. 1)Add a JavaScript File in Codeigniter. The Javascript code should check
whether a number is positive or negative.
Ans:-
<!DOCTYPE html>
<html>
<head>
<style> * {font-family: Calibri;}
</style>
</head>
<body>
<h2>Checking if a given number is positive or negative using JavaScript
Comparative Operator.</h2>
<p>
<a
href='https://www.encodedna.com/javascript/operators/default.htm#compari
son_operator' target='_blank'>Learn more about Comparison Operators.</a>
</p>
</body>
<script>
const number = 12;
if (number < 0)
document.write (number + ' is negative');
else
document.write (number + ' is positive');
</script>
</html>
Q. 2)Build a simple linear regression model for User Data.
-->
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv("/root/sampada_vaibhavi/Data Anlytics/dataset/fish.csv")
df
print(df.shape)
print(df.isnull().sum())
new_df = df[['Height','Weight']]
new_df.sample(10)
X = np.array(new_df[['Height']])
Y = np.array(new_df[['Weight']])
print(X.shape)
print(Y.shape)
plt.scatter(X,Y,color="green")
plt.title('Height vs Weight')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
from sklearn.model_selection import train_test_split
X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size =
0.25,random_state=15)
X_train
X_test
from sklearn.model_selection import train_test_split
X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size =
0.25,random_state=15)
Y_train
Y_test
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train,Y_train)
plt.scatter(X_test,Y_test,color="red")
plt.plot(X_train,regressor.predict(X_train),color="cyan",linewidth=3)
plt.title('Regression(Test Set)')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
plt.scatter(X_train,Y_train,color="blue")
plt.plot(X_train,regressor.predict(X_train),color="red",linewidth=3)
plt.title('Regression(training Set)')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
from sklearn.metrics import r2_score,mean_squared_error
Y_pred = regressor.predict(X_test)
print('R2 score: %.2f' % r2_score(Y_test,Y_pred))
print('Mean Error :',mean_squared_error(Y_test,Y_pred))
slip 22
slip 23
slip 24
slip 25
slip 26
slip 27
slip 28
slip 29
Q. 1) Write a PHP script for the following: Design a form to accept a number
from the user. Perform the operations and show the results.
1) Fibonacci Series.
2) To find sum of the digits of that number.
(Use the concept of self processing page.)
Ans:-
<html>
<body bgcolor = "navyblue">
<form action = "<?php echo $_SERVER['PHP_SELF'] ?>" method = "POST">
Enter the first number:
<input type = "text" name = "n1" id = "n1"> <BR>
<input type = "submit" value = "submit">
</form>
<?php
$num = $_POST['n1'];
$n1 = 0;
$n2 = 1;
echo "<BR> Fibonacci series are:<BR>";
echo "<BR> $n1";
echo "<BR> $n2";
for($i = 1; $i<=$num-2; $i++)
{
$n3 = $n1 + $n2;
echo "<BR> $n3";
$n1 = $n2;
$n2 = $n3;
}
$temp = $num;
$sum=0;
while($temp!=0)
{
$sum += $temp % 10;
$temp = $temp / 10;
}
echo "<BR>sum of digits of ".$num." is :".$sum;
?>
</body>
</html>
Q. 2 ) Build a logistic regression model for Student Score Dataset.
-->
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv("/root/sampada_vaibhavi/Data Anlytics/dataset/fish.csv")
df
print(df.shape)
print(df.isnull().sum())
new_df = df[['Height','Weight']]
new_df.sample(10)
X = np.array(new_df[['Height']])
Y = np.array(new_df[['Weight']])
print(X.shape)
print(Y.shape)
plt.scatter(X,Y,color="green")
plt.title('Height vs Weight')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
from sklearn.model_selection import train_test_split
X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size =
0.25,random_state=15)
X_train
X_test
from sklearn.model_selection import train_test_split
X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size =
0.25,random_state=15)
Y_train
Y_test
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train,Y_train)
plt.scatter(X_test,Y_test,color="red")
plt.plot(X_train,regressor.predict(X_train),color="cyan",linewidth=3)
plt.title('Regression(Test Set)')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
plt.scatter(X_train,Y_train,color="blue")
plt.plot(X_train,regressor.predict(X_train),color="red",linewidth=3)
plt.title('Regression(training Set)')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
from sklearn.metrics import r2_score,mean_squared_error
Y_pred = regressor.predict(X_test)
print('R2 score: %.2f' % r2_score(Y_test,Y_pred))
print('Mean Error :',mean_squared_error(Y_test,Y_pred))
slip 30
Q. 1) Create a XML file which gives details of books available in “Bookstore”
from following categories.
1) Yoga
2) Story
3) Technical
and elements in each category are in the following format
<Book>
<Book_Title> --------------</Book_Title>
<Book_Author> ---------------</Book_Author>
<Book_Price> --------------</Book_Price>
</Book>
Save the file as “Bookcategory.xml”
Ans:-
Book.XML
Book.php
<?php
$xml=simplexml_load_file("Book.xml") or die("cannnot load");
$xmlstring=$xml->asXML();
echo $xmlstring;
?>
import pandas as pd
from mlxtend.frequent_patterns import apriori,association_rules
transactions = [['Bread','Milk'],['Bread','Diaper','Beer','Eggs'],
['Milk','Diaper','Beer','Coke'],
['Bread','Milk','Diaper','Beer'],[
'Bread','Milk','Diaper','Coke ']]
from mlxtend.preprocessing import TransactionEncoder
te = TransactionEncoder()
te_array=te.fit(transactions).transform(transactions)
df = pd.DataFrame(te_array,columns=te.columns_)
df
freq_items = apriori(df,min_support=0.5,use_colnames=True)
print(freq_items)
rules=association_rules(freq_items,metric='support',min_threshold=0.0)rules=
rules.sort_values(['support','confidence'],ascending[False,False])
print(rules)