You are on page 1of 58

BTCS3550-Technical Training-III

(Application Development using Python)

Name : Kartik Kumar


Admission No:19SCSE1010575
B.Tech Sem 05 Elective sec : 05
Submitted to:
1. Problem Title: BankAccount Class
Create a Python class called BankAccountwhich represents a bank account, having as attributes:
accountNumber(numeric type), name (name of the account owner as string type), balance.

Create a constructor with parameters: accountNumber, name, balance.

Create a Deposit() method which manages the deposit actions.

Create a Withdrawal() method which manages withdrawals actions.

Create a bankFees() method to apply the bank fees with a percentage of 5% of the balance
account.

Create a display() method to display account details.

Give the complete code for the BankAccount class.

class BankAccount:

# create the constructor with parameters: accountNumber, name and balance

def __init__(self,accountNumber, name, balance):

self.accountNumber = accountNumber

self.name = name

self.balance = balance

# create Deposit() method

def Deposit(self , d ):

self.balance = self.balance + d

# create Withdrawal method

def Withdrawal(self , w):

if(self.balance < w):

print("impossible operation! Insufficient balance !")

else:

self.balance = self.balance - w

# create bankFees() method

def bankFees(self):
self.balance = (95/100)*self.balance

# create display() method

def display(self):

print("Account Number : " , self.accountNumber)

print("Account Name : " , self.name)

print("Account Balance : " , self.balance , " $")

# Testing the code :

newAccount = BankAccount(2178514584, "Albert" , 2700)

# Creating Withdrawal Test

newAccount.Withdrawal(300)

# Create deposit test

newAccount.Deposit(200)

# Display account informations

newAccount.display()

2. Problem Title: Person Class


Create a Python class Person with attributes: name and age of type string.

Create a display() method that displays the name and age of an object created via the Person
class.

Create a child class Student which inherits from the Person class and which also has a section
attribute.

Create a method displayStudent() that displays the name, age and section of an object created
via the Student class.

Create a student object via an instantiation on the Student class and then test the
displayStudent method.

class Person:

# define constructor with name and age as parameters

def __init__(self, name, age):

self.name = name
self.age = age

# create display method fro Person class

def display(self):

print("Person name : ", self.name)

print("Person age = ", self.age)

# create child class Student of Person class

class Student(Person):

# define constructor of Student class with section additional parameters

def __init__(self, name , age , section):

Person.__init__(self,name, age)

self.section = section

# Create display method for Student class

def displayStudent(self):

print("Student name : ", self.name)

print("Student age = ", self.age)

print("Student section = ", self.section)

# Testing Person class

P = Person("Tomas Wild", 37)

P.display()

print("-------------------------------")

S = Student("Albert", 23 , "Mathematics")

S.displayStudent()

3. Create a website with the following information and structure using


HTML5:
The contents of the home page should be:

- Logo and title of the website


- Navigation bar: links to presentation, studies and staff

- News (aside/article/section)

- Announcements (aside/article/section)

- Footer: contact information and copyright

Use these tags: <header>, <nav>, <aside>, <article>, <section>, <time>, <footer>.

Here logo image, news, announcements used can be any suitable data

Solution: HTML CODE:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title> GU WEBSITE</title>

<link rel="stylesheet" href="abc.css">

</head>

<body>

<div class="image">

<div class="navbar">

<img src="logoz.jpg" alt="" class="logo">

<p>GALGOTIAS UNIVERSITY</p>

<ul>

<li><a href="https://www.slideshare.net/deepakchand19762001/galgotias-university-
presentation"> PRESENTATION</a> </li>

<div class="dropdown">

<button class="dropbtn">STUDIES

<i class="fa fa-caret-down"></i>

</button>
<div class="dropdown-content">

<a href="https://www.shiksha.com/university/galgotias-university-greater-noida-
37105/courses/humanities-and-social-sciences-s">SOCIAL SCIENCES</a>

<a href="https://www.shiksha.com/university/galgotias-university-greater-noida-
37105/course-b-tech-in-civil-engineering-237402">ENGINEERING</a>

</div>

</div>

<li><a href="https://galgotiacollege.edu/faculty-of-mechanical-engineering"> STAFF</a>


</li>

</ul>

</div>

<div class="main">

<p> News & Announcement</p>

<marquee class="marq"

background-color="Green"

direction="up"

loop="">

<a href="https://timesofindia.indiatimes.com/home/education/news/galgotias-university-
to-open-deendayal-upadhyaya-higher-quality-center-for-students-from-weaker-sections/
articleshow/81094067.cms">Galgotias University to open 'Deendayal Upadhyaya Higher Qua ..

Read more at: http://timesofindia.indiatimes.com/articleshow/81094067.cms?


utm_source=contentofinterest&utm_medium=text&utm_campaign=cppst</a></marquee>

<marquee class="marq"

background-color="Green"

direction="up"

loop="">

<a href="https://www.firstpost.com/tag/galgotias-university">Galgotias University is


creating engineers ready to face the challenges of Industry 4.0</a></marquee>

</div>

</div>

<footer>
<p>Galgotias University</p>

<P>Call us at: 0120–4370000, +91 9582847072, 9810162221</P>

<p><a href="mailto:admissions@galgotiasuniversity.edu.in
">admissions@galgotiasuniversity.edu.in </a></p>

</footer>

</body>

</html>

CSS CODE:

