How to create Xml for a book store application and display it?

A book store has a collection of books with various categories. It includes fiction,non fiction based books, general books, Technical books. In  this example, the book store has computer science based books.

Each book has a title,author(s),category it belongs, publications details and price of the book.The code is given below...

XML program for book store application is given below. 

<?xml version="1.0" encoding="UTF-8"?>

<book_store>

<book>

<title>The art of computer programming</title>

<author> Donald E.Knuth</author>

<category> Computers</category>

<publications> Addison wesley</publications>

<price> 10,060</price>

</book>

<book>

<title>Code </title>

<author> Charles Petzold </author>

<category> Coding </category>

<publications> Microsoft Press</publications>

<price> 1500</price>

</book>

<book>

<title>Artificial intelligence: A modern approach </title>

<author> Stuart russell</author>

<author>peter norvig </author>

<category> Modern computers</category>

<publications>Pearson Education </publications>

<price>4,600 </price>

</book>

<book>

<title> Algorithms to live by</title>

<author> Brain christian</author>

<author> Tom  griffiths</author>

<category> Algorithms</category>

<publications>  Henry holt and company</publications>

<price>1860 </price>

</book>

<book>

<title> The C Programming Language</title>

<author> Brain W.Kernighan</author>

<author> Dennis Ritchie </author>

<category> Programming</category>

<publications> Pearson Education</publications>

<price>250 </price>

</book>

</book_store>


To format this, you can any formatter available in websites. To view the xml, use any XMLviewer available as free.
My xml file's formatted and tree view is given below

Formatted XML                                           Tree view

Formatted XML                                                 Tree view
This is the easy way to create a book store application in  XML.




 

SQL interview questions part 1

SQL stands for Structured Query Language. It is used in databases to manipulate and retrieve data from database. It mainly used in relational databases.

When you attending any software interview, you will get the questions from SQL. Because it is the basic language and easy one too.

Let us discuss the interview questions....

Before starting the SQL, you must know about database and RDBMS.

A database is a collection of data stored in a system in an organized  way. Using SQL, you can retrieve the data.

RDBMS (Relational Database Management system)is a software which is used to create, retrieve ,update and manage the database. The data is stored in the form of tables.

Next, SQL interview questions are given below….

1.What is SQL?

    SQL is Structured Query Language which is used to define ,retrieve and manipulate  

    data from databases.

 

2.Name some SQL servers.

    Some examples are MySQL,PostgreSQL,Oracle,Microsoft SQL server, SQLite.                                                                                                


3.What is a tuple?

    A tuple is a set of values of an individual record. For example, In Class A table, a  

   record of a student is called a tuple.


Class A

Student name

Roll no

Rank

Ajay

1

5

Baby

2

10

Charlie

3

6


             

4.What is DDL?

      DDL stands for Data Definition Language. It is used to define things in SQL.

       Eg: CREATE,ALTER,DROP,TRUNCATE,COMMENT,RENAME  

 

 5.What is DML?

        DML is Data Manipulation Language which is used to manipulate data. it is  

     used to store, modify, retrieve, delete and update data in a database. It has  

     following SQL commands   

      SELECT,INSERT,UPDATE,DELETE,MERGE,CALL,EXPLAIN PLAN,

      LOCK TABLE.

 

6.What is DCL?

   DCL is Data Control Language which is used to grant permissions and controls the   

  database. It includes GRANT ,REVOKE commands.

 

7.What is TCL?

     TCL is Transaction Control Language. It is used in transactions of a database. It includes  

   COMMIT,ROLLBACK,SAVEPOINT and SET TRANSACTION commands.


8. How to create table in SQL?

    To create table in SQL, follow the given syntax.

    Create table table_name(column1 datatype, column2 datatype,.....,column n datatype);

    Eg: Create table student(stu_name varchar(20), stu_id INT PRIMARY KEY,stu_class 

     varchar(10)); 

 

9.How to insert data in to a table in SQL?

      To insert a data, the syntax is given below. INSERT INTO 

    table_name(column1,column2,...) VALUES(VALUE1,VALUE2,....)

    Eg: INSERT INTO student(stu_name,stu_id,stu_class) values(‘ajay’,1,’commerce’);

 10.How  to select a row in SQL?

      This command is used to display the records in the database. It has the following  

       syntax

