public class Test {
private int id;
private String name;
public Test(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void display() {
System.out.println("id: " + id + " name: " + name);
}
}
def prime(n):
for i in range(2,n):
if n % i == 0:
return False
return True
n = int(input("Enter any number:"))
if prime(n):
print('Prime')
else:
print('Not prime')
function myFunction() {
var x = document.getElementById("fname");
document.getElementById("demo").innerHTML = x.value;
}
typescript
var mobileNo = /^\d{10}$/;
if (mobileNo.test(phone)) {
return true;
}
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
slides[slideIndex-1].style.display = "block";
setTimeout(showSlides, 2000); // Change image every 2 seconds
}
<script>
var images = [
"./assets/img/1.jpg",
"./assets/img/2.jpg",
"./assets/img/3.jpg",
"./assets/img/4.jpg",
"./assets/img/5.jpg"
];
var num = 0;
function next() {
var slider = document.getElementById("slider");
num++;
if (num >= images.length) {
num = 0;
}
slider.src = images[num];
}
function prev() {
var slider = document.getElementById("slider");
num--;
if (num < 0) {
num = images.length - 1;
}
slider.src = images[num];
}
function slider() {
window.setInterval(() => next(), 1000);
}
</script>
#for importing all the modules in one go
from flask import *
#for creating an app
app = Flask(__name__)
#for creating a route to python file on which we have to work
@app.route('/')
def abc():
return render_template('au.html')#this render_template is used to render the html file on the browser
if __name__ == '__main__':
app.run(debug=True)#this debug=True is used for auto reloading of the website when any changes are occured on the website
function fact(n) {
let fact = 1;
for(let i = 1; i <= n; i++) {
fact = fact * i;
}
return fact;
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class CreateTable {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
//step1 load the driver class
Class.forName("oracle.jdbc.driver.OracleDriver");
//step2 create the connection object
Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
//step3 create the statement object
Statement stmt=con.createStatement();
//step4 execute query
stmt.executeUpdate("create table employee(emp_id int,emp_name varchar(20))");
System.out.println("table created");
//step5 close the connection object
<script>
function evaluate(){
var a=parseInt(document.getElementById("a").value);
var b=parseInt(document.getElementById("b").value);
var c=parseInt(document.getElementById("c").value);
var d=parseInt(document.getElementById("d").value);
var e=parseInt(document.getElementById("e").value);
var f=parseInt(document.getElementById("f").value);
var g=parseInt(document.getElementById("g").value);
var h=parseInt(document.getElementById("h").value);
var i=parseInt(document.getElementById("i").value);
var result;
result=a+b+c+d+e+f+g+h+i;
alert(result);
}
</script>
var a = 10;
var b = 20;
var x = a + b;
var y = a - b;
var z = a * b;
var w = a % b;
alert(x);
alert(y);
alert(z);
alert(w);
<html>
<head>
<title>Example</title>
<script type="text/javascript">
function show_status()
{
window.status="hi i am status bar";
return true;
}
</script>
</head>
<body>
<a href="#" onmouseover="show_status();">link</a>
</body>
</html>
import java.io.*;
import java.net.*;
class ChatServer{
public static void main(String[] args){
try{
ServerSocket ss = new ServerSocket(5000);
Socket s = ss.accept();
DataInputStream din = new DataInputStream(s.getInputStream());
DataOutputStream dout = new DataOutputStream(s.getOutputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String msgin="", msgout="";
while(!msgin.equals("end")){
msgin = din.readUTF();
System.out.println(msgin);
msgout = br.readLine();
dout.writeUTF(msgout);
dout.flush();
}
s.close();
}catch(Exception e){
}
}
}
<select id="mySelect">
<option value="http://www.w3schools.com/tags/smiley.gif">Smiley face</option>
<option value="http://www.w3schools.com/tags/planets.gif">Planets</option>
<option value="http://www.w3schools.com/tags/mountain.jpg">Mountain</option>
<option value="http://www.w3schools.com/tags/sky.jpg">Sky</option>
</select>
<button type="button" onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.getElementById("mySelect").value;
window.open(x);
}
</script>
<script>
function myFunction() {
var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I
public class Employee {
private int emp_id;
private int emp_name;
// getters and setters
}
function myFunction() {
var x = document.getElementById("myDIV");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
function facto(num) {
if (num < 0) {
return -1;
}
else if (num == 0) {
return 1;
}
else {
return (num * facto(num - 1));
}
}
<script type="text/javascript">
function dropdownlist(listindex)
{
switch (listindex)
{
case "1" :
window.open("http://www.c-sharpcorner.com/","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400")
break;
case "2" :
window.open("http://www.c-sharpcorner.com/Code/2008/Feb/Expand-Collapse-Div-on-CheckBox-Click.aspx", "_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400")
break;
case "3" :
window.open("http://www.c-sharpcorner.com/forums/thread/194881/this-will-be-your-first-game-with-
class Hospital {
int id;
String name;
String address;
String contact;
Hospital(int id,String name,String address,String contact)
{
this.id=id;
this.name=name;
this.address=address;
this.contact=contact;
}
public void HospitalDetails()
{
System.out.println("Hospital ID : "+id);
System.out.println("Hospital Name : "+name);
System.out.println("Hospital Address : "+address);
System.out.println("Hospital Contact : "+contact);
}
}
class Doctor extends Hospital{
int did;
String dname;
String dspecial;
Doctor(int id,String name,String address,String contact,int did,String dname,String dspecial)
{
super(id,name,address,contact);
this.did=did;
this.dname=dname;
this.dspecial=dspecial;
}
public void DoctorDetails()
{
System.out.println("Doctor ID : "+did);
import java.sql.*;
public class TestDB {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/db", "root", "");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from Employee");
while (rs.next())
System.out.println(rs.getInt(1) + " " + rs.getString(2));
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
def main(a: int, b: int) -> int:
return a + b
function isMobile(n){
var phoneno = /^\d{10}$/;
if(n.match(phoneno))
return true;
else
return false;
}
var x = "John"
var y = new String("John")
// Outputs: false
console.log(x === y)
// Outputs: true
console.log(x == y)
function mobile(inputtxt){
var phoneno = /^\d{10}$/;
if((inputtxt.value.match(phoneno))){
return true;
}
else{
alert("Not a valid Phone Number");
return false;
}
}
public class Emp{
private int emp_id;
private String emp_name;
public int getEmp_id() {
return emp_id;
}
public void setEmp_id(int emp_id) {
this.emp_id = emp_id;
}
public String getEmp_name() {
return emp_name;
}
public void setEmp_name(String emp_name) {
this.emp_name = emp_name;
}
public Emp(int emp_id, String emp_name) {
this.emp_id = emp_id;
this.emp_name = emp_name;
}
}
def add(a: int, b: int) -> int:
return a + b
<html>
<head>
<title>Html and Javascript</title>
<script type="text/javascript">
function cal() {
var x = document.getElementById( "t1" ).value;
var y = document.getElementById( "t2" ).value;
var r = parseInt(x) + parseInt(y);
document.getElementById( "res" ).innerHTML = r;
}
</script>
</head>
<body>
<p>Enter first number: <input type="text" id="t1"/></p>
<p>Enter second number: <input type="text" id="t2"/></p>
<input type="button" value="Add" onclick="cal()"/>
<p>Result <span id="res"></span></p>
</body>
</html>
function factorial(n) {
var fact = 1;
while (n > 0) {
fact *= n;
n--;
}
return fact;
}
document.write(factorial(5));
package com.javatpoint.bean;
public class Employee{
private int id;
private String name;
//setters and getters
}
![](https://i.imgur.com/uZvJYj7.png)
var images = ['1.png', '2.png', '3.png', '4.png', '5.png', '6.png'];
var i = 0;
var myImage = document.getElementById('myImage');
myImage.onclick = function () {
if (i < images.length - 1) {
i++;
} else {
i = 0;
}
myImage.src = images[i];
}
<!DOCTYPE html>
<html>
<body>
<h2>HTML Forms</h2>
<form>
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
</form>
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
<form action="/action_page.php">
<label for="country">Choose a country:</label><br>
<select id="country" name="country">
<option value="australia">Australia</option>
<option
def foo(a, b, c=None, d=None):
pass
<form>
<input type="text" name="firstname" placeholder="First Name">
<input type="text" name="lastname" placeholder="Last Name">
<input type="password" name="password" placeholder="Password">
<input type="text" name="email" placeholder="Email">
<input type="submit" value="Register">
</form>
<script type="text/javascript">
$(document).ready(function(){
$("form").submit(function(e){
e.preventDefault();
$.ajax({
url:"register.php",
method: "POST",
data:$("form").serialize(),
dataType:"text",
success: function(strmessage){
$("#message").text(strmessage)
}
})
})
})
</script>
create table employee(emp_id int primary key, emp_name varchar(100))
var phoneno = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
if(inputtxt.value.match(phoneno))
{
return true;
}
else
{
alert("message");
return false;
}
const validateMobileNo = mobileNo => /^\d{10}$/.test(mobileNo);
var mobile = document.getElementById('mobile');
mobile.addEventListener('input', function (ev) {
if (this.value.length > 10) {
this.value = this.value.slice(0, 10);
}
}, false);
<!DOCTYPE html>
<html>
<body>
<form id="loginForm">
<label for="userName">Username:</label>
<input type="text" id="userName" name="userName" value="">
<label for="userPassword">Password:</label>
<input type="text" id="userPassword" name="userPassword" value=""><br><br>
<input type="submit" value="Submit">
</form>
<script>
var userName = document.getElementById("userName");
userName.addEventListener("input", function (event) {
console.log(`username input event ${event.target.value}`);
});
var userPassword = document.getElementById("userPassword");
userPassword.addEventListener("input", function (event) {
console.log(`userPassword input event ${event.target.value}`);
});
var loginForm = document.getElementById("loginForm");
loginForm.onsubmit=function(){
// first your validation code will go here
var age = prompt("What is your age?");
if (Number(age) < 18) {
alert("Sorry, you are too yound to drive this car. Powering off");
} else if (Number(age) > 18) {
alert("Powering On. Enjoy the ride!");
} else if (Number(age) === 18) {
alert("Congratulations on your first year of driving. Enjoy the ride!");
}
<html>
<body>
<script>
function myfunction()
{
document.getElementById("demo").innerHTML = Date();
}
</script>
<p id="demo">Click the button to display Date and Time.</p>
<button type="button" onclick="myfunction()">Date and Time</button>
</body>
</html>
a + b
a - b
a * b
a / b
def aurthonage(a: str, b: str) -> int:
return a - b
var regEx = new RegExp(/^\d{10}$/)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
public class Employee {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}