*{

margin:0;

padding:0;

font-family:sans-serif;

.image {

width:100%;

height:100vh;

background-size:cover;

background-color:cadetblue;

background-position:center;

.logo {

width:100px;

height:70px;

float: left;

position: relative;

margin: 10px 15px 15px 10px;

.navbar {
width:85%;

margin:auto;

padding: 35px 0;

display: flex;

align-items:center;

justify-content:space-between;

color:white;

font-size:30px;

.navbar p {

margin-left:-200px;

.navbar ul li{

list-style:none;

display:inline-block;

margin: 0 20px;

.navbar ul li a{

text-decoration:none;

color:white;

.navbar ul li a:hover{

color:yellow;

.navbar a {

float: left;

font-size: 24px;

color: white;
text-align: center;

padding: 14px 16px;

text-decoration: none;

.dropdown {

float: left;

overflow: hidden;

/* Dropdown button */

.dropdown .dropbtn {

font-size: 24px;

border: none;

outline: none;

color: white;

padding: 14px 16px;

background-color: inherit;

font-family: inherit; /* Important for vertical align on mobile phones */

margin: 0; /* Important for vertical align on mobile phones */

.dropdown-content {

display: none;

position: absolute;

background-color: #f9f9f9;

min-width: 160px;

box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);

z-index: 1;

.dropdown-content a {
float: none;

color: black;

padding: 12px 16px;

text-decoration: none;

display: block;

text-align: left;

.dropdown-content a:hover {

background-color: #ddd;

/* Show the dropdown menu on hover */

.dropdown:hover .dropdown-content {

display: block;

.main p{

margin-top:50px;

margin-bottom: 50px;

font-weight:bold;

font-size:28px;

OUTPUT:
4. Design below form using HTML5
-City is drop down list with multiple city names

-Name, mobile number, address are mandatory fields. If any of these field is empty, after clicking
submit button, it should show like this.

Index.html

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8" />

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>Visitor Form</title>

<link rel="stylesheet" type="text/css" href="style.css" />

</head>

<body>

<h1>Visitor Entry Form</h1>

<table align="centre" cellpadding="10"></table>

<div class="register">

<form method="post" id="register" action="">


<tr>

<td>Name</td>

<td>

<input

type="text"

name="Name"

id="name"

placeholder="Enter your name"

required

/><br />

</td>

</tr>

<tr>

<td>

Gender

<input type="radio" name="gender" value="male" />

Male

<input type="radio" name="gender" value="female" />

Female

</td>

</tr>

<tr>

<br />

<td>Mobile Number</td>

<td>

<input

type="number"

name="Mnum"
id="num"

placeholder="Enter your mobile number"

/>

<br />

</td>

</tr>

<tr>

<td>Address</td>

<td>

<input

type="text"

name="address"

id="address"

placeholder="Enter your address"

/><br />

</td>

</tr>

<tr>

<td>City</td>

<select id="City" name="City">

<option value="none" selected disabled hidden>select</option>

<option value="Chandigarh">Chandigarh</option>

<option value="Delhi">Delhi</option>

<option value="Varanasi">Varanasi</option>

</select>

<br />

</tr>

<tr>
<td id="knowledge">How do you come to know about us</td>

<input type="radio" name="knowledge" value="knowledge" />

Tv news

<input type="radio" name="knowledge" value="knowledge" />

Internet

</tr>

<br /

<tr>

<td align="center" colspan="2">

<input type="submit" value="submit" />

&nbsp;&nbsp; <input type="submit" value="reset" />

</td>

</tr>

</form>

</div>

</body>

</html>

Style.css

body {

text-align: center;

margin: 0;

font-family: verdana;

font-size: 15px;

h1 {

margin: 10px 250px;

font-size: 40px;

}
table,

th,

td {

border: 1px solid black;

td,

th {

padding: 10px;

#divRegister {

margin: 10px 0 0 0;

#Name {

margin-left: 46px;

#Gender {

margin-left: -12px;

padding-right: 56px;

#Address {

margin-left: 12px;

#divFooter {

margin: 50px 0 0 400px;}

input,

select,

button {

margin: 0.5% 0;
}

#knowledge {

padding: 5px;

Output :

5. Problem Description
1. To Create this HTML Application, create a folder called TestCSS.

2. create a file called TableWithCSS.html

3. In the body tag, create a table with header, table rows and table data.

4. Use Internal CSS and provide styles as in sample output

5. Use any png image as background to table header with border radius of 6px.Refer to output
for color, height, width and font-size.

6. For the table, provide collapse to border-collapse attribute

7. For table data provide border of 1 px dotted and padding of 15px, width 100px, refer to other
properties and background color as in output

8. Run the Application in Live Server as http://127.0.0.1:5500/TableWithCSS.html

9. Or open the Application in browser

TableWithCSS.html

<!DOCTYPE html>
<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="style.css">

<title>Document</title>

</head>

<body>

<table class = "table-img">

<tr>

<td>

<center>

<img src="image/image.png" alt="">

</center>

</td>

</tr>

</table>

<table class = "table-data">

<tbody>

<tr>

<center>

<th>Name</th>

<th>Gender</th>

<th>Mobile Number</th>

<th>Address</th>

<th>City</th>

<th>Country</th>
</tr>

<tr>

<td >zdev</td>

<td >MALE</td>

<td >9214143454</td>

<td >f329/435 ks-1 </td>

<td >Varanasi</td>

<td >india</td>

</tr>

<tr>

<td >zdev</td>

<td >MALE</td>

<td >9214143454</td>

<td >f329/435 ks-1 </td>

<td >Varanasi</td>

<td >india</td>

</tr>

<tr>

<td >zdev</td>

<td >MALE</td>

<td >9214143454</td>

<td >f329/435 ks-1 </td>

<td >Varanasi</td>

<td >india</td>

</tr>

<tr>

<td >zdev</td>

<td >MALE</td>
<td >9214143454</td>

<td >f329/435 ks-1 </td>

<td >Varanasi</td>

<td >india</td>

</tr>

<tr>

<td >zdev</td>

<td >MALE</td>

<td >9214143454</td>

<td >f329/435 ks-1 </td>

<td >Varanasi</td>

<td >india</td>

</tr>

</center>

</tbody>

</table>

</body>

</html>

Style.css

.table-img img {

border: 6px solid rgb(69, 212, 176);

border-radius: 6px;
height: 30%;

width: 30%;

.table-data th {

width: 100px;

border: 1px dotted;

padding: 15px;

background-color: #e20e0e;

border-spacing: 0px;

.table-data td {

background-color: aqua;

6. Problem Description ()

1. To Create this HTML Application, create a folder called Telephone.

2. create a file called TelephoneComplaint.html

3. In the body tag create a form and table as shown in sample output with the labels and input
types as shown.

4. Include the following options under Nature of Complaint

5. 1.Disconnection Problem

2.Phone Dead

3.Other

6. Create a TelephoneComplaint.css file and define the CSS properties here as per sample output

7. Link CSS file to HTML file.

8. Run the Application in Live Server as http://127.0.0.1:5500/TelephoneComplaint.html

or open the Application in the browser.


7. Problem Description

1. To Create this HTML Application, create a folder called pyramid.

2. Create a file called pyramid.html

3. Use internal JS and define a function called buildPyramid with the number of rows as
parameter

4. Write the logic to construct a pyramid in the function.

5. Invoke the function with any value as row argument.

6. Open the application in browser or run in Live Server with URL as


http://127.0.0.1:5500/pyramid.html

Sample Input 1: for 5 rows

Sample output 1:

<!DOCTYPE html>

<html>

<head>

<script>

function pyramid(n) {

for(let i=1; i<= n; i++){

let str = ' '.repeat(n-i);

let str2 = '*'. repeat(i*2 -1)

console.log(str + str2 + str);

pyramid(5);

</script>

</head>

<body>

<h2>Demo JavaScript in Head</h2>

<button type="button" onclick="pyramid()">Try it</button>


</body>

</html>

Sample Input 2: for 6 rows

Sample Output 2:

<!DOCTYPE html>

<html>

<head>

<script>

function pyramid(n) {

for(let i=1; i<= n; i++){

let str = ' '.repeat(n-i);

let str2 = '*'. repeat(i*2 -1)

console.log(str + str2 + str);

pyramid(6);

</script>

</head>

<body>

<h2>Demo JavaScript in Head</h2>

<button type="button" onclick="pyramid()">Try it</button>

</body>

</html>

8. Problem Description

For this Application, use the existing application TelephoneComplaint.html created in folder
Telephone under section 4.3

Modify the HTML page to include the below validations in JavaScript


1. Subscriber Name is required and should have max length of 10.

2. validate Email to have @ and. symbol.

3. Registered Mobile number should be 10 digits

Detailed Complaint Description box should be disabled initially, and when user chooses Other
option in Nature of Complaint, Description box should get enabled and get disabled when a
subscriber changes the Nature Of Complaint to something else. (Disconnection Problem/Phone
Dead).

Hint: Use onchange event and write JS Code in function enableDisableTextBox(this) to


enable/disable description box. This refers to the option currently selected

Complaint raised date should be current date and shouldn’t be changed, it should be readyonly
and the date should be populated as soon as the form loads in browser.

Hint: write code in JS function getDate() to load current date.

Invoke this function using window.onload.

Open the application in browser or in LiveServer with URL as


http://127.0.0.1:5500/TelephoneComplaint.html

Experiment - 8

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Telephone Complaint</title>

<style>

body {

background-color: #5f5f60ba; }

label {

display: inline-block;

width: 204px;
text-align: left;

margin: 5px;

padding: 8px;

.label {

border-width: 2px;

border-radius: 5px;

margin: 5px;

padding: 7px;

width: 221px;

#Business {

text-align: right;

.Tab {

margin-left: 14.65em;

.maindiv {

background-color: rgb(175 174 174 / 281%);

width: 500px;

margin: auto;

border-radius: 10px; }

.sub {

margin-left: 14.5em;

width: 10px;}

#Submit:hover {

background-color: rgb(127, 126, 128);

}
#detailed {

width: 218px;

height: 55px;}

#ddlModels {

width: 236px;}

.Heading {

margin-left: 400px;

padding-left: 75px;}

</style>

</head>

<body>

<div class="Heading">

<h1>Telephone Complaint Registration Form</h1>

</div>

<div class="maindiv">

<form name="Register_complain" onSubmit="return formValidation();">

<div class="Label">

<label for="tel">Enter Subscriber Id</label>

<input type="tel" name="Id" class="label" id="tel" placeholder="Enter Subscriber Id">

</div>

<br>

<div class="Label">

<label for="Name">Subscriber Name</label>

<input type="text" name="Name" class="label" id="Name" placeholder="Enter


Subscriber Name" required>

</div>

<br>

<div class="Label">
<label for="Address">Address</label>

<input type="text" name="Add" class="label" id="Address" placeholder="Enter the


Address">

</div>

<br>

<div class="Label">

<label for="phone">Registered Mobile Number</label>

<input type="tel" name="Phone" class="label" id="phone"

placeholder="Enter the Registered mobile number">

</div>

<br>

<div class="Label">

<label for="Email">Registered Email ID</label>

<input type="email" name="Email" class="label" id="Email" placeholder="Enter the


Registered Email Id">

</div>

<br>

<div class="Label">

<label for="Label">Subscriber Category</label>

<input type="radio" name="subscriber"> Residential Home User

<br>

<div class="Tab">

<input type="radio" name="Subscriber" id="Business"> SVE User

</div>

</div>

<br>

<div class="Label">

<label for="Label">Nature of Complaint</label>


<select name="other" class="label" id="ddlModels"
onchange="EnableDisableTextBox(this)">

<option value="1">Select</option>

<option value="2">Home</option>

<option value="3">Office</option>

<option value="4">Other</option>

</select>

</div>

<br>

<div class="Label">

<label for="detailed">Detailed Complaint Description</label>

<input type="text" name="Detailed" class="label" id="detailed" disabled="disabled"

placeholder="Enter Detailed Complaint Description">

</div>

<br>

<div class="Label">

<label for="date">Complaint Raised Date</label>

<input type="date" name="date" class="label" id="date">

</div><br>

<div class="sub">

<input type="submit" name="submit" value="Submit" class="label" id="Submit">

</div>

</form>

</div>

</body>

<script>

function EnableDisableTextBox(ddlModels) {

var Selectedvalue = ddlModels.options[ddlModels.selectedIndex].value;


var detailed = document.getElementById("detailed");

detailed.disabled = Selectedvalue == 4 ? false : true;

if (!detailed.disabled) {

detailed.focus();}}

function formValidation() {

var Subscriberid = document.Register_complain.Id;

var Subscribername = document.Register_complain.Name;

var Address = document.Register_complain.Add;

var Register_mobile = document.Register_complain.Phone;

var Register_email = document.Register_complain.Email;

var Residential_user = document.Register_complain.subscriber;

var SVE_User = document.Register_complain.Subscriber;

var Nature_Complain = document.Register_complain.other;

var Detailed_description = document.Register_complain.Detailed;

var Complain_date = document.Register_complain.date;

if (Subscribername.value.length > 10) {

alert("Name can't be greater than 10 character");

Subscribername.focus();

return false;

if (Register_mobile.value.length != 10) {

alert("Mobile number must be of 10 digits only");

Register_mobile.focus();

return false; }

function ValidateEmail(inputText) {

var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

if (Register_email.value.match(mailformat)) {
return true; } }

alert("Your Complain is registered successful.");

return true;}

</script>

</html>

Sample Output when form loads on browser (Assume sysdate/currentDate is 20-07-2021)

Sample Output when NatureOf Complaint is chosen as Other

9. Problem Description

Zip codes consist of 5 consecutive digits. Given a string, write a JavaScript function
isValid(zipCode) to determine whether the input is a valid zip code.

A valid zip code is as follows:

Must only contain numbers (no non-digits allowed).

Must not contain any spaces.

Must not be greater than 5 digits in length.

Examples:

isValid("59001") ➞ true

isValid("853a7") ➞ false

isValid("732 32") ➞ false

isValid("393939") ➞ false

Solution Code :

const zipCodeRegex = /^(0|[1-9][0-9]*)$/

const isValid = (zipCode) => {

if (zipCode.length !== 5) {

return false}

return zipCodeRegex.test(zipCode)}

const main = () => {

const zipCode = "59001"


if (isValid(zipCode)) {

console.log(true)

} else {

console.log(false)}}

main()

10. Problem Description

A group of friends have decided to create a secret code which will be used to login their
application. This code will be the first letter of their names, sorted in alphabetical order and
count of group members.

Create a function that takes in an array of names and returns the secret code.

Examples:

findCode(["Adam", "Sarah", "Malcolm"]) ➞ "AMS3"

findCode(["Harry", "Newt", "Luna", "Cho"]) ➞ "CHLN4"

findCode(["Phoebe", "Chandler", "Rachel", "Ross", "Monica", "Joey"]) ➞ "CJMPRR6"

Note

The secret code name should entirely uppercased

Solution :

Aditya Shrivastav - 19SCSE1010018

const findCode = (names) => {

if (!Array.isArray(names))

return 'Error: PLEASE PASS A VALID INPUT'

let sortedNames = names.sort();

let code = '';

sortedNames.forEach((name) => {

code += name.charAt(0).toUpperCase()})

code += names.length;
return code;}

11. Problem Description

1. To Create this application, create a folder called DomManipulation.

2. Create a HTML file called dom.html with hyperlink for the paragraph text

3. “[On mouse hover here bold words of the following paragraph will be highlighted]”

4. Include 2 events onMouseOver and onMouseOut for the above hyperlink. For onMouseOver
define a function highlight() and for onMouseOut define a function return_normal.

5. Include the other paragraph having bold(strong) and non bold text as in output.

6. Create an external JS called dom.js and link to html file.

7. Define following functions in dom.js such that when window loads, it invokes function
getBold_items().

8. getBold_items() gets all the bold tags with tagname strong and stores it.

9. highlight() iterates all stored bold tags and changes color to red.

10. return_normal() makes all highlighted words dark once the mouse is moved out from
hyperlink

11. Open the html application in browser or run in LiveServer with URL
http://127.0.0.1:5500/dom.html

Sample Output: On loading the page in browser

Sample output-1 when mouse is moved over hyperlink

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

</head>

<body>
<a href = "#Para " id="e"> [On mouse hover here bold words of the following paragraph will be
highlighted] </a>

<p><b id = "Para">We</b> have just started <b id = "Para2">this</b> section for the users (<b
id = "Para3">beginner</b> to intermediate) who <b id = "Para4">want</b> to work with <b id =
"Para5">various</b> JavaScript <b id = "Para6">problems</b> write scripts online to <b id =
"Para7">test</b> their JavaScript <b id = "Para8">skill</b>. </b>

</body>

<script>

document.getElementById("e").onmouseover = function() {mouseOver()};

document.getElementById("e").onmouseout = function() {mouseOut()};

function mouseOver() {

document.getElementById("Para").style.color = "red";

document.getElementById("Para2").style.color = "red";

document.getElementById("Para3").style.color = "red";

document.getElementById("Para4").style.color = "red";

document.getElementById("Para5").style.color = "red";

document.getElementById("Para6").style.color = "red";

document.getElementById("Para7").style.color = "red";

document.getElementById("Para8").style.color = "red";

function mouseOut() {

document.getElementById("Para").style.color = "Black";

document.getElementById("Para2").style.color = "Black";

document.getElementById("Para3").style.color = "Black";

document.getElementById("Para4").style.color = "Black";

document.getElementById("Para5").style.color = "Black";

document.getElementById("Para6").style.color = "Black";

document.getElementById("Para7").style.color = "Black";

document.getElementById("Para8").style.color = "Black";}
</script>

</html>

Before mouse Hover

After mouse Hover

12. Using DOM Manipulation create a dynamic shopping List as below

index.html

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8" />

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link rel="stylesheet" href="./styles/style.css" />

<title>Document</title>

</head>

<body>

<div class="container">

<h1>My shopping list</h1>

<div class="item-div">

<label for="input"

>Enter a new item:

<input type="text" class="input" />

<button class="addBtn">Add Item</button>

</label>

</div>

<div class="output">

<ul>
<li>

Milk

<button class="deleteBtn">Delete</button>

</li>

<li>

Veggies

<button class="deleteBtn">Delete</button>

</li>

<li>

Chocolate

<button class="deleteBtn">Delete</button>

</li>

</ul>

</div>

</div>

<script src="./scripts/script.js"></script>

</body>

</html>

Script.js

var input = document.querySelector(".input");

var addBtn = document.querySelector(".addBtn");

var outputList = document.querySelector("ul");

addBtn.addEventListener("click", function () {

var inputValue = input.value;

var listItemNode = document.createElement("li");

var listItemText = document.createTextNode(inputValue);

listItemNode.appendChild(listItemText);
var delBtn = document.createElement("button");

var delBtnText = document.createTextNode("Delete");

delBtn.className = "deleteBtn";

delBtn.appendChild(delBtnText);

listItemNode.appendChild(delBtn);

outputList.append(listItemNode);

input.value = "";});

outputList.addEventListener("click", function (e) {

if (e.target.classList.contains("deleteBtn")) {

let li = e.target.parentNode;

outputList.removeChild(li);}});

style.css

li {

margin: 20px;

As items are entered, it gets added as below with the option to delete

When Chocolates is deleted, the List should be

13. Problem Title: Create Student table

Refer the below schema, and create the student table.

CREATE TABLE mark(

value number,

subject_id number,

student_id number,

constraint pk primary key(subject_id,student_id),

constraint fk foreign key(subject_id,student_id) references


subject(subject_id,student_id));

CREATE TABLE department(


department_id number(2),

department_name varchar(30),

department_block_number number,

constraint PK primary key(department_id));

CREATE TABLE student(

student_id number,

student_name varchar(30),

address varchar(40),

city varchar(30),

department_id number,

constraint pk primary key(student_id),

constraint fk foreign key(department_id) references department(department_id));

CREATE TABLE staff(

staff_id number,

staff_name varchar(30),

department_id number,

constraint pk primary key(staff_id),

constraint fk foreign key(department_id) references department(department_id));

14. Problem Title: Insert Records – Tickets

Insert the below records into the tickets table.

CREATE TABLE tickets (

Ticket_id varchar(4),

Schedule_id varchar(4) ,

User_id int,

No_seats int);

insert into tickets values('T2', 'S2', 5, 1);

insert into tickets values('T1', 'S5', 1, 2);


select * from tickets;

15. Problem Title: Department name based on block number

Write a query to display the names of the departments in block number 3 in ascending order.

CREATE TABLE department (

department_id INTEGER PRIMARY KEY,

department_name TEXT NOT NULL,

department_block_number INTEGER NOT NULL

);

-- insert some values

INSERT INTO department VALUES (1, 'SCSE', 3);

INSERT INTO department VALUES (4, 'LAW', 2);

INSERT INTO department VALUES (2, 'ELEC', 3);

INSERT INTO department VALUES (3, 'MECH', 3);

select department_name from department where department_block_number=3 order by


department_name asc;

16. Problem Title: Students Name based on Start and Ending Character

Write a query to display the names of the students that start with letter 'A' and end with the
letter 'a', ordered in ascending order.

select * from table where firstname like 'A%' and lastname like '%a'

select columns

from table

where (

column like 'A%'

or column like 'a%' )

order by column asc;


17. Problem Title: Number of departments

select department_block_number

from department

where department_id in (select max(department_id)

from department group by department_block_number);

18. Problem Title: Subject with Staff Details

Write a query to display the subjectname, code and staff name who handles that subject,
ordered by code in ascending order.

Code:-

select staff_name from Staff

where staff_id NOT IN(

select staff_id from Subject)

order by staff_name;

select staff_name,subject_name,value as max_mark

from subject

join staff using(staff_id

join mark using(subject_id)

where(staff_id,value

in(select staff_id,max(value)

from subject group by staff_id)

order by max_mark desc;

19. Problem Title: Maximum mark in Subject with Staff name

Write a query to display list of staff name, subject name handled and maximum mark scored
in that subject. Give an alias to the maximum mark as max_mark. Sort the result based on
maximum mark in descending

Solution

Select st.staff_name, s.subject_name,


max(m.value) as max_marks

From staff st

join subject s

On st.staff_id = s.staff_id

Join marks m

on m.subject_id = s.subject_id

Group by st.staff_name, s.subject_name, st.staff_id

20. Problem Title: Salesmen from New York

Write a query to create a view for those salesmen belongs to the city New York.

Refer the following table

table: salesman

salesman_id | name | city | commission

-------------+------------+----------+------------

5001 | James Hoog | New York | 0.15

5002 | Nail Knite | Paris | 0.13

5005 | Pit Alex | London | 0.11

5006 | Mc Lyon | Paris | 0.14

5007 | Paul Adam | Rome | 0.13

5003 | Lauson Hen | San Jose | 0.12

CREATE VIEW newyorkstaff

AS SELECT *

FROM salesman

WHERE city = 'New York';

Sample table: salesman

21. Problem Title: Create Index on Customer table

Create an index named customer_name for the cust_name column of the customer table
Refer the following schema

CREATE INDEX cust_name_idx ON customers (cust_name);

Soln-

Input

Create table customer (

Cust_ID int (7) ,

Cust_Name varchar( 30 ) ,

Cust_Address1 varchar (20) ,

Cust_Address2 varchar (30) ,

Pincode int(6) ,

Cust_Phone varchar(10)) ;

22. Problem Title: Create Sequence

Write a PL/SQL query to create an ascending sequence called id_seq, starting from 10,
incrementing by 10, minimum value 10, maximum value 100.

CREATE SEQUENCE id_seq

INCREMENT BY 10

START WITH 10

MINVALUE 10

MAXVALUE 100

CYCLE

CACHE 2;

23. Problem Title: Use Sequence in a Table Column

Create a new table called tasks with the below DDL query

CREATE TABLE tasks(id NUMBER PRIMARY KEY, title VARCHAR2(255) NOT NULL);

Create a sequence called task_id_seqfor the id column of the tasks table and use it while
inserting records to the tasks table:
Solution:

STEP 1: First, create a new table called tasks:

CREATE TABLE tasks(

id NUMBER PRIMARY KEY,

title VARCHAR2(255) NOT NULL

);

STEP 2: Create a sequence for the id column of the tasks table:

CREATE SEQUENCE task_id_seq;

STEP 3: Insert data into the tasks table:

INSERT INTO tasks(id, title)

VALUES(task_id_seq.NEXTVAL, 'Create Sequence in Oracle');

INSERT INTO tasks(id, title)

VALUES(task_id_seq.NEXTVAL, 'Examine Sequence Values');

STEP 4: query data from the tasks table:

SELECT

id, title

FROM

Tasks;

Output

Refer below schema

Create a synonym called stocks for the inventories table and use it in place of the actual table
name in the select query.

Solution:

CREATE SYNONYM stocks

FOR inventories;

SELECT * FROM stocks;

24. Problem Title: Granting all privileges to a new user


Create a new user called super with a password super@123 and grant all privileges to the
super user. Later query the super user’s privileges.

use mysql;

select user from user;

CREATE USER abc@localhost IDENTIFIED BY ‘abc123’;

GRANT ALL PRIVILEGES ON * . * TO super@123;

GRANT CREATE, SELECT, INSERT ON * . * TO super@123;

FLUSH PRIVILEGES;

SHOW GRANTS for username;

desc mysql.user;

select user,host,account_locked from mysql.user;

25. Problem Title: Personal Details

Write a program using Python for accepting your personal details and display the same. You
should read the following values from the console. Use appropriate variable names and types
to represent and store personal details in the memory.

First Name

Last Name

Date of Birth

Address

Phone Number

Refer the below given sample input and output for the formatting specification

Sample Input 1

Enter your first name: John

Enter your last name: Butler

Enter your date of birth: 25/12/1990

Enter your address: NYC, US

Enter your phone number: 636-48018


Sample Output 1

John Butler’s details are,

First Name: John

Last Name: Butler

DOB: 25/12/1990

Address: NYC, US

Phone: 636-48018

Source code:-

f = input("Enter your First name: ")

l = input("Enter your Last name: ")

d = input("Enter your Date of Birth: ")

a = input("Enter your Address: ")

P = input("Enter your Phone Number: ")

print("John Butler’s details are,")

print()

print()

print("First name:", f)

print("Last name:", l)

print("Date of Birth", d)

print("Address", a)

print("Phone Number", P)

26. Problem Title: Converting the Data

Write a Python program to convert the given string type to other types such as int and float.

Input String: “123”

Also print the source and target types using type().

Program
a = '123'

b = '3'

print(type(a))

print(type(b))

a = float(a)

# convert b using int

b = int(b)

print(type(a))

print(type(b))

print(a)

print(b)

27. Problem Title: Random Numbers

Write a Python program to create a list of random integers and randomly select multiple items
from the said list. Use random.sample()

CODE :-

print("Create a list of random integers:")

population = range(0, 100)

nums_list = random.sample(population, 10)

print(nums_list)

no_elements = 4

print("\nRandomly select",no_elements,"multiple items from the said list:")

result_elements = random.sample(nums_list, no_elements)

print(result_elements)

no_elements = 8

print("\nRandomly select",no_elements,"multiple items from the said list:")

result_elements = random.sample(nums_list, no_elements)

print(result_elements)
28. Problem Title: Current Date

Write a Python program to import the datetime module and display the current date Program

from datetime import date

today = date.today()

print("Today's date:", today)

29. Problem Title: Class and Object

Create a class named MyClass, with a property named x. Set some value to x. Later, create an
object named p1, and print the value of x.

class Person:

def __init__(self, name, age):

self.name = name

self.age = age

p1 = Person("John", 36)

print(p1.name)

print(p1.age)

30. Problem Title: Dog Class

Create Dog class which has the following specification:

Dogs consume their energy by barking and gain energy by sleeping

A fresh Dog instance has 10 units of energy

Dog has a method sleep which gives 2 units of energy

Dog has a method bark which consumes 1 unit of energy

Dog has a method get_energy which returns the amount of energy left.

Code:

class Dog:

def __init__(self, energy):


self.energy = energy

def sleep(self):

ei=self.energy+2

return ei

def bark(self):

ec=self.energy-1

return ec

p1 = Dog(10)

print(p1.sleep())

print(p1.bark())

31. Problem Title: Class Inheritance(Ishita Sharma 19SCSE1010504)

Create a class named Person, with firstnameand lastnameproperties, and a printnamemethod.


Afterwards, create another class named Student, which will inherit the properties and
methods from the Person class.

class Person:

def __init__(self, name, age):

self.name = name

self.age = age

p1 = Person("Ishita", 21)

print(p1.name)

print(p1.age)

32. Problem Title: Vehicle Details Create a Vehicle class with name, max_speedand mileage
instance attributes. Create a Bus child class that inherits from the Vehicle class and use all the
instance attributes for capturing the details of a bus and display the same. The method name
can be displaydetails()

Solution:

class Vehicle:

def __init__(self, name, max_speed, mileage):


self.name = name

self.max_speed = max_speed

self.mileage = mileage

class Bus(Vehicle):

def displaydetails(self):

print("Vehicle Name: " , self.name)

print("Speed: " , self.max_speed)

print("Mileage: ", self.mileage)

pass

School_bus = Bus("Volvo", 180, 12)

School_bus.displaydetails()

33. Write a Python program to get a string made of the first 2 and the last 2 chars from a
given a string. If the string length is less than 2, return instead of the empty string.

Sample Input 1

'w3resource'

Sample Output 1

'w3ce'

Sample Input 2

'w'

Sample Output 2

Empty String

CODE:

def string_both_ends(str):

if len(str) < 2:

return ''

return str[0:2] + str[-2:]

print(string_both_ends('w3resource'))
print(string_both_ends('w3'))

print(string_both_ends('w'))

34. Problem Title: Swapping the Elements of a List Given a list in Python and provided the
positions of the elements, write a program to swap the two elements in the list.

Sample Input 1

List = [23, 65, 19, 90], pos1 = 1, pos2 = 3

Sample Output 1

[19, 65, 23, 90]

Sample Input 2

List = [1, 2, 3, 4, 5], pos1 = 2, pos2 = 5

Sample Output 2

[1, 5, 3, 4, 2]

35. Problem Title: Min and Max in the Set Write a Python program to get the maximum and
minimum element in a set, using the built-in functions of Python

CODE:

def MIN(sets):

return(min(sets))

def MAX(STES):

return(max(sets))

# Driver Code

sets = set([8, 16, 24, 1, 25, 3, 10, 65, 55])

print(" min is ",MIN(sets))

print(" max is ",MAX(sets))

Output:

min is 1 and max is 65

Sample Input
set = ([8, 16, 24, 1, 25, 3, 10, 65, 55])

Sample Output

min is 1 and max is 65

36. Problem Title: Number and its Cube using Tuple Given a list of numbers of list, write a
Python program to create a list of tuples having first element as the number and second
element as the cube of the number.

Sample Input

list = [9, 5, 6]

Sample Output

[(9, 729), (5, 125), (6, 216)]

list1 = [9,5,6]

res = [(val,pow(val,3)) for val in list1]

print (res)

[(9, 729), (5, 125), (6, 216)]

37. Problem Title: Sum of Elements in the Dictionary Given a dictionary in Python, write a
Python program to find the sum of all Items in the dictionary.

Sample Input 1

{'a': 100, 'b':200, 'c':300}

Sample Output 1

600

Sample Input 2

{'x': 25, 'y':18, 'z':45}

Sample Output 2

88

OUTPUT:

Code:
dict={"x":69,"y":420,"z":6969}

values=dict.values()

total=sum(values)

print(total)

38. Problem Title: Reverse the Order Write a Python program to reverse the order of
the elements in the given array.
Create an array with the below given elements.

array('i', [1, 3, 5, 3, 7, 1, 9, 3])

Sample Output

Reverse the order of the items:

3, 9, 1, 7, 3, 5, 3, 1

CODE

arr = [1, 3, 5, 3, 7, 1, 9, 3];

print("Original array: ");

for i in range(0, len(arr)):

print(arr[i]),

print("Array in reverse order: ");

for i in range(len(arr)-1, -1, -1):

print(arr[i]),

39. Problem Title: Element Count Write a Python program to get the number of
occurrences of a specified element in an array. If the specified element not found in the
given array, then display “Not Found” message.
Create the array with the below elements.

array('i', [1, 3, 5, 3, 7, 9, 3])

Sample Input 1

Sample Output 1
Number of occurrences of the number 3 in the array: 3

Sample Input 2

Sample Output 2

Not Found

CODE:

lst = [1,3,5,3,7,9,3]

h=int(input("Enter element to count "))

count=lst.count(h)

if h in lst:

print("The count of element is :", count)

else:

print("Not found")

40. Problem Title: Insert Element at Specified PositionWrite a Python program to insert
a new item before the second element in an existing array.
Create the array with the below elements.

array('i', [1, 3, 5, 7, 9])

Sample Input 1 4

Sample Output 1 1, 4, 3, 5, 7, 9

ANSWER :

Python code :

from array import *

array_num = array('i', [1, 3, 5, 7, 9])

print("Original array: "+str(array_num))

print("Insert new value 4 before 3:")

array_num.insert(1, 4)
print("New array: "+str(array_num))

Sample Output:

Original array: array('i', [1, 3, 5, 7, 9])\

Insert new value 4 before 3:

New array: array('i', [1, 4, 3, 5, 7, 9])

41. Problem Title: List Total Write a Python function to sum all the numbers in a list.
Code :

mylist=[8, 2, 3, 0, 7]

sum=0

sum += mylist[0]

sum += mylist[1]

sum += mylist[2]

sum += mylist[3]

sum += mylist[4]

print("Sum of the list is:",sum)

Sample List: (8, 2, 3, 0, 7)

Sample Output 20

42. Problem Title: Prime Checker Write a Python function that takes a number as a
parameter and check the number is prime or not. The function should return a Boolean value.

Call the above function and display “x is a Prime Number” if the function returns true, else
display “x is not a Prime Number”

Note: A prime number (or a prime) is a natural number greater than 1 and that has no positive
divisors other than 1 and itself.

Sample Input 1

Sample Output 1
5 is a Prime Number

Sample Input 2

12

Sample Output 2

12 is not a Prime Number

PROGRAM

x = int(input("enter the no. : "))

def prime(x):

for i in range(2, x):

if (x % i) == 0 :

return True

break

else :

return False

if prime(x) == True :

print(str(x) + " is not a prime number")

else :

print(str(x) + " is a prime number")

1st output ::

enter the no. : 5

5 is a prime number

2nd output ::

enter the no. : 12

12 is not a prime number

43. Problem Title: Work with Modules bPerform the following tasks in this exercise,
Load the osModule

import os
cwd = os.getcwd()

print("Current working directory:", cwd)

Call one of its functions called system

import os

cmd = 'date'

os.system(cmd)

Load another Module called time

import time

Seconds = 1545925769.9618232

Local_time = time.ctime(seconds)

print(“Local time:”, local_time)

Call its functions to get the date, hour, minute and second.

from datetime import datetime

datetime_object = datetime.now()

print(datetime_object)

print('Type :- ',type(datetime_object))

Import the math module and call the sin function

import math

a = math.pi / 6

print ("The value of sine of pi / 6 is : ", end ="")

print (math.sin(a))

Create your own module called greeting with the function sayhello()

def greet(name):

print ('Hello ', name)

greet('Raj')

greet(998)

Import the greeting module in another program and invoke sayhello()


44. Problem Title: Animals Package Write a Python program to create a new package
called Animals. Create two classes for the new package named Mammals and Birds.
Copy the following code to the file Mammals.py

Birds.py

class Birds:

def __init__(self):

''' Constructor for this class. '''

# Create some member animals

self.members = ['Sparrow', 'Robin', 'Duck']

def printMembers(self):

print('Printing members of the Birds class')

for member in self.members:

print('\t%s ' % member)

Mammals.py

class Mammals:

def __init__(self):

''' Constructor for this class. '''

# Create some member animals

self.members = ['Tiger', 'Elephant', 'Wild Cat']

def printMembers(self):

print('Printing members of the Mammals class')

for member in self.members:

print('\t%s ' % member)

__init__.py

from Animals.Mammals import Mammals

from Animals.Birds import Birds

# Import classes from your brand new package


from Animals.Mammals import Mammals

from Animals.Birds import Birds

# Create an object of Mammals class & call a method of it

myMammal = Mammals()

myMammal.printMembers()

# Create an object of Birds class & call a method of it

myBird = Birds()

myBird.printMembers()

45. Problem Description. Write a NumPy program to create an array of 10 zeros, 10


ones, 10 fives.
import numpy as np

ar1 = np.zeros(10)

ar2 = np.ones(10)

ar3 = np.ones(10)*5

print ("array of 0: ",ar1)

print("array of 1: ",ar2)

print("array of 5: ",ar3)

arfin = (ar1, ar2, ar3)

ars = np.concatenate(arfin)

print(ars)

46. Problem Title: Write a NumPy program to compute sum of all elements, sum of
each column and sum of each row of a given array.
PROGRAM:

import numpy as np

x = np.array([[0,1],[2,3]])

print("Original array:")

print(x)
print("Sum of all elements:")

print(np.sum(x))

print("Sum of each column:")

print(np.sum(x, axis=0))

print("Sum of each row:")

print(np.sum(x, axis=1))

OUTPUT:

Original array:

[[0 1]

[2 3]]

Sum of all elements:

Sum of each column:

[2 4]

Sum of each row:

[1 5]

47. Problem Description


Write a NumPy program to create a new array of 3*5, filled with 2.

Sample Output

[[2 2 2 2 2]

[2 2 2 2 2]

[2 2 2 2 2]]

[[2 2 2 2 2]

[2 2 2 2 2]

[2 2 2 2 2]]
Code-

import numpy as np

x = np.full((3, 5), 2, dtype=np.uint)

print(x)

y = np.ones([3, 5], dtype=np.uint) *2

print(y)

You might also like