SELECT * FROM table_name;

SELECT Column_name(s) FROM table_name;

Eg: SELECT * FROM student;

It displays the entire records from table student.

These are some basic interview questions of SQL. Part 2 contains the advance concepts of SQL.

how to write python programs for arithmetic operations

 Arithmetic operations

Arithmetic operations are the basic operation in any programming language. Even in mathematics, these are the basic things that everybody should know. They are

  • Addition(+) 
  • Subtraction(-)
  • Multiplication(*)
  • Division(/)
  • Modulus(%)
  • Exponent(**)
  • Floor division(//)
Program 1 :Addition of three numbers.

I am using notepad as a editor to write this python program. I named this file name as "add3.py"
The program is

a=2

b=3

c=4

print(“the sum of three numbers are”+a+b+c)

 The output is shown below.

C:\Users\python>py add3.py

the sum of three numbers are 9

 C:\Users\python>


Program 2: Subtraction of two numbers 

The program "sub.py"

d=10
e=4
print(" The subtraction  value is",d-e)

The output is given below
C:\Users\python>py sub.py
 The subtraction  value is 6

C:\Users\python>

Program 3: The multiplication table 
Program "mul.py"
a=2
for i in range(1,11):
print(a,'x',i,'=',a*i)

The output is
C:\Users\python>py mul.py
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20

C:\Users\python>


Program 4: Sum of the digit
Program "sum.py"
In this program, We used  modulus operator(%), Floor division operator(//) and division operator(/).

m=int(input("enter  the number"))
c=0
while(m>0):
 sum=m%10
 c=c+sum
 m=m//10
print("The sum of the digit is:",c)

The output is given below:
C:\Users\python>py sum.py
enter  the number567
The sum of the digit is: 18

C:\Users\python>

Program 5: Square  of a number

Program "square.py"-This program uses exponent operator

a=5
square=a**2
print(" The square value of the number is",square)

The output is:

C:\Users\python>py square.py
 The square value of the number is 25

C:\Users\python>

These are the simple programs using arithmetic operations.

Python -A basic view


Python is a high level programming language which is based on object oriented technology. You can interpret it directly. It is an interactive language in web development applications.

Who developed it???

Guido van Rossum was the creator.

Advantages:

It has lots and lots of advantages to programmers.

·      It is a portable language.

·      It can be compatible with many platforms.

·      It has wide range of functions in its library.

·      It is GUI based programming language which is benefit for web programmers and many more…

Let us the journey to python.

How to start the python?????

·      First, download the python software from python website.  Install it to your computer.

 ·      To Set the path in windows command prompt, type the following

Path % Path%; c:\python

Where C:\python is the path of the python folder in the system.

 ·      Now, your system is ready to interpret the python program.

 

First program in python:

·      Open a notepad application, create a new file with the name “first.py”

·      Type the following program

Print(“ welcome to the world of python”) and Save the program.

 



·      Now, Open the command prompt and run the program by “python first.py” 



·      You get the output “ Welcome to the world of python”.


Basics of python programming

The basics of python programming starts with declaring identifiers and datatypes.  The identifier may be a variable, class or a module. To declare an identifier, some rules are there.  They are as follows.

The identifier name should start with any alphabets (AtoZ,atoz) or underscore symbol( _ ) followed by digits(0 to 9).

Eg:  valid: a, count, _sum, name20

 Invalid: b!, c#, v%

  

Datatypes:

Python has standard data types. Standard datatypes are numbers, strings,lists, tuples and directory. The way of declaring python datatypes are given below

  

Number

int

long

float

complex

 

Strings

Str1=”Welcome”

List

List=[‘name’,21,’it dept’,’abc college’]

Tuple

Tuple=[‘name’, 34,’cse dept’,’cde college’]

Directory

Dict={}

Dict[‘first’]=” first name”

Dict[id]=”abc1”

 Table 1: Datatypes and sample declaration.

     These are basics of python programming. Next part deals with the operators, expressions and conditional statements.