[go: up one dir, main page]

0% found this document useful (0 votes)
232 views669 pages

Day1-Day75 Data Analytics Interview

The document provides answers to 12 questions related to Python programming language. Some key points covered include: - Python is a highly versatile language that supports object-oriented, functional, imperative and procedural programming. - It has advantages like being extensible in C/C++, dynamic typing, easy to learn and implement, and availability of third-party modules. - Python is an interpreted language where code is not compiled before execution. Interpretation of code to machine language occurs during runtime. - High-level languages like Python act as a bridge between machine and humans, making programming easier and less time-consuming compared to machine language. - In comparison to Java, Python is interpreted while Java is

Uploaded by

Rushi Khandare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
232 views669 pages

Day1-Day75 Data Analytics Interview

The document provides answers to 12 questions related to Python programming language. Some key points covered include: - Python is a highly versatile language that supports object-oriented, functional, imperative and procedural programming. - It has advantages like being extensible in C/C++, dynamic typing, easy to learn and implement, and availability of third-party modules. - Python is an interpreted language where code is not compiled before execution. Interpretation of code to machine language occurs during runtime. - High-level languages like Python act as a bridge between machine and humans, making programming easier and less time-consuming compared to machine language. - In comparison to Java, Python is interpreted while Java is

Uploaded by

Rushi Khandare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 669

Page | 1

iNeuron Intelligence Pvt Ltd

Q1. Define Dictionary.


Ans- a) Unordered sets of objects.
b) Also known as maps, hashmaps, lookup tables, or associative array.
c) Data exists in key-value pair. Elements in dictionary have a key and a
corresponding value. The key and the value are separated from each other
with a colon “:” and all elements are separated by comma.
d) Elements of a dictionary are accessed by the “key” and not by index.
Hence it is more or less like an associative array where every key is
associated with a value and elements exists in an unordered fashion as key-
value pair.
e) Dictionary literals use curly brackets ‘ {}’.

Q2. How can we create a dictionary object?


Ans- A dictionary object can be created in any of the following ways:
# Initializing an empty Dictionary
Dictionary = {}
print("An empty Dictionary: ")
print(Dictionary)

# Creating a Dictionary using in-built dict() method


Dictionary = dict({1: 'Python', 2: 'Java', 3:'Dictionary'})
print("\nDictionary created by using dict() method: ")
print(Dictionary)

# Creating dictionary by key: value pair format


Dictionary = dict([(1, 'Java'), (2, 'Python'), (3, 'Dictionary')])
print("\nDictionary with key: value pair format: ")
print(Dictionary)

Page | 2
iNeuron Intelligence Pvt Ltd

Q3. Explain from Keys () method.


Ans- The form keys () method returns a new dictionary that will have the
same keys as the dictionary object passed as the argument. If you provide a
value then all keys will be set to that value or else all keys will be set to
‘None’.

Q4. What is the purpose of items() function?


Ans- the items() function does not take any parameters. It returns the view
object that shows the given dictionary’s key value pairs.

Q5. Define bucket sorting?


Ans- Bucket Sort is a two-step procedure for sorting data. First, the values are
collected in special containers called buckets. Then, these values are
transferred appropriately into a sorted list. For the algorithm to be feasible,
the elements to be sorted must have a limited set of values.

Page | 3
iNeuron Intelligence Pvt Ltd

Q6. Which one of the following is correct way of declaring and initialising a
variable, x with value 5?
A. int x
x=5
B. int x=5
C. x=5
D. declare x=5

Ans: C
Explanation: One of the following is correct way of declaring and initialising
a variable, x with value 5 is x=5.

Q7. How many local and global variables are there in the following
Python code?
var1=5
def fn():
var1=2
var2=var1+5
var1=10
fn()
A. 1 local, 1 global variables
B. 1 local, 2 global variables
C. 2 local, 1 global variables
D. 2 local, 2 global variables

Ans-D. 2 local, 2 global variables


Explanation: 2 local, 2 global variables are there in the following Python
code.

Page | 4
iNeuron Intelligence Pvt Ltd
Q8. Which one is false regarding local variables?
A. These can be accessed only inside owning function
B. Any changes made to local variables does not reflect outside the function.
C. These remain in memory till the program ends
D. None of the above
Ans: C
Explanation: These remain in memory till the program ends is false regarding
local variables.

Q9. Which of the following options will give an error if set1={2,3,4,5}?


A. print(set1[0])
B. set1[0]=9
C. set1=set1+{7}
D. All of the above
Ans : D

Explanation: All of the above option will give error if set1={2,3,4,5}.

Q10. What will be the result of below Python code?


set1= {1,2,3}

set1.add (4)

set1.add (4)

print(set1)

A. {1,2,3,4}
B. {1,2,3}
C. {1,2,3,4,4}
D. It will throw an error as same element is added twice

Ans: A
Explanation: The output for the following python code is {1,2,3,4}.

Page | 5
iNeuron Intelligence Pvt Ltd
______________________________________________________________

Q11. Which of the following options will give an error if set1= {2,3,4,5}?
A. print(set1[0])
B. set1[0] = 9
C. set1=set1 + {7}
D. All of the above

Ans: D
Explanation: All of the above option will give error if set1= {2,3,4,5}

Q12.What will the below Python code do?


set1={"a",3,"b",3}
set1.remove(3)
A. It removes element with index position 3 from set1
B. It removes element 3 from set1
C. It removes only the first occurrence of 3 from set1
D. No such function exists for set
Ans: B
Explanation: It removes element 3 from set1.

Q13. What will be the output of following Python code?


set1= {2,5,3}
set2= {3,1}
set3= {}
set3=set1&set2
print(set3)

A. {3}
B. {}
C. {2,5,3,1}
D. {2,5,1}

Ans: A
Explanation: The output of the following code is {3}
Page | 6
iNeuron Intelligence Pvt Ltd
______________________________________________________________
_____________________________
Q14. Which of the following is True regarding lists in Python?
A. Lists are immutable.
B. Size of the lists must be specified before its initialization
C. Elements of lists are stored in contagious memory location.
D. size(list1) command is used to find the size of lists.
Ans: C
Explanation: Elements of lists are stored in contagious memory location is
True regarding lists in Python.

Q15. Which of the following will give output as [23,2,9,75]?


If list1= [6,23,3,2,0,9,8,75]
A. print(list1[1:7:2])
B. print(list1[0:7:2])
C. print(list1[1:8:2])
D. print(list1[0:8:2])
View Answer

Ans: C
Explanation: print(list1[1:8:2]) of the following will give output as
[23,2,9,75].

Q16. The marks of a student on 6 subjects are stored in a list, list1=


[80,66,94,87,99,95]. How can the student's average mark be calculated?

A. print(avg(list1))
B. print(sum(list1)/len(list1))
C. print(sum(list1)/size of(list1))
D. print(total(list1)/len(list1))

Ans: B
Explanation: the student's average mark be calculated through
print(sum(list1)/len(list1)).

Page | 7
iNeuron Intelligence Pvt Ltd
______________________________________________________________
_____________________________
Q17. What will be the output of following Python code?

list1= ["Python", "Java", "c", "C", "C++"]

print(min(list1))

A. c

B. C++

C. C

D. min function cannot be used on string elements

Ans: C

Explanation: C will be the output of following Python code.

Q18. What will be the result after the execution of above Python code?
list1= [3,2,5,7,3,6]
list1.pop (3)
print(list1)

A. [3,2,5,3,6]
B. [2,5,7,3,6]
C. [2,5,7,6]
D. [3,2,5,7,3,6]
Ans: A
Explanation: [3,2,5,3,6] will be the result after the execution of above Python
code.

Page | 8
iNeuron Intelligence Pvt Ltd
______________________________________________________________
_____________________________
Q19. What will be the output of below Python code?

list1=["tom","mary","simon"]
list1.insert(5,8)
print(list1)

A. ["tom", "mary", "simon", 5]


B. ["tom", "mary", "simon", 8]
C. [8, "tom", "mary", "simon"]
D. Error
Ans: B
Explanation: ["tom", "mary", "simon", 8] will be the result after the execution
of above Python code.

Q20. Which among the following are mutable objects in Python?


(i) List
(ii) Integer
(iii) String
(iv) Tuple

A. i only
B. i and ii only
C. iii and iv only
D. iv only

Ans- A

Explanation: List are mutable objects in Python.

Page | 9
iNeuron Intelligence Pvt Ltd

Q1. Why is Python considered to be a highly versa7le programming


language?
Ans- Python is a high versa1le programming language because it
supports mul1ple models of programming such as:
OOP
Func1onal
Impera1ve
Procedural

Q2. What are the advantages of choosing python over any other
programming language?
Ans- The advantages of choosing python over any other
programming languages are as follows:
ü Extensible in C and C++
ü It is dynamic in nature
ü Easy to learn and easy to implement
ü Third party opera1ng modules are present: As the name
suggests a third-party module is wriDen by third party which
means neither you nor the python writers have developed it.
However, you can make use of these modules to add
func1onality to your code.

Q3. Is python dynamically typed?


Ans - Yes, Python is dynamically typed because in a code we need not
specify the type of variables while declaring them. The type of a
variable is not known un1l the code is executed.

Page 2 of 9
iNeuron Intelligence Pvt Ltd

Q4. What do you mean when you say that Python is an interpreted
language?
Ans – When we say python is an interpreted language it means that
python code is not compiled before execu1on. Code wriDen in
compiled languages such as java can be executed directly on the
processor because it is compiled before run1me and at the 1me of
execu1on it is available in the form of machine language that the
computer can understand.
This is not the case with python. It does not provide code in machine
language before run1me. The transla1on of code to machine
language occurs while the program is being executed.

Q5. Python is a high-level programming language? What is a need


for high level programming languages?
Ans- High level programming languages act as a bridge between the
machine and humans. Coding directly in machine language can be a
very 1me consuming and cumbersome process and it would
definitely restrict coders from achieving their goals. High level
programming languages like Python , JAVA ,C++ , etc are easy to
understand. They are tools which the programmers can use for
advanced level programming.

Q6. Draw the comparison between Java and Python.


JAVA PYTHON
Java is complied. Python is interpreted.
Java is sta1cally typed. Python is dynamically typed.

Java encloses everything in Python follows indenta1on and


braces. makes the code neat and readable.

Page 3 of 9
iNeuron Intelligence Pvt Ltd

Indenta1on also determines the


code execu1on.
Android app development is There are libraries like Kivy which
mostly done using Java and can be used along with the python
XML. code to make it compa1ble for
android development.
Java is stronger when it comes Python connec1vity is not that
to connec1vity with database. strong as Java.
Java is more difficult to learn as Python was developed with focus
compared to python. on making it easy to learn.
Java gives high priority to A good developer can code a secure
security. applica1on in python also.

Q7. Which character set does Python use?


Ans- Python uses tradi1onal ASCII character set.

Q8. What is the purpose of indenta7on in python?


Ans – Indenta1on is one of the most dis1nc1ve features of Python.
While in other programming languages, developers uses indenta1on
to keep their code neat but in case of Python , indenta1on is required
to mark the beginning of a block or to understand which block the
code belongs to. No braces are used to mark block of codes in
python. Block in codes is required to define func1ons, condi1onal
statements, or loops. These blocks are created simply by correct
usage of spaces. All statement that are same distance from the right
belong to the same block.

Page 4 of 9
iNeuron Intelligence Pvt Ltd

Q9. Explain memory management in Python.


Ans- Memory management is required so that par1al or complete
sec1on of computer’s memory can be reserved for execu1ng
programs and processes. This method of providing memory is called
memory alloca1on. Also, when data is no longer required, it must be
removed. Knowledge of memory management helps developer is
develop efficient code.
Everything in Python is an object. Python has different types of
objects, such as simple objects which consist of numbers and strings
and container object such as dic1onary, list, and user defined classes.
These objects can be accessed by an iden1fier -name.

Q 10. Differen7ate between mutable and immutable objects.


Mutable Objects Immutable Objects
Can change their state or Cannot change their state or
contents. contents.
Type: list, dic1onary, set Inbuilt types: int, float, bool, string,
Unicode, tuple
Easy to change Making changes require crea1on of
copy
Customized container like Primi1ve like data types is
types is mostly mutable. immutable.

Q11. What is Variable in Python?


Ans- Variables in Python are reserved memory loca1ons that stores
values. Whenever a variable is created, some space is reserved in the
memory. Based on the data type of a variable, the interpreter will
allocate memory and decide what should be stored in the memory.

Page 5 of 9
iNeuron Intelligence Pvt Ltd

Q12. How can we assign same value to mul1ple variables in one


single go?
Ans- a=b=c= “hello world!”
print(a)
Output - hello world!
print(b)
Output - hello world!
print(c)
Output - hello world!

Q13. What are the methods available for conversion of numbers


from one type to another?
Ans- a = 87.8
#Conversion to integer
print(int(a))
Output
87
# Conversion to float
a=87
print(float(a))
Output
87.0
#Convert to complex
a =87
print(complex(a))
Output
(87+0j)

Q14. What are number data types in python?


Ans- Number data types are the one which are used to store numeric
values such as:

Page 6 of 9
iNeuron Intelligence Pvt Ltd

1.integer
2.long
3.float
4.complex
a=1
b = -1
c = 1.1
print(type(a))
print(type(b))
print(type(c))
Output
<class ‘int’>
<class ‘int’>
<class ‘float’>

Q15. How to convert real numbers to complex numbers?


a=7
b = -8
x = complex (a, b)
x.real
Output
7.0
x.imag
Output
-8.0

Page 7 of 9
iNeuron Intelligence Pvt Ltd

Q16. Which of the following is used to define a block of code in


Python language?
a) Indenta1on
b) Key
c) Brackets
d) All of the men1oned
Answer: a

Explana1on: In Python, to define a block of code we use indenta1on.


Indenta1on refers to whitespaces at the beginning of the line.

Q17 Which keyword is used for func1on in Python language?


a) Func1on
b) def
c) Fun
d) Define
Answer: b
Explana1on: The def keyword is used to create, (or define) a func1on
in python.

Q18 Who developed Python Programming Language?


a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom
Answer: c
Explana1on: Python language is designed by a Dutch programmer
Guido van Rossum in the Netherlands.

Page 8 of 9
iNeuron Intelligence Pvt Ltd

Q19. Which of the following func1ons can help us to find the version
of python that we are currently working on?
a) sys. version(1)
b) sys.version(0)
c) sys.version()
d) sys.version
Answer: d
Explana1on: The func1on sys. version can help us to find the version
of python that we are currently working on. It also contains
informa1on on the build number and compiler used. For example,
3.5.2, 2.7.3 etc. this func1on also returns the current date, 1me, bits
etc along with the version.

Q20. Which of the following is the trunca1on division operator in


Python?
a) |
b) //
c) /
d) %
Answer: b
Explana1on: // is the operator for trunca1on division. It is called so
because it returns only the integer part of the quo1ent, trunca1ng
the decimal part. For example: 20//3 = 6.

Page 9 of 9
iNeuron Intelligence Pvt Ltd

1. Which of the following is not a core data type in Python


programming?
a) Tuples
b) Lists
c) Class
d) Dic@onary
Answer: c
Explana@on: Class is a user-defined data type.

2. Which of these is the defini@on for packages in Python?


a) A set of main modules
b) A folder of python modules
c) A number of files containing Python defini@ons and statements
d) A set of programs making use of Python modules
Answer: b
Explana@on: A folder of python programs is called as a package of
modules.

3. What is the order of namespaces in which Python looks for an


iden@fier?
a) Python first searches the built-in namespace, then the global
namespace and finally the local namespace
b) Python first searches the built-in namespace, then the local
namespace and finally the global namespace
c) Python first searches the local namespace, then the global
namespace and finally the built-in namespace
d) Python first searches the global namespace, then the local
namespace and finally the built-in namespace

Page 2 of 8
iNeuron Intelligence Pvt Ltd

Answer: c
Explana@on: Python first searches for the local, then the global and
finally the built-in namespace.

4. Which one of the following is not a keyword in Python language?


a) pass
b) eval
c) assert
d) nonlocal

Answer: b
Explana@on: eval can be used as a variable.

5. Which module in the python standard library parses op@ons


received from the command line?
a) getarg
b) getopt
c) main
d) os
Answer: b
Explana@on: getopt parses op@ons received from the command line.

6. Which of the following statements is used to create an empty set


in Python?
a) ()
b) [ ]
c) { }
d) set()
Answer: d
Explana@on: {} creates a dic@onary not a set. Only set() creates an
empty set.

Page 3 of 8
iNeuron Intelligence Pvt Ltd

7. Which one of the following is the use of func@on in python?


a) Func@ons do not provide beWer modularity for your applica@on
b) you cannot also create your own func@ons
c) Func@ons are reusable pieces of programs
d) All of the men@oned

Answer: c
Explana@on: Func@ons are reusable pieces of programs. They allow
you to give a name to a block of statements, allowing you to run that
block using the specified name anywhere in your program and any
number of @mes.

8. What is the maximum possible length of an iden@fier in Python?


a) 79 characters
b) 31 characters
c) 63 characters
d) none of the men@oned

Answer: d
Explana@on: Iden@fiers can be of any length.

9. What are the two main types of func@ons in Python?


a) System func@on
b) Custom func@on
c) Built-in func@on & User defined func@on
d) User func@on

Answer: c
Explana@on: Built-in func@ons and user defined ones. The built-in
func@ons are part of the Python language. Examples are: dir(), len()
or abs(). The user defined func@ons are func@ons created with the
def keyword.
Page 4 of 8
iNeuron Intelligence Pvt Ltd

10. Which of the following is a Python tuple?


a) {1, 2, 3}
b) {}
c) [1, 2, 3]
d) (1, 2, 3)

Answer: d
Explana@on: Tuples are represented with round brackets.

11. Which of the following is the use of id() func@on in python?


a) Every object in Python doesn’t have a unique id
b) In Python Id func@on returns the iden@ty of the object
c) None of the men@oned
d) All of the men@oned

Answer: b
Explana@on: Each object in Python has a unique id. The id() func@on
returns the object’s id.

12. The process of pickling in Python includes ____________


a) conversion of a Python object hierarchy into byte stream
b) conversion of a datatable into a list
c) conversion of a byte stream into Python object hierarchy
d) conversion of a list into a datatable

Answer: a
Explana@on: Pickling is the process of serializing a Python object, that
is, conversion of a Python object hierarchy into a byte stream. The
reverse of this process is known as unpickling.

Page 5 of 8
iNeuron Intelligence Pvt Ltd

13. What is the output of print 0.1 + 0.2 == 0.3?


a) True
b) False
c) Machine dependent
d) Error

Answer: b
Explana@on: Neither of 0.1, 0.2 and 0.3 can be represented
accurately in binary. The round off errors from 0.1 and 0.2
accumulate and hence there is a difference of 5.5511e-17 between
(0.1 + 0.2) and 0.3.

14. Which of the following is not a complex number?


a) k = 2 + 3j
b) k = complex (2, 3)
c) k = 2 + 3l
d) k = 2 + 3J

Answer: c
Explana@on: l (or L) stands for long.

15. Which of the following is incorrect?


a) x = 30963
b) x = 0x4f5
c) x = 19023
d) x = 03964

Answer: d
Explana@on: Numbers star@ng with a 0 are octal numbers but 9 is not
allowed in octal numbers.

Page 6 of 8
iNeuron Intelligence Pvt Ltd

16. What are tokens?


Ans- Tokens are the smallest units of program in Python. There are
four types of tokens in Python:
a) Keywords
b) Iden@fiers
c)Literals
d)Operators

17. What are constants?


Ans- Constants (literals) are values that do not change while
execu@ng a program.

18. What would be the output for 2*4**2? Explain.


Ans- The precedence of ** is higher than precedence of *. Thus, 4**2
will be computed first. The output value is 32 because 4**2 will be
computed first. The output value is 32 because 4**2=16 and
2*16=32.

19. What are operators and operands?


Ans- Operators are the special symbols that represent computa@ons
like addi@on and mul@plica@on. The values the operator uses are
called operands.
The symbols +, -, and /, and the use of parenthesis for grouping,
mean in Python what they mean in mathema@cs. The asterisk (*) is
the symbol of mul@plica@on, and** is the symbol for exponen@a@on.
When a variable name appears in the place of an operand, it is
replaced with its value before the opera@on is performed.

Page 7 of 8
iNeuron Intelligence Pvt Ltd

20. What is the Order of Opera@ons?


Ans- For mathema@cal operators, Python follows mathema@cal
conven@on. The acronym PEMDAS is a useful way to remember the
rules:
a) For mathema@cal operators, Python follows mathema@cal
conven@on. The acronym PEMDAS is a useful way to remember
the rules:
b) Exponen@a@on has the next highest precedence, so 1 + 2**3 is
9, not 27, and 2 * 3**2 is 18, not 36.
c) Mul@plica@on and Division have higher precedence than
Addi@on and Subtrac@on.

Page 8 of 8
iNeuron Intelligence Pvt Ltd

1. Define string, list and Tuple.


Ans- String- They are immutable sequence of text characters. There is
no special class for a single character in Python. A character can be
considered as String of text having a length of 1.
List- Lists are very widely used in Python programming and a list
represents sequence of arbitrary objects. List is immutable.
Tuple-Tuple is more or less like a list but it is immutable.

2. What would be the output for the following expression:


Ans- print (‘{0:4}’. format (7.0 / 3))

3. How can String literals be defined?


Ans- a= “Hello World”
b= ’Hi’
type(a)
<class ‘str’>
Type(b)
<class ‘str’>
c=” Once upon a \me in a land far away there lived a king”
type(c)
<class ‘str’>

4. How can we perform concatena\on of Strings?


Ans -Concatena\on of Strings can be performed using following
techniques:
1) +operator
string1= “Welcome”
string2 = “to the world of Python!!!”
string3 = string1 + string2
print(string3)
Welcome to the world of Python!!!
Page 2 of 9
iNeuron Intelligence Pvt Ltd

2)Join () func3on
The join () func\on is used to return a string that has string
elements joined by a separator. The syntax for using join ()
func\on.
string_name. join (sequence)
string1 = “-“
sequence = (“1”, ”2”, “3”, “4”,)
print (string1.join(sequence))
1-2-3-4

3) % operator
string1 = “Hi”
string2 = “There”
string3 = “%s %s” % (string1, string2)
print(string3)
Hi There
4) format () func3on
string1= “Hi”
string2= “There”
string3 = “{} {}”. format (string1, string2)
print(string3)
Hi There
5) f-string
string1= “Hi”
string2= “There”
string3= f’ {string1} {string2}’
print(string3)
Hi There

Page 3 of 9
iNeuron Intelligence Pvt Ltd

5.How can you repeat strings in Python?


Ans- Strings can be repeated either using the mul\plica\on sign ‘*’ or
by using for loop.
Ø Operator for repea3ng strings
string1 = “Happy Birthday!!!”
string1*3
Happy Birthday!!! Happy Birthday!!! Happy Birthday!!!
Ø for loop for string repe33on
for x in range (0,3)
for x in range (0,3):
print (“Happy Birthday!!!)

6. What would be the output for the following lines of code?


Ans- string1 = “Happy”
string2 = “Birthday!!!”
(string1 + string2) *3
Happy Birthday!!! Happy Birthday!!! Happy Birthday!!!

7. What is the simplest way of unpacking single characters from


string “HAPPY”?
Ans- This can be doe as shown in the following code:
string1 = “Happy”
a,b,c,d,e = string1
print(a)
H
print(b)
a
print(c)
p
print(d)

Page 4 of 9
iNeuron Intelligence Pvt Ltd

p
print(e)
y

8. How can you access the fourth character of the string “HAPPY”?
Ans- You can access any character of a string by using Python’s array
like indexing syntax. The first item has an index of 0. Therefore, the
index of fourth item will be 3.
string1 = “Happy”
string1[3]
Output
p

9. If you want to start coun\ng the characters of the string from the
right most end, what index value will you use?
Ans- If the length of the string is not known we can s\ll access the
rightmost character of the string using index of -1.

string1 =” hello world”


string1[-1]
output
!

10. By mistake the programmer has created string1 having the value
“happu”. He wants to change the value of the last character. How can
that be done?
Ans- string1=” happu”
string1.replace(‘u’,’y’)
happy

Q11.Which character of the string will exist at index -2?

Page 5 of 9
iNeuron Intelligence Pvt Ltd

Ans- Index of -2 will provide second last character of the string.


string1=” happy”
string [-1]
Y
string1[-2]
p

Q12.Explain slicing in strings.


Ans- Python allows you to extract a chunk of characters from a string
if you know the posi\on and size. All we need to do is to specify the
start and end point.
The following example shows how this can be done.
Eg-1
string1=”happy-birthday”
string1[4:7]
output
y-b
Eg-2
string1=”happy-birthday”
string1[:7]
output
happy-b
Eg-3
string1=”happy-birthday”
string1[4:]
output
y-birthday

Page 6 of 9
iNeuron Intelligence Pvt Ltd

13. What would be the output for the following code?


Ans- string1=”happy-birthday”
String1[-1: -9: -2]
Output
!!ah

14. What is the return type of func\on id?


a) int
b) float
c) bool
d) dict
Answer: a
Explana\on: Execute help(id) to find out details in python shell.id
returns a integer value that is unique.

15. What data type is the object below?

L = [1, 23, 'hello', 1]

a) list
b) dic\onary
c) array
d) tuple
Answer: a
Explana\on: List data type can store any values within it.

16.The method to extract the last element of a list is

a) List_name[2:3]
b) List_name[-1]
c) List_name[0]

Page 7 of 9
iNeuron Intelligence Pvt Ltd

d) None of the above


Answer: a) List_name [-1]

17. To remove an element of a list, we use the arribute


a) add

b) index
c) pop
d) Delete
Answer – c) pop

18. To add an element to a list, we use the arribute

a) append
b) copy
c) reverse
d) sort
Answer- a) append

19. The process of pickling in Python includes ____________


a) conversion of a Python object hierarchy into byte stream
b) conversion of a data table into a list
c) conversion of a byte stream into Python object hierarchy
d) conversion of a list into a data table
Answer: a
Explana\on: Pickling is the process of serializing a Python object, that
is, conversion of a Python object hierarchy into a byte stream. The
reverse of this process is known as unpickling.

Page 8 of 9
iNeuron Intelligence Pvt Ltd

20. What is the return type of func\on id?


a) int
b) float
c) bool
d) dict
Answer: a
Explana\on: Execute help(id) to find out details in python shell.id
returns a integer value that is unique.

Page 9 of 9
iNeuron Intelligence Pvt Ltd

1. Which of the following results in a Syntax Error?


a) ‘” Once upon a >me…”, she said.’
b) “He said, ‘Yes!'”
c) ‘3\’
d) ”’That’s okay”’
Answer: c
Explana>on: Carefully look at the colons.

2.If a= (1,2,3,4), a [1: -1] is _________


a) Error, tuple slicing doesn’t exist
b) [2,3]
c) (2,3,4)
d) (2,3)
Answer: d
Explana>on: Tuple slicing exists and a [1: -1] returns (2,3).c) (2,3,4)
d) (2,3)

3. What type of data is: a= [(1,1), (2,4), (3,9)]?


a) Array of tuples
b) List of tuples
c) Tuples of lists
d) Invalid type
Answer: b
Explana>on: The variable a has tuples enclosed in a list making it a
list of tuples.

4. Which of these about a frozen set is not true?


a) Mutable data type
b) Allows duplicate values
c) Data type with unordered values
d) Immutable data type

Page 2 of 8
iNeuron Intelligence Pvt Ltd

Answer: a
Explana>on: A frozen set is an immutable data type.

5. Set members must not be hashable.


a) True
b) False
Answer: b
Explana>on: Set members must always be hashable.

6. Which one of these is floor division?


a) /
b) //
c) %
d) None of the men>oned
Answer: b
Explana>on: When both of the operands are integer then python
chops out the frac>on part and gives you the round off value, to get
the accurate answer use floor division.

7. Mathema>cal opera>ons can be performed on a string.


a) True
b) False
Answer: b
Explana>on: You can’t perform mathema>cal opera>on on string
even if the string is in the form: ‘1234…’.

8. Operators with the same precedence are evaluated in which


manner?
a) Lej to Right
b) Right to Lej

Page 3 of 8
iNeuron Intelligence Pvt Ltd

c) Can’t say
d) None of the men>oned
Answer: a
Explana>on: None.

8. Which one of the following has the highest precedence in the


expression?
a) Exponen>al
b) Addi>on
c) Mul>plica>on
d) Parentheses
Answer: d
Explana>on: Just remember: PEMDAS, that is, Parenthesis,
Exponen>a>on, Division, Mul>plica>on, Addi>on, Subtrac>on.

9. Which one of the following has the same precedence level?


a) Addi>on and Subtrac>on
b) Mul>plica>on, Division and Addi>on
c) Mul>plica>on, Division, Addi>on and Subtrac>on
d) Addi>on and Mul>plica>on
Answer: a
Explana>on: “Addi>on and Subtrac>on” are at the same precedence
level. Similarly, “Mul>plica>on and Division” are at the same
precedence level.

10. Operators with the same precedence are evaluated in which


manner?
a) Lej to Right
b) Right to Lej
c) Can’t say
d) None of the men>oned

Page 4 of 8
iNeuron Intelligence Pvt Ltd

Answer: a
Explana>on: None.

11. What is the default value of encoding in encode()?


a) ascii
b) qwerty
c) up-8
d) up-16
Answer: c
Explana>on: The default value of encoding is up-8.

12. Suppose list Example is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 ajer
list Example. extend([34, 5])?
a) [3, 4, 5, 20, 5, 25, 1, 3, 34, 5]
b) [1, 3, 3, 4, 5, 5, 20, 25, 34, 5]
c) [25, 20, 5, 5, 4, 3, 3, 1, 34, 5]
d) [1, 3, 4, 5, 20, 5, 25, 3, 34, 5]
Answer: a
Explana>on: Execute in the shell to verify.

13. Suppose list Example is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 ajer
list Example. pop(1)?
a) [3, 4, 5, 20, 5, 25, 1, 3]
b) [1, 3, 3, 4, 5, 5, 20, 25]
c) [3, 5, 20, 5, 25, 1, 3]
d) [1, 3, 4, 5, 20, 5, 25]
Answer: c
Explana>on: pop () removes the element at the posi>on specified in
the parameter.

Page 5 of 8
iNeuron Intelligence Pvt Ltd

14. Which of the following func>ons is a built-in func>on in python?


a) seed()
b) sqrt()
c) factorial()
d) print ()

Answer: d
Explana>on: The func>on seed is a func>on which is present in the
random module. The func>ons sqrt and factorial are a part of the
math module.

15. The func>on pow (x, y, z) is evaluated as:


a) (x**y) **z
b) (x**y) / z
c) (x**y) % z
d) (x**y) *z

Answer: c
Explana>on: The built-in func>on pow () can accept two or three
arguments. When it takes in two arguments, they are evaluated as
x**y.

16. Is Python case sensi>ve when dealing with iden>fiers?


a) yes
b) no
c) machine dependent
d) none of the men>oned
Answer: a
Explana>on: Case is always significant while dealing with iden>fiers in
python.

Page 6 of 8
iNeuron Intelligence Pvt Ltd

17. Which of the following statements create a dic>onary?


a) d = {}
b) d = {“john”:40, “peter”:45}
c) d = {40:” john”, 45:” peter”}
d) All of the men>oned
Answer: d
Explana>on: Dic>onaries are created by specifying keys and values.

18. Suppose d = {“john”:40, “peter”:45}, to delete the entry for


“john” what command do we use?
a) d.delete(“john”:40)
b) d.delete(“john”)
c) del d[“john”]
d) del d(“john”:40)
Answer: c
Explana>on: Execute in the shell to verify.

19. Suppose d = {“john”:40, “peter”:45}. To obtain the number of


entries in dic>onary which command do we use?
a) d. size()
b) len(d)
c) size(d)
d) d. len()
Answer: b
Explana>on: Execute in the shell to verify.

20. Suppose d = {“john”:40, “peter”:45}, what happens when we try


to retrieve a value using the expression d[“susan”]?
a) Since “susan” is not a value in the set, Python raises a Key Error
excep>on
b) It is executed fine and no excep>on is raised, and it returns None

Page 7 of 8
iNeuron Intelligence Pvt Ltd

c) Since “susan” is not a key in the set, Python raises a Key Error
excep>on
d) Since “susan” is not a key in the set, Python raises a syntax error
Answer: c
Explana>on: Execute in the shell to verify.

Page 8 of 8
iNeuron Intelligence Pvt Ltd

1. Which of the statements about dic3onary values if false?


a) More than one key can have the same value
b) The values of the dic3onary can be accessed as dict[key]
c) Values of a dic3onary must be unique
d) Values of a dic3onary can be a mixture of leBers and numbers
Answer: c
Explana3on: More than one key can have the same value.

2. If a is a dic3onary with some key-value pairs, what does a.pop


item() do?
a) Removes an arbitrary element
b) Removes all the key-value pairs
c) Removes the key-value pair for the key given as an argument
d) Invalid method for dic3onary
Answer: a
Explana3on: The method pop item() removes a random key-value
pair.

3. Name the important escape sequence in Python.


Ans- Some of the important escape sequences in Python are as
follows:
• \\: Backlash
• \’: Single quote
• \”: Double quote
• \f: ASCII from feed
• \n: ASCII linefeed
• \t: ASCII tab
• \v: Ver3cal tab

Page 2 of 9
iNeuron Intelligence Pvt Ltd

4. What is a list?
Ans- A list is a in built Python data structure that can be changed. It is
an ordered sequence of elements and every element inside the list
may also be called as item. By ordered sequence, it is meant that
every element of the list that can be called individually by its index
number. The elements of a list are enclosed in square brackets [].

5. How would you access the element of the following list?

6. Concatenate the two strings.

Page 3 of 9
iNeuron Intelligence Pvt Ltd

7. What is the difference between append () and extend () func3on


for lists?
Ans- The append () func3on allows you to add one element to a list
whereas extend () allows you to add more than one element to the
list.

8. How the format method works?


Ans- The format method works by pu`ng a period directly aaer the
ending string quota3on, followed by the keyword “format”. Within
the parenthesis aaer the keyword are the variables that will be
injected into the string. No maBer what data type it is, it will insert it
into the string in the proper loca3on, which brings up the ques3on,
how does it know where to put it? That’s where the curly brackets
come in to play. The order of the curly brackets is the same order for
the variables within the format parenthesis. To include mul3ple
variables in one format string, you simply separate each by a comma.
Let’s check out some examples:

Page 4 of 9
iNeuron Intelligence Pvt Ltd

9. How the strings are stored?

Ans- When a computer saves a string into memory, each character


within the string is assigned what we call an “index.” An index is
essen3ally a loca3on in memory. Think of an index as a posi3on in a
line that you’re wai3ng in at the mall. If you were at the front of the
line, you would be given an index number of zero. The person behind
you would be given index posi3on one. The person behind them
would be given index posi3on two and so on.
Q8. Why python is an Object-Oriented programming language?
Ans- Python is an object-oriented (OO) programming language.
Unlike some other object-oriented languages, however, Python
doesn’t force you to use the object-oriented paradigm exclusively: it
also supports procedural programming, with modules and func3ons,
so that you can select the best paradigm for each part of your
program. The object-oriented paradigm helps you group state (data)
and behaviour(code) together in handy packets of func3onality.
Moreover, it offers some useful specialized mechanisms covered in
this chapter, like inheritance and special methods. The simpler
procedural approach, based on modules and func3ons, may be more
suitable when you don’t need the pluses1 of object-oriented
programming. With Python, you can mix and match paradigms.

10. What Are Python’s Technical Strengths?


Ans- Naturally, this is a developer’s ques3on. If you don’t already
have a programming background, the language in the next few
sec3ons may be a bit baffling—don’t worry, we’ll explore all of these
terms in more detail as we proceed through this book. For
developers, though, here is a quick introduc3on to some of Python’s
top technical features.

Page 5 of 9
iNeuron Intelligence Pvt Ltd

11. How Does Python Stack Up to Language X?


Ans- Finally, to place it in the context of what you may already know,
people some3mes compare Python to languages such as Perl, Tcl,
and Java. This sec3on summarizes common consensus in this
department.

I want to note up front that I’m not a fan of winning by disparaging


the compe33on—it doesn’t work in the long run, and that’s not the
goal here. Moreover, this is not a zero sum game—most
programmers will use many languages over their careers.
Nevertheless, programming tools present choices and tradeoffs that
merit considera3on. Aaer all, if Python didn’t offer something over
its alterna3ves, it would never have been used in the first place.

12. How python is a Rapid Prototyping?


Ans- To Python programs, components wriBen in Python and C look
the same. Because of this, it’s possible to prototype systems in
Python ini3ally, and then move selected components to a compiled
language such as C or C++ for delivery. Unlike some prototyping tools,
Python doesn’t require a complete rewrite once the prototype has
solidified. Parts of the system that don’t require the efficiency of a
language such as C++ can remain coded in Python for ease of
maintenance and use.

13. What is the func3on of interac3ve shell?


Ans- The interac3ve shell stands between the commands give by the
user and the execu3on done by the opera3ng system. It allows users
to use easy shell commands and the user need not be bothered
about the complicated basic func3ons of the Opera3ng System. This
also protects the opera3ng system from incorrect usage of system
func3ons.

Page 6 of 9
iNeuron Intelligence Pvt Ltd

14. What does the pop() func3on do?


Ans- The pop func3on can be used to remove an element from a
par3cular index and if no index value is provided, it will remove the
last element. The func3on returns the value of the element removed.

15. Is there any method to extend a list?

Page 7 of 9
iNeuron Intelligence Pvt Ltd

16. Is there any method to clear the contents of a list?


Ans- Contents of a list can be cleared using clear () func3on.

17. How to insert the item in a list.


Ans-

18. How to copy the elements of a list?

19. When would you prefer to use a tuple or list?


Ans-Tuples and lists can be used for similar situa3ons but tuples are
generally preferred for collec3on of heterogenous datatypes whereas
list are considered for homogeneous data types. Itera3ng through a
tuple is faster than itera3ng through list. Tuples are idle for storing
values that you don’t want to change. Since Tuples are immutable,
the values within are write-protected.

Page 8 of 9
iNeuron Intelligence Pvt Ltd

20. How can you create a tuple?

Page 9 of 9
iNeuron Intelligence Pvt Ltd

1. Present different types of tuples.

2. How to access Python Tuple Elements


Ans- We can use the index operator [] to access an item in a tuple,
where the index starts from 0.
So, a tuple having 6 elements will have indices from 0 to 5. Trying to
access an index outside of the tuple index range (6, 7, ... in this
example) will raise an Index Error.
The index must be an integer, so we cannot use float or other types.
This will result in Type Error.
Likewise, nested tuples are accessed using nested indexing, as shown
in the example below.

Page 2 of 8
iNeuron Intelligence Pvt Ltd

3. How to use negaNve indexing in tuple?


Ans- Python allows negaNve indexing for its sequences.

The index of -1 refers to the last item, -2 to the second last item and
so on. For example,

4.Usage of slicing in tuple.


Ans- We can access a range of items in a tuple by using the slicing
operator colon:

5. Which of the following is invalid variable?


a) string_123
b) _hello

Page 3 of 8
iNeuron Intelligence Pvt Ltd

c) 12_hello
d) None of these

Answer – c) 12_hello

6. Is python idenNfiers case sensiNve?


a) False
b) True
c) Depends on program
d) Depends on computer

Answer – b) True

7. Which of the following statements is true regarding Python?


a) Python does not support object-oriented programming.
b) Python uses indentaNon to indicate block structure.
c) Python is a compiled language.
d) Python is a staNcally typed language.

Answer – b) uses indentaNon to indicate block structure.


8. List in Python is ................in nature.
a) funcNonable
b) mutable
c) immutable
d) None of these

Answer- b) mutable

9. Which of the following is NOT a valid type code for Python array?
a) 'i'
b) 'f'

Page 4 of 8
iNeuron Intelligence Pvt Ltd

c) 'd'
d) 's'
Answer – d) 's'

10. What is the output of the following Python code?


import array
a = array.array('i', [1, 2, 3])
print(a[0])

a) 0
b) 2
c) 1
d) 3
Answer – c) 1

11. When was Python 3.0 released?


a. 3 December 2008
b. 4 December 2008
c. 5 December 2008
d. 3 December 2010
Answer- 1. The new version of Python 3.0 was released on December
3, 2008.

12. Who founded Python?


a. Alexander G. Bell
b. Vincent van Gogh
c. Leonardo da Vinci
d. Guido van Rossum
Answer. d. The idea of Python was conceived by Guido van Rossum in
the later 1980s.

Page 5 of 8
iNeuron Intelligence Pvt Ltd

13. What are the people who specialize in Python called?


a. Pythonic
b. Unpythonic
c. Monty Python
d. Pythonistas
Answer. d. the people who specialize, or are great admirers of this
programming language are called as Pythonistas. They are extremely
knowledgeable people.

14. What is the type of programming language supported by Python?


a. Object-oriented
b. FuncNonal programming
c. Structured programming
d. All of the above
Answer. d. Python is an interpreted programming language,
supporNng object-oriented, structured, and funcNonal programming.

15. All the keywords in Python are in_


a. Lower case
b. Upper case
c. Capitalized
d. None of the above

Answer. d. Only True, False and None are capitalized and all the
others in lower case.

16. What is the order in which namespaces in Python looks for an


idenNfier?
a. First, the python searches for the built-in namespace, then the
global namespace and then the local namespace

Page 6 of 8
iNeuron Intelligence Pvt Ltd

b. Python first searches for the built-in namespace, then local and
finally the global namespace
c. Python first searches for local namespace, then global
namespace and finally the built-in namespace
d. Python searches for the global namespace, followed by the
local namespace and finally the built-in namespace.

Answer. C. Python first searches for the local namespace, followed by


the global and finally the built-in namespace.

17. What is Python code-compiled or interpreted?


a. The code is both compiled and interpreted
b. Neither compiled nor interpreted
c. Only compiled
d. Only interpreted
Answer. b. There are a lot of languages which have been
implemented using both compilers and interpreters, including C,
Pascal, as well as python.

18. What is the funcNon of pickling in python?


a. Conversion of a python object
b. Conversion of database into list
c. Conversion of byte stream into python object hierarchy
d. Conversion of list into database
Answer. a. The process of pickling refers to sterilizing a Python object,
which means converNng a byte stream into python object hierarchy.
The process which is the opposite of pickling is called unpickling.

Page 7 of 8
iNeuron Intelligence Pvt Ltd

19. How to create a python tuple index?

20.what are the numeric data types in python?

Ans- In Python, numeric data type is used to hold numeric values.


Integers, floaNng-point numbers and complex numbers fall under
Python numbers category. They are defined as int, float and complex
classes in Python.

• int - holds signed integers of non-limited length.


• float - holds floaNng decimal points and it's accurate up to 15
decimal places.
• complex - holds complex numbers.

Page 8 of 8
iNeuron Intelligence Pvt Ltd

1. Suppose there are two sets, set1 and set2, where set1 is the
superset of set2. It is required to get only the unique elements of
both the sets. Which of the following will serve the purpose?
set1= {2,3}

set2= {3,2}

set3= {2,1}

if(set1==set2):

print("yes")

else:

print("no")

if(set1==set3):

print("yes")

else:

print("no")
A. set1|set2
B. set1&set2
C. set1-set2
D. None of the above
Ans: C

ExplanaRon: set1-set2 will serve the purpose.

Page 2 of 10
iNeuron Intelligence Pvt Ltd

2. The elements of a list are arranged in descending order. Which of


the following two will give same outputs?
i. print(list_name.sort())
ii. print(max(list_name))
iii. print(list_name.reverse())
iv. print(list_name[-1])

A. i, ii
B. i, iii
C. ii, iii
D. iii, iv
Ans: B
ExplanaRon: print(list_name. sort ()) and print(list_name.reverse())
will give same outputs.

3. What will be the output of below Python code?

list1=[1,3,5,2,4,6,2]
list1.remove(2)
print(sum(list1))
A. 18
B. 19
C. 21
D. 22

Ans: C
ExplanaRon: 21 will be the result a]er the execuRon of above Python
code.

4. Which of the following would give an error?

Page 3 of 10
iNeuron Intelligence Pvt Ltd

A. list1 = []
B. list1= [] *3
C. list1= [2,8,7]
D. None of the above
Ans: D
ExplanaRon: None of the above will result in error

5. What is type conversion in python?

Ans - When we perform any operaRon on variables of different


datatypes, the data of one variable will be converted to a higher
datatype among the two variables and the operaRon is completed.
When this conversion is done by interpreter automaRcally then it is
known as implicit type conversion while conversions is done by user
then it is called explicit type conversion.

num1=10
num2="20"
result=num1+int(num2)
print(result)

6. When we want to treat some data as a group, it would not be good


to create individual variables for each data. We can store them
together as a collecRon.

Ans- There are many collecRon data types which are supported by
Python-

1. List- List can be used to store a group of elements together in a


sequence.

Page 4 of 10
iNeuron Intelligence Pvt Ltd

2. Tuple- A tuple is an immutable sequence of Python objects. Tuples


are sequences, just like lists.
3. String- In a program, not all values will be numerical. We will also
have alphabeRcal or alpha numerical values. Such values are called
strings.
4. Set- A set is an unordered group of values with no duplicate
entries. Set can be created by using the keyword set or by using curly
braces {}. set funcRon is used to eliminate duplicate values in a list.
5. DicRonary- A dicRonary can be used to store an unordered
collecRon of key-value pairs. The key should be unique and can be of
any data type. Like lists, dicRonaries are mutable.

7. What is math module?

Answer - math is another useful module in Python. Once you have


imported the math module, you can use some of the below
funcRons:

1. math. ceil(x) - Smallest integer greater than or equal to x


2. math. floor(x) - Largest integer smaller than or equal to x
3. math.factorial(x) - Factorial of x
4. math. fabs(x) - Gives absolute value of x

8. What are the differences between python 2 and 3?

Answer -The main differences between python 2 and python 3 are as


follows -
python 2 python 3
a) print statement is treated print statement is treated more
more as statement as statement
b) integer size limited to 32 bits integer size unlimited

Page 5 of 10
iNeuron Intelligence Pvt Ltd

c) complex Simplified
d) ASCII is used. Unicode is used.

9. What are docstrings in Python?

Answer - Docstrings are not actually comments, but they are


documentaRon strings. These docstrings are within triple quotes.
They are not assigned to any variable and therefore, at Rmes, serve
the purpose of comments as well.
"""
Using docstring as a comment.
This code divides 2 numbers
"""
a=10
b=5
c=a/b
print(c)
Output -
2.0

10. What is __init__ in Python?

Answer - "__init__" is a reserved method in python classes. It is


called as a constructor in object-oriented terminology. This method
is called when an object is created from a class and it allows the
class to iniRalize the anributes of the class.

11. Does Python have Opp’s concepts?

Ans - Python is an object-oriented programming language. This


means that any program can be solved in python by creaRng an
Page 6 of 10
iNeuron Intelligence Pvt Ltd

object model. However, Python can be treated as procedural as well


as structural language.

12. How will you capitalize the first lener of string?


Ans- In Python, the capitalize () method capitalizes the first lener of a
string. If the string already consists of a capital lener at the
beginning, then, it returns the original string.

13. Why we use Lambda FuncRons?

Ans - Lambda funcRons are used when you need a funcRon for a
short period of Rme. This is commonly used when you want to pass a
funcRon as an argument to higher-order funcRons, i.e. funcRons that
take other funcRons as their arguments.

14. What is ExcepRon handling in python?

Ans - SomeRmes the programs may misbehave or terminate/crash


unexpectedly due to some unexpected events during the execuRon
of a program. These unexpected events are called as excepRons and
the process of handling them to avoid misbehaviour or crashing the
program is called as excepRon handling.

15. What are funcRons in python?

Ans - FuncRons are set of instrucRons to perform a specific task.


Below is the syntax of funcRons in python.
def funcRon_name ([arg1, ..., argn]):
#statements
[return value]
variable_name = funcRon_name ([val1, ..., valn])

Page 7 of 10
iNeuron Intelligence Pvt Ltd

16. How many types of arguments are there in python?

Ans- Programming languages allow controlling the ordering and


default values of arguments.
1. PosiRonal Default way of specifying arguments. In this, the order,
count and type of actual argument should exactly match to that of
formal argument. Else, it will result in error.

def funcRon_name (arg1, arg2):


#statements
return result
res = funcRon_name (val1, val2)
2. Keyword: Allow flexibility in order of passing actual arguments by
menRoning the argument name.

def funcRon_name (arg1, arg2):


#statements
return result
res = funcRon_name (arg2=val2, arg1=val1)
3. Default: Allow to specify the default value for an argument in the
funcRon signature. It is used only when no value is passed for that
argument else it works normally. In python default arguments should
be last in order.

def funcRon_name (arg1, arg2=default value):


#statements
return result

Page 8 of 10
iNeuron Intelligence Pvt Ltd

res = funcRon_name(val1)
4. Variable argument count: Allow funcRon to have variable number
of arguments. In python, any argument name starRng with '*' is
consider to be vary length argument. It should be last in order. It will
copy all values beyond that posiRon into a tuple.

def funcRon_name (arg1, arg2, *arg3):


#statements
return result
res = funcRon_name (val1, val2, val3, val4, val5)

17. What is random module?

Answer -Python has many inbuilt packages and modules. One of the
most useful modules is random. This module helps in generaRng
random numbers.

The code given below generates a random number between x and y-


1 (both inclusive) using the randrange funcRon of the random
module.

import random
a=20
b=30
print(random. randrange (a, b))
output:
Any random number between 20 to 30.

Page 9 of 10
iNeuron Intelligence Pvt Ltd

18. What is seek() funcRon in python?


Answer - Python provides seek() funcRon to navigate the file object
pointer to the required posiRon specified.
Syntax: file_object. seek(offset, [whence])
//file_object indicates the file object pointer to be navigated
//offset indicates which posiRon the file object pointer is to be
navigated

19. What is PEP 8??

Ans- PEP 8 is a coding convenRon, a set of recommendaRons, about


how to write your Python code more readable.

20. What is pickling and unpickling in Python?

Ans- Pickling is a way to convert a python object (list, dict, etc.) into a
character stream. Pickle has two main methods. The first one is
dump, which dumps an object to a file object and the second one is
load, which loads an object from a file object.

While the process of retrieving original Python objects from the


stored string representaRon is called unpickling.

Page 10 of 10
iNeuron Intelligence Pvt Ltd

1. What is namespace in Python?

Ans- In Python, every name introduced has a place where it lives and
can be hooked for. This is known as namespace. It is like a box where
a variable name is mapped to the object placed. Whenever the
variable is searched out, this box will be searched, to get
corresponding object.

2. What is difference between range and xrange?

Ans- The differences between range and xrange are as follows –

Range Xrange
a) Access via list method Access via index
b) slower for larger range Faster
c) python 2 and python 3 python 2 and python 3

3. Which of the following funcJon is used to know the data type of a


variable in Python?

A. datatype ()
B. typeof()
C. type()
D. vartype()
View Answer
Ans: C

ExplanaJon: type() funcJon is used to know the data type of a


variable in Python. So,opJon C is correct.
Page 2 of 10
iNeuron Intelligence Pvt Ltd

4. What is the output of following: set([1,1,2,3,4,2,3,4])

A. [1,1,2,3,4,2,3,4]
B. {1,2,3,4}
C. {1,1,2,3,4,2,3,4}
D. Invalid Syntax
Ans- B
ExplanaJon: Set will remove the duplicate values from the list. So,
OpJon B is correct.

5. Which of the following statements is used to create an empty set?

A. []
B. {}
C. ()
D. set()
Ans: D
ExplanaJon: set() is used to create an empty set. So, OpJon D is
correct.

6. Which one of the following is mutable data type?

A. set
B. int
C. str
D. tuple
View Answer

Ans: A

Page 3 of 10
iNeuron Intelligence Pvt Ltd

ExplanaJon: set is one of the following is mutable data type. So,


opJon A is correct.

7. Which one of the following is immutable data type?

A. list
B. set
C. int
D. dict
View Answer

Ans: C
ExplanaJon: int one of the following is immutable data type. So,
OpJon C is correct.
Q49. How to get last element of list in python? Suppose we have list
with name arr, contains 5 elements.

A. arr[0]
B. arr[5]
C. arr[last]
D. arr[-1]
Ans: D
ExplanaJon: The arr[-n] syntax gets the nth-to-last element. So arr[-
1] gets the last element, arr[-2] gets the second to last, etc. So,
OpJon D is correct.

8. How to copy one list to another in python?

A. l1[] = l2[]
B. l1[] = l2

Page 4 of 10
iNeuron Intelligence Pvt Ltd

C. l1[] = l2[:]
D. l1 = l2
View Answer

Ans- C
ExplanaJon: OpJon A and B syntax is incorrect while D will point
both name to same list. Hence C is the best way to copy the one list
to another. So, OpJon C is correct.

9. Suppose a tuple arr contains 10 elements. How can you set the 5th
element of the tuple to 'Hello'?

A. arr[4] = 'Hello'
B. arr(4) = 'Hello'
C. arr[5] = 'Hello'
D. Elements of tuple cannot be changed
Ans: D
ExplanaJon: Tuples are immutable that is the value cannot be
changed. So, OpJon D is correct.

10. Which of the following creates a tuple?

A. tuple1= ("a", "b")


B. tuple1[2] = ("a”, ”b")
C. tuple1= (5) *2
D. None of the above
Ans: A
ExplanaJon: We can create a tuple using tuple1= ("a", "b").

11. Choose the correct opJon with respect to Python.

Page 5 of 10
iNeuron Intelligence Pvt Ltd

A. Both tuples and lists are immutable.


B. Tuples are immutable while lists are mutable.
C. Both tuples and lists are mutable.
D. Tuples are mutable while lists are immutable.
View Answer

Ans- B
ExplanaJon: Tuples are immutable while lists are mutable the correct
opJon with respect to Python.

12. What will be the output of below Python code?

tuple1= (5,1,7,6,2)

tuple1.pop(2)

print(tuple1)

A. (5,1,6,2)
B. (5,1,7,6)
C. (5,1,7,6,2)
D. Error
Ans- D
ExplanaJon: The following code will result in error.

13. What will be the output of below Python code?

tuple1= (2,4,3)
tuple3=tuple1*2

Page 6 of 10
iNeuron Intelligence Pvt Ltd

print(tuple3)

A. (4,8,6)
B. (2,4,3,2,4,3)
C. (2,2,4,4,3,3)
D. Error
Ans- B
ExplanaJon: The following code will result in (2,4,3,2,4,3).

14. What will be the output of below Python code?

tupl=([2,3],"abc",0,9)

tupl [0][1] =1

print(tupl)

A. ([2,3],"abc",0,9)
B. ([1,3],"abc",0,9)
C. ([2,1],"abc",0,9)
D. Error
Ans: C
ExplanaJon: The output for the following code is ([2,1],"abc",0,9).

15. What will be the output of the following Python code?

def fn(var1):
var1.pop(1)
var1= [1,2,3]
fn(var1)
print(var1)

Page 7 of 10
iNeuron Intelligence Pvt Ltd

A. [1,2,3]
B. [1,3]
C. [2,3]
D. [1,2]
View Answer

Ans- B
ExplanaJon: [1,3] will be the output of the following Python code.

16. def funcJon1(var1):


var1=var1+10
print (var1)
var1=12
funcJon1(var1)
print(var1)
A. 22
22
B. 12
12
C. 22
22
D. 12
22

Ans- C
ExplanaJon: 22

Page 8 of 10
iNeuron Intelligence Pvt Ltd

17. What will be the output of the following Python code?

def funcJon1(var1=5, var2=7):


var2=9
var1=3
print (var1, " ", var2)
funcJon1(10,12)
A. 5 7
B. 3 9
C. 10 12
D. Error
Ans- B
ExplanaJon: 3 9 will be the output of the following Python code.

18. Which among the following are mutable objects in Python?


(i) List
(ii) Integer
(iii) String
(iv) Tuple

A. i only
B. i and ii only
C. iii and iv only
D. iv only

Ans- A

ExplanaJon: List are mutable objects in Python.

19.How to Check Whether a Number is Even or Odd.


Page 9 of 10
iNeuron Intelligence Pvt Ltd

20. How to check Whether a Number is Prime or not.

Page 10 of 10
iNeuron Intelligence Pvt Ltd

1. Which of the following is not used as loop in Python?

A. for loop
B. while loop
C. do-while loop
D. None of the above
Ans: C
ExplanaDon: do-while loop is not used as loop in Python.

2. Which of the following is False regarding loops in Python?

A. Loops are used to perform certain tasks repeatedly.


B. While loop is used when mulDple statements are to executed
repeatedly unDl the given condiDon becomes False
C. While loop is used when mulDple statements are to executed
repeatedly unDl the given condiDon becomes True.
D. for loop can be used to iterate through the elements of lists.

Ans: B
ExplanaDon: While loop is used when mulDple statements are to
executed repeatedly unDl the given condiDon becomes False
statement is False regarding loops in Python.

3. What will be the output of given Python code?

n=7

c=0

while(n):

Page 2 of 11
iNeuron Intelligence Pvt Ltd

if(n>5):

c=c+n-1

n=n-1

else:

break

print(n)

print(c)

A. 5 11
B. 5 9
C. 7 11
D. 5 2
Ans: A
ExplanaDon: 5 11 will be the output of the given code

4. What will be the output of the following Python code?

for i in range(0,2,-1):

print("Hello")

A. Hello
B. Hello Hello

Page 3 of 11
iNeuron Intelligence Pvt Ltd

C. No Output
D. Error
View Answer

Ans: C
ExplanaDon: There will be no output of the following python code.

5. What keyword would you use to add an alternaDve condiDon to an


if statement?

A. else if
B. elseif
C. elif
D. None of the above
View Answer

Ans : C
ExplanaDon: elif is used to add an alternaDve condiDon to an if
statement. So, opDon C is correct.

6. Can we write if/else into one line in python?

A. Yes
B. No
C. if/else not used in python
D. None of the above
View Answer

Ans : A

Page 4 of 11
iNeuron Intelligence Pvt Ltd

ExplanaDon: Yes, we can write if/else in one line. For eg i = 5 if a > 7


else 0. So, opDon A is correct.

7. What will be output of this expression:

'p' + 'q' if '12'.isdigit() else 'r' + 's'


A. pq
B. rs
C. pqrs
D. pq12
View Answer

Ans: A
Explanation: If condition is true so pq will be the output. So, option A
is correct.

8. Which statement will check if a is equal to b?

A. if a = b:
B. if a == b:
C. if a === c:
D. if a == b
View Answer

Ans: B
Explanation: if a == b: statement will check if a is equal to b. So,
option B is correct.

9. A while loop in Python is used for what type of iteraDon?

A. indefinite
B. discriminant
Page 5 of 11
iNeuron Intelligence Pvt Ltd

C. definite
D. indeterminate

Ans: A
ExplanaDon: A while loop implements indefinite iteraDon, where the
number of Dmes the loop will be executed is not specified explicitly
in advance. So, opDon A is correct.

10. When does the else statement wri`en aaer loop executes?

A. When break statement is executed in the loop


B. When loop condiDon becomes false
C. Else statement is always executed
D. None of the above

Ans: B
ExplanaDon: Else statement aaer loop will be executed only when
the loop condiDon becomes false. So, opDon B is correct.

11. A loop becomes infinite loop if a condition never becomes


________.

A. TRUE

B. FALSE

C. Null

D. Both A and C

Page 6 of 11
iNeuron Intelligence Pvt Ltd

View Answer

Ans: B

Explanation: A loop becomes infinite loop if a condition never


becomes FALSE. You must use caution when using while loops
because of the possibility that this condition never resolves to a
FALSE value. This results in a loop that never ends. Such a loop is
called an infinite loop.

12. If the else statement is used with a while loop, the else statement
is executed when the condition becomes _______.

A. TRUE

B. FALSE

C. Infinite

D. Null

Ans: B

Explanation: If the else statement is used with a while loop, the else
statement is executed when the condition becomes false.

13. The ________ statement is a null operation.

Page 7 of 11
iNeuron Intelligence Pvt Ltd

A. break
B. exit
C. return
D. pass

Ans: D
Explanation: The pass statement is a null operation; nothing happens
when it executes.

14. The continue statement can be used in?

A. while loop
B. for loop
C. do-while
D. Both A and B

Ans: D
Explanation: The continue statement can be used in both while and
for loops.

15. Which of the following is a valid for loop in Python?

A. for(i=0; i < n; i++)


B. for i in range(0,5):
C. for i in range(0,5)
D. for i in range(5)
View Answer

Ans: B

Page 8 of 11
iNeuron Intelligence Pvt Ltd

ExplanaDon: For statement always ended with colon (:). So, opDon B
is correct.

16. Which of the following sequences would be generated bt the


given line of code?

range (5, 0, -2)


A. 5 4 3 2 1 0 -1
B. 5 4 3 2 1 0
C. 5 3 1
D. None of the above
View Answer

Ans: C
ExplanaDon: The iniDal value is 5 which is decreased by 2 Dll 0 so we
get 5, then 2 is decreased so we get 3 then the same thing repeated
we get 1 and now when 2 is decreased we get -1 which is less than 0
so we stop and hence we get 5 3 1. So, opDon C is correct.

17. When does the else statement wri`en aaer loop executes?

A. When break statement is executed in the loop


B. When loop condiDon becomes false
C. Else statement is always executed
D. None of the above

Ans: B

ExplanaDon: Else statement aaer loop will be executed only when


the loop condiDon becomes false. So, opDon B is correct.

Page 9 of 11
iNeuron Intelligence Pvt Ltd

18. The ________ statement is a null operaDon.

A. break
B. exit
C. return
D. pass
View Answer

Ans: D
ExplanaDon: The pass statement is a null operaDon; nothing happens
when it executes.

19. The conDnue statement can be used in?

A. while loop
B. for loop
C. do-while
D. Both A and B
View Answer

Ans: D
ExplanaDon: The conDnue statement can be used in both while and
for loops

20. What will be the output of the following Python code?

list1 = [3 , 2 , 5 , 6 , 0 , 7, 9]

sum = 0

Page 10 of 11
iNeuron Intelligence Pvt Ltd

sum1 = 0

for elem in list1:

if (elem % 2 == 0):

sum = sum + elem

conDnue

if (elem % 3 == 0):

sum1 = sum1 + elem

print(sum , end=" ")

print(sum1)

A. 8 9
B. 8 3
C. 2 3
D. 8 12
View Answer

Ans- D
ExplanaDon: The output of the following python code is 8 12.

Page 11 of 11
iNeuron Intelligence Pvt Ltd

1. How to Check whether the Given Year is Leap Year or Not.


Ans-

2. Write a python program to Print Fibonacci Series.

3. Write a Python Program to Check Vowel or Consonant.

Page 2 of 11
iNeuron Intelligence Pvt Ltd

4. Which statement is correct?

A. List is immutable && Tuple is mutable


B. List is mutable && Tuple is immutable
C. Both are Mutable.
D. Both are Immutable
Ans : B

ExplanaRon: List is mutable and Tuple is immutable. A mutable data


type means that a python object of this type can be modified. An
immutable object can't. So, OpRon B is correct.

5. To create a class, use the keyword?

A. new
B. except
C. class
D. object
Ans: C

ExplanaRon: To create a class, use the keyword class

Page 3 of 11
iNeuron Intelligence Pvt Ltd

6. All classes have a funcRon called?

A. __init__
B. __init__()
C. init
D. init()

Ans: B

ExplanaRon: All classes have a funcRon called __init__(), which is


always executed when the class is being iniRated.

7. The __________ parameter is a reference to the current instance


of the class, and is used to access variables that belong to the class.

A. __init__()
B. self
C. both A and B
D. None of the above

Ans: B

ExplanaRon: The self-parameter is a reference to the current instance


of the class, and is used to access variables that belong to the class.

8. You can delete properRes on objects by using the ______ keyword.

A. delete
B. dedl

Page 4 of 11
iNeuron Intelligence Pvt Ltd

C. del
D. drop

Ans: C

ExplanaRon: You can delete properRes on objects by using the del


keyword

9. A variable that is defined inside a method and belongs only to the


current instance of a class is known as?

A. Inheritance
B. Instance variable
C. FuncRon overloading
D. InstanRaRon

Ans: B

ExplanaRon: Instance variable: A variable that is defined inside a


method and belongs only to the current instance of a class.

10. A class variable or instance variable that holds data associated


with a class and its object is known as?

A. Class variable
B. Method
C. Operator overloading
D. Data member

Page 5 of 11
iNeuron Intelligence Pvt Ltd

Ans: D

ExplanaRon: Data member: A class variable or instance variable that


holds data associated with a class and its objects.

11. What is setacr() used for?

A. To set an acribute
B. To access the acribute of the object
C. To check if an acribute exists or not
D. To delete an acribute

Ans: A

ExplanaRon: setacr (obj, name, value) is used to set an acribute. If


acribute doesn’t exist, then it would be created.
12. What will be output for the following code?

class test:
def __init__(self,a):
self.a=a

def display(self):
print(self.a)
obj= test ()
obj. display ()

Page 6 of 11
iNeuron Intelligence Pvt Ltd

A. Runs normally, doesn’t display anything


B. Displays 0, which is the automaRc default value
C. Error as one argument is required while creaRng the object
D. Error as display funcRon requires addiRonal argument

Ans: C
ExplanaRon: Since, the __init__ special method has another
argument a other than self, during object creaRon, one argument is
required. For example: obj=test(“Hello”)

13. ___ represents an enRty in the real world with its idenRty and
behaviour.

A. A method
B. An object
C. A class
D. An operator
View Answer
Ans- B

ExplanaRon: An object represents an enRty in the real world that can


be disRnctly idenRfied. A class may define an object.

14. Which of the following is correct with respect to OOP concept in


Python?

Page 7 of 11
iNeuron Intelligence Pvt Ltd

A. Objects are real world enRRes while classes are not real.
B. Classes are real world enRRes while objects are not real.
C. Both objects and classes are real world enRRes.
D. Both object and classes are not real.
Ans: A

ExplanaRon: In OOP, classes are basically the blueprint of the objects.


They does not have physical existence.

15. In python, what is method inside class?

A. acribute
B. object
C. argument
D. funcRon

Ans: D

ExplanaRon: In OOP of Python, funcRon is known by "method".

16. Which one of the following is correct?

A. In python, a dicRonary can have two same keys with different


values.
B. In python, a dicRonary can have two same values with different
keys
C. In python, a dicRonary can have two same keys or same values
but cannot have two same key-value pair
D. In python, a dicRonary can neither have two same keys nor two
same values.
Page 8 of 11
iNeuron Intelligence Pvt Ltd

Ans: B

ExplanaRon: In python, a dicRonary can have two same values with


different keys.

17. What will be the following Python code?

dict1={"a":10,"b":2,"c":3}

str1=""

for i in dict1:

str1=str1+str(dict1[i])+" "

str2=str1[:-1]

print(str2[::-1])

A. 3, 2

B. 3, 2, 10

C. 3, 2, 01

D. Error

Ans: C

ExplanaRon: 3, 2, 01 will be the following Python code output.

Page 9 of 11
iNeuron Intelligence Pvt Ltd

18. Write a Python Program to Find Factorial of a Number.

19. What are operators?


Ans-Operators are required to perform various operaRons on data.
They are special symbols that are required to carry out arithmeRc
and logical operaRons. The values on which the operator operates
are called operands.
So, if we say 10/5=2
Here ‘/’ is the operator that performs division and 10 and 5 are the
operands. Python has following operators defined for various
operaRons:
a) ArithmeRc Operators
b) RelaRonal Operators
c) Logical Operators
d)Assignment Operators
e) Bitwise Operators
f) Membership Operators
g) IdenRty Operators

20. What are ArithmeRc operators? What are various types of


arithmeRc operators that we can use in python?

Page 10 of 11
iNeuron Intelligence Pvt Ltd

Ans- They are used to perform mathemaRcal funcRons such as


addiRon, subtracRon, division, and mulRplicaRon. Various types of
arithmeRc operators that we can use in Python are as follows:

Page 11 of 11
iNeuron Intelligence Pvt Ltd

1. What is the Arithme.c operators precedence in Python?


Ans- When more than one arithme.c operator appears in an expression the
opera.ons will execute in a specific order. In Python the opera.on precedence
follows as per the acronym PEMDAS.
Parenthesis
Exponent
Mul.plica.on
Addi.on
Division
Subtrac.on
Q4. Evaluate the following keeping Python’s precedence of operators.
a=2
b=4
c=5
d=4

print(a+b+c)
print(a+b*c+d)
print(a/b+c/d)
print(a+b*c+a/b+d)
Ans-

2. What are rela.onal operators?


Ans- Rela.onal operators are known as condi.onal operators.

Page 2 of 9
iNeuron Intelligence Pvt Ltd

Equal

x=y

True if x is equal to y.

>

Greater than

x>y

True if x is greater than y.

<

Less than

x<y

True if x is less than y.

>=

Greater than or equal to

x >= y

True if x is greater than or equal to y.

<=

Less than or equal to


Page 3 of 9
iNeuron Intelligence Pvt Ltd

x <= y

True if x is less than or equal to y.

!=

Not equal to

x != y

True if x is not equal to y.

3. a = 5, b = 6, c = 7, d = 7
What will be the outcome for the following:
1. a <=b>=c
2. -a+b==c>d
3. b+c==6+d>=13
Ans-

4. What is the func.on of pickling in python?


a. Conversion of a python object
b. Conversion of database into list
c. Conversion of byte stream into python object hierarchy

Page 4 of 9
iNeuron Intelligence Pvt Ltd

d. Conversion of list into database

Answer. a. The process of pickling refers to sterilizing a Python object, which


means conver.ng a byte stream into python object hierarchy. The process
which is the opposite of pickling is called unpickling.

5. What is Python code-compiled or interpreted?


a. The code is both compiled and interpreted
b. Neither compiled nor interpreted
c. Only compiled
d. Only interpreted

Answer. b. There are a lot of languages which have been implemented using
both compilers and interpreters, including C, Pascal, as well as python.

6. When was Python released?


1. 16 October, 2001
2. 16 October 2000
3. 17 October 2000
4. 17 October 2001

Answer. b. 16 October 2000. The idea of Python was conceived in the later
1980s, but it was released on a. 16 October 2000.

7. When was Python 3.0 released?


1. 3 December 2008
2. 4 December 2008
3. 5 December 2008
4. 3 December 2010

Answer. a. The new version of Python 3.0 was released on December 3, 2008.

Page 5 of 9
iNeuron Intelligence Pvt Ltd

8. Who founded Python?


1. Alexander G. Bell
2. Vincent van Gogh
3. Leonardo da Vinci
4. Guido van Rossum

Answer. d. The idea of Python was conceived by Guido van Rossum in the later
1980s.

9. What is Python?
1. A programming language
2. Computer language
3. Binary language
4. None of the above
Answer. a. Python is a programming language, basically a very high-level and a
general-purpose language.

10. What are the people who specialize in Python called?


1. Pythonic
2. Unpythonic
3. Monty Python
4. Pythoniasts
Answer. d. the people who specialize, or are great admirers of this
programming language are called as Pythoniasts. They are extremely
knowledgeable people.

11. What is the type of programming language supported by Python?


1. Object-oriented
2. Func.onal programming
3. Structured programming
4. All of the above
Page 6 of 9
iNeuron Intelligence Pvt Ltd

Answer. d. Python is an interpreted programming language, suppor.ng object-


oriented, structured, and func.onal programming.

12. When Python is dealing with iden.fiers, is it case sensi.ve?


1. Yes
2. No
3. Machine dependent
4. Can’t say
Answer. a. It is case sensi.ve.

13. What is the extension of the Python file?


1. .pl
2. .py
3. .python
4. .p

Answer. b. The correct extension of python is .py and can be wrilen in any text
editor. We need to use the extension .py to save these files.

14. All the keywords in Python are in_


1. Lower case
2. Upper case
3. Capitalized
4. None of the above

Answer. d. Only True, False and None are capitalized and all the others in lower
case.

15. What does pip mean in Python?


1. Unlimited length
2. All private members must have leading and trailing underscores
Page 7 of 9
iNeuron Intelligence Pvt Ltd

3. Preferred Installer Program


4. None of the above

Answer. c. Variable names can be of any length.

16. The built-in func.on in Python is:


1. Print ()
2. Seed ()
3. Sqrt ()
4. Factorial ()

Answer. a. The func.on seed is a func.on which is present in the random


module. The func.ons sqrt and factorial are a part of the math module. The
print func.on is a built-in func.on which prints a value directly to the system
output.

17. Which of the following defini.ons is the one for packages in Python?
1. A set of main modules
2. A folder of python modules
3. Set of programs making use of python modules
4. Number of files containing python defini.ons and statements

Answer. b. A folder of python modules is called as package of modules.

18. What is the order in which namespaces in Python looks for an iden.fier?
1. First, the python searches for the built-in namespace, then the global
namespace and then the local namespace
2. Python first searches for the built-in namespace, then local and finally
the global namespace
3. Python first searches for local namespace, then global namespace and
finally the built-in namespace

Page 8 of 9
iNeuron Intelligence Pvt Ltd

4. Python searches for the global namespace, followed by the local


namespace and finally the built-in namespace.

Answer. C. Python first searches for the local namespace, followed by the
global and finally the built-in namespace.

19. Which of the following is not a keyword used in Python language?


1. Pass
2. Eval
3. Assert
4. Nonlocal

Answer. b. Eval is used as a variable in Python.

20. Which of the following is the use of func3on in python?


1. Func3ons do not provide be=er modularity for applica3ons
2. One can’t create our own func3ons
3. Func3ons are reusable pieces of programs
4. All of the above

Answer. c. Func3ons are reusable pieces of programs, which allow us


to give a name to a par3cular block of statements, allowing us to run
the block using the specified name anywhere in our program and any
number of 3mes.

Page 9 of 9
iNeuron Intelligence Pvt Ltd

1. Which of the following is a feature of Python Docstring?


1. All functions should have a docstring in python
2. Docstrings can be accessed by the _doc_ attribute on objects
3. This feature provides a very convenient way of associating
documentation with python modules, functions, classes and
methods
4. All of the above

Answer. d. Python has a nifty feature, which is referred to as the


documentation strings, usually referred to by its abbreviated name of
docstrings. They are important tools and one must use them as they
help document the program better along with making it easier to
understand.

2. Amongst which of the following is / are the Numeric Types of Data


Types?

A. int
B. float
C. complex
D. All of the mentioned above

Answer: D) All of the mentioned above

Explanation:

Numeric data types include int, float, and complex, among others. In
information technology, data types are the classification or
categorization of knowledge items. It represents the type of
information that is useful in determining what operations are
frequently performed on specific data.

Page 2 of 13
iNeuron Intelligence Pvt Ltd

3. list, tuple, and range are the ___ of Data Types.

A. Sequence Types
B. Binary Types
C. Boolean Types
D. None of the mentioned above

Answer: A) Sequence Types

Explanation:

The sequence Types of Data Types are the list, the tuple, and the
range. In order to store multiple values in an organized and efficient
manner, we use the concept of sequences.

4. Float type of data type is represented by the float class.

A. True
B. False

Answer: A) True

Explanation:

The float data type is represented by the float class of data types. A
true number with a floating-point representation is represented by
the symbol.

5. Binary data type is a fixed-width string of length bytes?


Page 3 of 13
iNeuron Intelligence Pvt Ltd

A. True
B. False

Answer: A) True

Explanation:

It is a fixed-width string of length bytes, where the length bytes is


declared as an optional specifier to the type, and its width is declared
as an integer.

6. Var binary data type returns variable-width string up to a length of


max-length bytes?

A. TRUE
B. FALSE

Answer: A) TRUE

Explanation:

Var binary - a variable-width string with a length of max-length bytes,


where the maximum number of bytes is declared as an optional
specifier to the type, and where the maximum number of bytes is
declared as an optional specifier to the type.

7. Is Python supports exception handling?

A. Yes
B. No

Page 4 of 13
iNeuron Intelligence Pvt Ltd

Answer: A) Yes

Explanation:

Unexpected events that can occur during a program's execution are


referred to as exceptions, and they can cause the program's normal
flow to be interrupted.

8. The % operator returns the ___.

A. Quotient
B. Divisor
C. Remainder
D. None of the mentioned above

Answer: C) Remainder

Explanation:

The % operator (it is an arithmetic operator) returns the amount that


was left over. This is useful for determining the number of times a
given number is multiplied by itself.

9. The list.pop ([i]) removes the item at the given position in the list?

A. True
B. False

Answer: A) True

Explanation:
Page 5 of 13
iNeuron Intelligence Pvt Ltd

The external is not a valid variable scope in PHP.

10. Python Dictionary is used to store the data in a ___ format.

A. Key value pair


B. Group value pair
C. Select value pair
D. None of the mentioned above

Answer: A) Key value pair

Explanation:

Python Dictionary is used to store the data in a key-value pair format,


which is similar to that of a database. The dictionary data type in
Python is capable of simulating the real-world data arrangement in
which a specific value exists for a specific key when the key is
specified.

11. The following is used to define a ___.

d={

<key>: <value>,

<key>: <value>,

Page 6 of 13
iNeuron Intelligence Pvt Ltd

<key>: <value>

Group

List

Dictionary

All of the mentioned above

Answer: C) Dictionary

12. Python Literals is used to define the data that is given in a


variable or constant?

A. True
B. False

Answer: A) True

Explanation:

It is possible to define literals in Python as data that is provided in a


variable or constant. Literal collections are supported in Python as
well as String and Numeric literals, Boolean and Boolean expressions,
Special literals, and Special expressions.

Page 7 of 13
iNeuron Intelligence Pvt Ltd

13. The if statement is the most fundamental decision-making


statement?

A. True
B. False

Answer: A) True

Explanation:

The if statement is the most fundamental decision-making


statement, and it determines whether or not the code should be
executed based on whether or not the condition is met. If the
condition in the if statement is met, a code body is executed, and the
code body is not otherwise executed.

14. Amongst which of the following if syntax is true?

if condition:

#Will executes this block if the condition is true

if condition

#Will executes this block if the condition is true

if(condition)

Page 8 of 13
iNeuron Intelligence Pvt Ltd

#Will executes this block if the condition is true

None of the mentioned above

Answer: A)

if condition:

#Will executes this block if the condition is true

15. Amongst which of the following is / are the conditional


statement in Python code?

A. if a<=100:
B. if (a >= 10)
C. if (a => 200)
D. None of the mentioned above

Answer: A) if a<=100:

Explanation:

The if statement in Python is used to make decisions in various


situations. It contains a body of code that is only executed when the
condition specified in the if statement is true; if the condition is not
met, the optional else statement is executed, which contains code
that is executed when the else condition is met.

Page 9 of 13
iNeuron Intelligence Pvt Ltd

16. Amongst which of the following is / are the conditional


statement in Python code?

A. if a<=100:
B. if (a >= 10)
C. if (a => 200)
D. None of the mentioned above

Answer: A) if a<=100:

Explanation:

The if statement in Python is used to make decisions in various


situations. It contains a body of code that is only executed when the
condition specified in the if statement is true; if the condition is not
met, the optional else statement is executed, which contains code
that is executed when the else condition is met.

17. Which of the following is false regarding conditional statement in


Python?

A. If-elif is the shortcut for the if-else chain


B. We use the dictionary to replace the Switch case statement
C. We cannot use python classes to implement the switch case
statement
D. None of the mentioned above

Answer: C) We cannot use python classes to implement the switch


case statement

Explanation:

Page 10 of 13
iNeuron Intelligence Pvt Ltd

It is possible to shorten the if-else chain by using the if-elif construct.


Use the if-elif statement and include an else statement at the end,
which will be executed if none of the if-elif statements in the
previous section are true.

18. In a Python program, Nested if Statements denotes?

A. if statement inside another if statement


B. if statement outside the another if statement
C. Both A and B
D. None of the mentioned above

Answer: A) if statement inside another if statement

Explanation:

Nesting an if statement within another if statement is referred to as


nesting in the programming community. It is not always necessary to
use a simple if statement; instead, you can combine the concepts of
if, if-else, and even if-elif-else statements to create a more complex
structure.

19. What will be the output of the following Python code?

a=7

if a>4: print("Greater")

Greater
Page 11 of 13
iNeuron Intelligence Pvt Ltd

None of the mentioned above

Answer: A) Greater

20. What will be the output of the following Python code?

X,y = 12,14

if(x +y==26):

print("true")

else:

print("false")

a) true

b) false

Answer: A) true

Page 12 of 13
iNeuron Intelligence Pvt Ltd

Explanation:

In this code the value of x = 12 and y = 14, when we add x and y the
value will be 26 so x + y= =26. Hence, the given condition will be true.

Page 13 of 13
iNeuron Intelligence Pvt Ltd

1. What will be the output of the following Python code?

x=13

if x>12 or x<15 and x==16:

print("Given condition matched")

else:

print("Given condition did not match")

Given condition matched

Given condition did not match

Both A and B

None of the mentioned above

Answer: A) Given condition matched

Explanation:

In this code the value of x = 13, and the condition 13>12 or 13<15 is
true but 13==16 becomes falls. So, the if part will not execute and
program control will switch to the else part of the program and
output will be "Given condition did not match".
Page 2 of 17
iNeuron Intelligence Pvt Ltd

2. Consider the following code segment and identify what will be the
output of given Python code?

a = int(input("Enter an integer: "))

b = int(input("Enter an integer: "))

if a <= 0:

b = b +1

else:

a=a+1

if inputted number is a negative integer then b = b +1

if inputted number is a positive integer then a = a +1

Both A and B

None of the mentioned above

Answer: C) Both A and B

Explanation:

Page 3 of 17
iNeuron Intelligence Pvt Ltd

In above code, if inputted number is a negative integer, then b = b +1


and if inputted number is a positive integer, then a = a +1. Hence, the
output will be depending on inputted number.

3. The writelines() method is used to write multiple strings to a file?

A. True
B. False

Answer: A) True

Explanation:

In order to write multiple strings to a file, the writelines() method is


used. The writelines() method requires an iterable object, such as a
list, tuple, or other collection of strings, to be passed to it.

4. A text file contains only textual information consisting of ___.

A. Alphabets
B. Numbers
C. Special symbols
D. All of the mentioned above

Answer: D) All of the mentioned above

Explanation:

Unlike other types of files, text files contain only textual information,
which can be represented by alphabets, numbers, and other special
symbols. These types of files are saved with extensions such
Page 4 of 17
iNeuron Intelligence Pvt Ltd

as.txt,.py,.c,.csv,.html, and so on. Each byte in a text file corresponds


to one character in the text.

5. Amongst which of the following is / are the method used to


unpickling data from a binary file?

A. load()
B. set() method
C. dump() method
D. None of the mentioned above

Answer: B) set() method

Explanation:

The load() method is used to unpickle data from a binary file that has
been compressed. The binary read (rb) mode is used to load the file
that is to be loaded. If we want to use the load() method, we can
write Store object = load(file object) in our program. The pickled
Python object is loaded from a file with a file handle named file
object and stored in a new file handle named store object. The
pickled Python object is loaded from a file with a file handle named
file object and stored in a new file handle named store object.

6. Amongst which of the following is / are the method of convert


Python objects for writing data in a binary file?

A. set() method
B. dump() method
C. load() method
D. None of the mentioned above

Page 5 of 17
iNeuron Intelligence Pvt Ltd

Answer: B) dump() method

Explanation:

The dump() method is used to convert Python objects into binary


data that can be written to a binary file. The file into which the data
is to be written must be opened in binary write mode before the data
can be written.

7. The readline() is used to read the data line by line from the text
file.

A. True
B. False

Answer: A) True

Explanation:

It is necessary to use readline() in order to read the data from a text


file line by line. The lines are displayed by employing the print()
command. When the readline() function reaches the end of the file,
it will return an empty string.

Discuss this Question

8. The module Pickle is used to ___.

A. Serializing Python object structure


B. De-serializing Python object structure
C. Both A and B
Page 6 of 17
iNeuron Intelligence Pvt Ltd

D. None of the mentioned above

Answer: C) Both A and B

Explanation:

Pickle is a Python module that allows you to save any object


structure along with its associated data. Pickle is a Python module
that can be used to serialize and de-serialize any type of Python
object structure. Serialization is the process of converting data or an
object stored in memory to a stream of bytes known as byte streams,
which is a type of data stream.

Page 7 of 17
iNeuron Intelligence Pvt Ltd

9. Write a python program to print even length words in a string.


Ans-

Page 8 of 17
iNeuron Intelligence Pvt Ltd

10. Write a Python program to declare, assign and print the string.

Ans-

Page 9 of 17
iNeuron Intelligence Pvt Ltd

11. An ___ statement has less number of conditional checks


than two successive ifs.

A. if else if
B. if elif
C. if-else
D. None of the mentioned above

Answer: C) if-else

Explanation:

A single if-else statement requires fewer conditional checks


than two consecutives if statements. If the condition is true, the
if-else statement is used to execute both the true and false
parts of the condition in question. The condition is met, and
therefore the if block code is executed, and if the condition is
not met, the otherwise block code is executed.

12. In Python, the break and continue statements, together


are called ___ statement.

A. Jump
B. goto
C. compound
D. None of the mentioned above

Answer: B) goto
Page 10 of 17
iNeuron Intelligence Pvt Ltd

Explanation:

With the go to statement in Python, we are basically telling the


interpreter to skip over the current line of code and directly
execute another one instead of the current line of code. You
must place a check mark next to the line of code that you want
the interpreter to execute at this time in the section labelled
"target."

Page 11 of 17
iNeuron Intelligence Pvt Ltd

13. What will be the output of the following Python code?

num = 10

if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
Positive number
Negative number
Real number
None of the mentioned above
Answer: A) Positive number

14. The elif statement allows us to check multiple expressions.

A. True
B. False

Answer: A) True

Explanation:

Page 12 of 17
iNeuron Intelligence Pvt Ltd

It is possible to check multiple expressions for TRUE and to execute a


block of code as soon as one of the conditions evaluates to TRUE
using the elif statement. The elif statement is optional in the same
way that the else statement is.

15. What will be the output of the following Python code?

i=5

if i>11 : print ("i is greater than 11")

No output

Abnormal termination of program

Both A and B

None of the mentioned above

Answer: C) Both A and B

Explanation:

In the above code, the assign value of i = 5 and as mentioned in the


condition if 5 > 11: print ("i is greater than 11"), here 5 is not greater
than 11 so condition becomes false and there will not be any output
and program will be abnormally terminated.

Page 13 of 17
iNeuron Intelligence Pvt Ltd

16. What will be the output of the following Python code?

a = 13

b = 15

print("A is greater") if a > b else print("=") if a == b else print("B is


greater")

A is greater

B is greater

Both A and B

None of the mentioned above

Answer: B) B is greater

17. If a condition is true the not operator is used to reverse the


logical state?

A. True
B. False

Answer: A) True

Explanation:

Page 14 of 17
iNeuron Intelligence Pvt Ltd

In order to make an if statement test whether or not something


occurred, we must place the word not in front of our condition.
When the not operator is used before something that is false, it
returns true as a result. And when something that is true comes
before something that is false, we get False. That is how we
determine whether or not something did not occur as claimed. In
other words, the truth value of not is the inverse of the truth value of
yes. So, while it may not appear to be abstract, this operator simply
returns the inverse of the Boolean value.

18. Loops are known as ___ in programming.

A. Control flow statements


B. Conditional statements
C. Data structure statements
D. None of the mentioned above

Answer: A) Control flow statements

Explanation:

The control flow of a program refers to the sequence in which the


program's code is executed. Conditional statements, loops,
and function calls all play a role in controlling the flow of a Python
program's execution.

Page 15 of 17
iNeuron Intelligence Pvt Ltd

19. The for loop in Python is used to ___ over a sequence or other
iterable objects.

Jump
Iterate
Switch
All of the mentioned above
Answer: B) Iterate

Explanation:

It is possible to iterate over a sequence or other iterable objects


using the for loop in Python. The process of iterating over a sequence
is referred to as traversal. Following syntax can be follow to use for
loop in Python Program –

for val in sequence:


...
loop body
...
For loop does not require an indexing variable to set beforehand.

Discuss this Question

Page 16 of 17
iNeuron Intelligence Pvt Ltd

20. With the break statement we can stop the loop before it has
looped through all the items?

True
False
Answer: A) True

Explanation:

In Python, the word break refers to a loop control statement. It


serves to control the sequence of events within the loop. If you want
to end a loop and move on to the next code after the loop; the break
command can be used to do so. When an external condition causes
the loop to terminate, it represents the common scenario in which
the break function is used in Python.

Page 17 of 17
iNeuron Intelligence Pvt Ltd

1. The continue keyword is used to ___ the current iteration in a


loop.

A. Initiate
B. Start
C. End
D. None of the mentioned above

Answer: C) End

Explanation:

The continue keyword is used to terminate the current iteration of a


for loop (or a while loop) and proceed to the next iteration of the for
loop (or while loop). With the continue statement, you have the
option of skipping over the portion of a loop where an external
condition is triggered, but continuing on to complete the remainder
of the loop.

2. Amongst which of the following is / are true about the while loop?

A. It continually executes the statements as long as the given


condition is true
B. It first checks the condition and then jumps into the instructions
C. The loop stops running when the condition becomes fail, and
control will move to the next line of code.
D. All of the mentioned above

Answer: D) All of the mentioned above

Explanation:

While loops are used to execute statements repeatedly as long as the


condition is met, they are also used to execute statements once. It
Page 2 of 14
iNeuron Intelligence Pvt Ltd

begins by determining the condition and then proceeds to execute


the instructions.

3. The ___ is a built-in function that returns a range object that


consists series of integer numbers, which we can iterate using a for
loop.

A. range()
B. set()
C. dictionary{}
D. None of the mentioned above

Answer: A) range()

Explanation:

This type represents an immutable sequence of numbers and is


commonly used in for loops to repeat a specific number of times a
given sequence of numbers.

4. What will be the output of the following Python code?

for i in range(6):

print(i)

1
Page 3 of 14
iNeuron Intelligence Pvt Ltd

None of the mentioned above

Answer: A)

Page 4 of 14
iNeuron Intelligence Pvt Ltd

5. The looping reduces the complexity of the problems to the ease of


the problems?

A. True
B. False

Answer: A) True

Explanation:

The looping simplifies the complex problems into the easy ones. It
enables us to alter the flow of the program so that instead of writing
the same code again and again, we can repeat the same code for a
finite number of times.

6. The while loop is intended to be used in situations where we do


not know how many iterations will be required in advance?

A. True
B. False

Answer: A) True

Explanation:

Page 5 of 14
iNeuron Intelligence Pvt Ltd

The while loop is intended to be used in situations where we do not


know how many iterations will be required in advance.

7. Amongst which of the following is / are true with reference to


loops in Python?

A. It allows for code reusability to be achieved.


B. By utilizing loops, we avoid having to write the same code over
and over again.
C. We can traverse through the elements of data structures by
utilizing looping.
D. All of the mentioned above

Answer: D) All of the mentioned above

Explanation:

Following point's shows the importance of loops in Python.

• It allows for code reusability to be achieved.


• By utilizing loops, we avoid having to write the same code over
and over again.
• We can traverse through the elements of data structures by
utilizing looping.

8. A function is a group of related statements which designed


specifically to perform a ___.

A. Write code
B. Specific task

Page 6 of 14
iNeuron Intelligence Pvt Ltd

C. Create executable file


D. None of the mentioned above

Answer: B) Specific task

Explanation:

A function is a group of related statements designed specifically to


perform a specific task. Functions make programming easier to
decompose a large problem into smaller parts. The function allows
programmers to develop an application in a modular way. As our
program grows larger and larger, functions make it more organized
and manageable.

9. Amongst which of the following is a proper syntax to create a


function in Python?

def function_name(parameters):

...

Statements

...

def function function_name:

...

Statements

Page 7 of 14
iNeuron Intelligence Pvt Ltd

...

def function function_name(parameters):

...

Statements

...

None of the mentioned above

Answer: A)

def function_name(parameters):

...

Statements

...

Explanation:

The range(6) is define as function. Loop will print the number from 0.

10. Once we have defined a function, we can call it?

Page 8 of 14
iNeuron Intelligence Pvt Ltd

A. True
B. False

Answer: A) True

Explanation:

Once a function has been defined, it can be called from another


function, a program, or even from the Python prompt itself.

11. Amongst which of the following shows the types of function calls
in Python?

A. Call by value
B. Call by reference
C. Both A and B
D. None of the mentioned above

Answer: C) Both A and B

Explanation:

Call by value and Call by reference are the types of function calls in
Python.

12. What will be the output of the following Python code?

def show(id,name):

print("Your id is :",id,"and your name is :",name)

Page 9 of 14
iNeuron Intelligence Pvt Ltd

show(12,"deepak")

Your id is: 12 and your name is: deepak

Your id is: 11 and your name is: Deepak

Your id is: 13 and your name is: Deepak

None of the mentioned above

Answer: A) Your id is: 12 and your name is: Deepak

13. Amongst which of the following is a function which does not have
any name?

Del function

Show function

Lambda function

None of the mentioned above

Answer: C) Lambda function

14. Can we pass List as an argument in Python function?

A. Yes

Page 10 of 14
iNeuron Intelligence Pvt Ltd

B. No

Answer: A) Yes

Explanation:

In a function, we can pass any data type as an argument, such as a


string or a number or a list or a dictionary, and it will be treated as if
it were of that data type inside the function.

15. A method refers to a function which is part of a class?

A. True
B. False

Answer: A) True

Explanation:

A method is a function that is a part of a class that has been defined.


It is accessed through the use of an instance or object of the class. A
function, on the other hand, is not restricted in this way: it simply
refers to a standalone function.

16. The return statement is used to exit a function?

A. True
B. False

Answer: A) True

Page 11 of 14
iNeuron Intelligence Pvt Ltd

17. Scope and lifetime of a variable declared in a function exist till the
function exists?

A. True
B. False

Answer: A) True

Explanation:

It is the portion of a program where a variable is recognized that is


referred to as its scope. It is not possible to see the parameters and
variables defined within a function from outside of the function. As a
result, they are limited in their application.

18. File handling in Python refers the feature for reading data from
the file and writing data into a file?

A. True
B. False

Answer: A) True

Explanation:

File handling is the capability of reading data from and writing it into
a file in Python. Python includes functions for creating and
manipulating files, whether they are flat files or text documents.

Page 12 of 14
iNeuron Intelligence Pvt Ltd

19. Amongst which of the following is / are the key functions used for
file handling in Python?

A. open() and close()


B. read() and write()
C. append()
D. All of the mentioned above

Answer: D) All of the mentioned above

Explanation:

The key functions used for file handling in Python


are: open(), close(), read(), write(), and append(). the open() function
is used to open an existing file, close() function is used to close a file
which opened, read() function is used when we want to read the
contents from an existing file, write() function is used to write the
contents in a file and append() function is used when we want to
append the text or contents to a specific position in an existing file.

Page 13 of 14
iNeuron Intelligence Pvt Ltd

20. Write a Python program to count vowels in a string.


Ans-

Page 14 of 14
iNeuron Intelligence Pvt Ltd

1. How to Implement the program by creating functions to check


vowel and to count vowels.

Ans-

2. Amongst which of the following function is / are used to create a


file and writing data?

A. append()
B. open()
C. close()
D. None of the mentioned above

Answer: B) open()

Explanation:

Page 2 of 11
iNeuron Intelligence Pvt Ltd

To create a text file, we call the open() method and pass it the
filename and the mode parameters to the function.

3. How to Create multiple copies of a string by using multiplication


operator.

Ans-

4. How to Append text at the end of the string using += Operator?

Page 3 of 11
iNeuron Intelligence Pvt Ltd

Ans-

5. How to Check if a substring presents in a string using 'in' operator?

Ans-

Page 4 of 11
iNeuron Intelligence Pvt Ltd

6. How to assign Hexadecimal values in the string and print it in the


string format?

Ans-

7. How to print double quotes with the string variable?

Page 5 of 11
iNeuron Intelligence Pvt Ltd

8. How to Ignore escape sequences in the string?

Ans-

9.Write a python program to check whether a string contains a


number or not.

Ans- Input:
str1 = "8789"
str2 = "Hello123"
str3 = "123Hello"
str4 = "123 456" #contains space

# function call
str1.isdigit()
str2.isdigit()
str3.isdigit()
str4.isdigit()

Page 6 of 11
iNeuron Intelligence Pvt Ltd

Output:
True
False
False
False

10. What is Factorial of a Number?


Factorial of a number is the product of all positive integers from 1 to
that number. It is denoted by the symbol “!”. For example, factorial of
5 is 5! = 5*4*3*2*1 = 120 and factorial of 8 is 8! = 8 * 7 * 6 * 5 * 4 * 3
* 2 * 1 which equals to 40320.
By default, the factorial of 0 is 1, and the Factorial of a negative
number is not defined.

In mathematics, a factorial is denoted by “!“. Therefore, the factorial


of n is given by the formula
n! = n x (n-1) x (n-2) x (n-3) … x1.

11. How to Search and Sort in Python?

Ans- Searching algorithms are used to locate an element or retrieve it


from a data structure. These algorithms are divided into two
categories based on the type of search operation, namely sequential
search (Linear Search) and interval search (Binary Search). Sorting is
the process of arranging data in a specific format. Sorting algorithms
specify how to sort data in a specific order such as numerical order
(ascending or descending order) or lexical order.

Page 7 of 11
iNeuron Intelligence Pvt Ltd

12. How to Determine if a Number is Prime or Not?


Ans- To check if a number is prime, follow these steps:

1. Begin by taking a number as input from the user.


2. Then, start counting through natural numbers, beginning
at 2.
3. Check whether the input number can be divided evenly by
any of these natural numbers.
4. If the input number is divisible by any of these numbers, it
is not a prime number; otherwise, it is a prime number.
5. Finally, exit the program.

13. How to Sort a list?

Create a function in Python that accepts two parameters. The first


will be a list of numbers. The second parameter will be a string that
can be one of the following values: asc, desc, and none.

If the second parameter is “asc,” then the function should return a


list with the numbers in ascending order. If it’s “desc,” then the list
should be in descending order, and if it’s “none,” it should return the
original list unaltered.

Page 8 of 11
iNeuron Intelligence Pvt Ltd

14. How to Convert a decimal number into binary

Write a function in Python that accepts a decimal number and


returns the equivalent binary number. To make this simple, the
decimal number will always be less than 1,024, so the binary number
returned will always be less than ten digits long.

15. Create a calculator function.

Write a Python function that accepts three parameters. The first


parameter is an integer. The second is one of the following
mathematical operators: +, -, /, or . The third parameter will also be
an integer.

The function should perform a calculation and return the results. For
example, if the function is passed 6 and 4, it should return 24.

Page 9 of 11
iNeuron Intelligence Pvt Ltd

20. How to Extract the mobile number from the given string in
Python?

Ans-

21.How to replace a special string from a given paragraph with


another string in Python?

Ans-

Page 10 of 11
iNeuron Intelligence Pvt Ltd

22. How to find the ASCII value of each character of the string in
Python?

Ans-

Page 11 of 11
iNeuron Intelligence Pvt Ltd

Q1. What are iden.ty operators?


Ans- this is used to verify whether two values are on the same part of
the memory or not. There are two types of iden.ty operators:

a) Is: return true if two operands are iden.cal


b) is not: returns true if two operands are not iden.cal

Q2. What is the difference between a=10 and a==10?

Ans- The expression a=10 assigns the value 10 to variable a, whereas


a==10 checks if the value of is equal to 10 or not. If yes then it
returns ‘True’ else it will return ‘False’.

Q3. What is an expression?


Ans- Logical line of code that we write while programming, are called
expressions. An expression can be broken into operators and
operands . It is therefore said that an expression is a combina.on of
one or more operands and zero or more operators that are together
used to compute a value.

Q4. What are the basic rules of operator precedence in python?

Ans- The basic rule of operator precedence in python is as follows:

1. Expressions must be evaluated from leS to right


2. Expressions of parenthesis are performed first.
3. In python the opera.on procedure follows as per the acronym
PEMDAS:
a) Parenthesis

Page 2 of 9
iNeuron Intelligence Pvt Ltd

b) Exponent
c) Mul.plica.on
d) Division
e) Addi.on
f) Subtrac.on

4. Mathema.cal operators are of higher precedence and the


Boolean operators are of lower precedence. Hence,
mathema.cal opera.ons are performed before Boolean
opera.ons.

Q5. Arrange the following operators from high to low precedence.


a) Assignment
b) Exponent
c) Addi.on and Subtrac.on
d) Rela.onal Operators
e) Equality operators
f) Logical operators
g) Mul.plica.on, division, floor division and modulus

Ans- 1. Exponent
2. Mul.plica.on, division, floor division and modulus
3. Addi.on and Subtrac.on
4. Rela.onal Operators
5. Equality operators
6. Assignment
7. Logical operators

Q6. Is it possible to change the order of evalua.on in an expression.

Page 3 of 9
iNeuron Intelligence Pvt Ltd

Ans- Yes, it is possible to change order of evalua.on of an expression.


Suppose you want to perform addi.on before mul.plica.on in an
expression, then you can simply put the addi.on expression in
parenthesis.

Q7. What is the difference between implicit and explicit expression?


Ans- Conversion is the process of conver.ng one data type into
another. Two types of conversion in Python as follows:

1. Implicit type conversion


2. Explicit type conversion

Q8. What is a statement?


Ans- A complete unit of code that Python interpreter can execute is
called statement.

Q9. What is input statement?


Ans- The input statement is used to get user input from the
keyboard. The syntax for input () func.on is as follows:

Q10. Look at the following code and find the solu.on.

Page 4 of 9
iNeuron Intelligence Pvt Ltd

Ans-

Q11. What is Associa.vity of Python operators? What are non-


associa.ve operators?
Ans- Associa.vity defines the order in which an expression will be
evaluated if it has more than one operator having same precedence.
In such a case generally leS to right associa.vity is followed.

Operators like assignment or comparison operators have no


associa.vity and known as Non associa.ve operators.

Q12. What are control statements?


Ans- They are used to control the follow of program execu.on. They
help in deciding the next steps under specific condi.ons also allow
repe..ons of program for certain number of .mes.

Two types of control statements are as follows:


1. Condi.onal branching
• If

Page 5 of 9
iNeuron Intelligence Pvt Ltd

• If…. else

• Nested if statements

2.Loops
While: repeat a block of statements as long as a given condi.on is
true

For: repeat a block of statements for certain number of .mes.

Q13. Write a code to print the star pahern.

Page 6 of 9
iNeuron Intelligence Pvt Ltd

Ans-

Q14. Write code to produce the following pahern:


1
22
333
4444
Ans-

Q15. Write a code to generate the following pahern.


1

Page 7 of 9
iNeuron Intelligence Pvt Ltd

12
123
1234
Ans-

Q16. Write code to spell a word entered by the user.


Ans-

Q17. What are the statements to control a loop?


Ans – The following three statements can be used to control as loop:
a) break: breaks the execu.on of the loop and jumps to next
statement aSer the loop.

Page 8 of 9
iNeuron Intelligence Pvt Ltd

b) Con.nue: takes the control back to the top of the loop without
execu.ng the remaining statements.

c) pass: does nothing

Q18. What is the meaning of condi.onal branching?


Ans- Deciding whether certain sets of instruc.ons must be executed
or not based on the value of an expression is called condi.onal
branching.

Q19. What is the difference between the con.nue and pass


statement?
Ans- Pass does nothing whereas con.nue starts the next itera.ons of
the loop.

Q20. What is Self-used for in Python?

Ans- It is used to represent the instance of the class. This is because


in Python, the ‘@’ syntax is not used to refer to the instance
ahributes.

Page 9 of 9
iNeuron Intelligence Pvt Ltd

Q1. What are Decorators in Python?

Ans- Decorator is a very useful tool in Python that is used by


programmers to alter the changes in the behaviour of classes and
func?ons.

Q2. What is a Python PATH?

Ans- This is an environment variable used to import a variable and


check for the presence of variables present in different directories.

Q3. Create a module in Python.

Ans- Crea?ng a module in Python is fairly simple. First, open a text


editor and create a new file. Add the code you want to include in the
module. You can include various func?ons and classes, as well as
global variables.
Save the file with a .py extension (e.g. myModule.py).
Import the module using the import statement.
Use the module's func?ons and classes in your program.
Q4. How memory can be managed in Python?

Ans- In Python, the memory is managed using the Python Memory


Manager. The manager allocates memory in the form of a private
heap space dedicated to Python. All objects are now stored in this
Hype and due to its private feature, it is restricted from the
programmer.

Page 2 of 9
iNeuron Intelligence Pvt Ltd

Q5. What do you mean by Python literals?

A literal is a simple and direct form of expressing a value. Literals


reflect the primi?ve type op?ons available in that language. Integers,
floa?ng-point numbers, Booleans, and character strings are some of
the most common forms of literal. Python supports the following
literals:

Literals in Python relate to the data that is kept in a variable or


constant. There are several types of literals present in Python

String Literals: It’s a sequence of characters wrapped in a set of


codes. Depending on the number of quota?ons used, there can be
single, double, or triple strings. Single characters enclosed by single
or double quota?ons are known as character literals.

Numeric Literals: These are unchangeable numbers that may be


divided into three types: integer, float, and complex.

Boolean Literals: True or False, which signify ‘1’ and ‘0,’ respec?vely,
can be assigned to them.

Special Literals: It’s used to categorize fields that have not been
generated. ‘None’ is the value that is used to represent it.

• String literals: “halo” , ‘12345’


• Int literals: 0,1,2,-1,-2
• Long literals: 89675L
• Float literals: 3.14
• Complex literals: 12j
• Boolean literals: True or False
• Special literals: None
Page 3 of 9
iNeuron Intelligence Pvt Ltd

• Unicode literals: u”hello”


• List literals: [], [5, 6, 7]
• Tuple literals: (), (9,), (8, 9, 0)
• Dict literals: {}, {‘x’:1}
• Set literals: {8, 9, 10}

Q6. What is pep 8?


PEP 8, olen known as PEP8 or PEP-8, is a document that outlines
best prac?ces and recommenda?ons for wri?ng Python code. It was
wrimen in 2001 by Guido van Rossum, Barry Warsaw, and Nick
Coghlan. The main goal of PEP 8 is to make Python code more
readable and consistent.

Python Enhancement Proposal (PEP) is an acronym for Python


Enhancement Proposal, and there are numerous of them. A Python
Enhancement Proposal (PEP) is a document that explains new
features suggested for Python and details elements of Python for the
community, such as design and style.

Q7. What are global, protected, and private amributes in Python?

The amributes of a class are also called variables. There are three
access modifiers in Python for variables, namely

a. public – The variables declared as public are accessible


everywhere, inside or outside the class.

b. private – The variables declared as private are accessible only


within the current class.

c. protected – The variables declared as protected are accessible only


within the current package.
Page 4 of 9
iNeuron Intelligence Pvt Ltd

Amributes are also classified as:

– Local a2ributes are defined within a code-block/method and can


be accessed only within that code-block/method.

– Global a2ributes are defined outside the code-block/method and


can be accessible everywhere.

Q8. What are Keywords in Python?

Keywords in Python are reserved words that are used as iden?fiers,


func?on names, or variable names. They help define the structure
and syntax of the language.

Q9. How can you concatenate two tuples?

Let’s say we have two tuples like this ->

tup1 = (1, ”a”, True)

tup2 = (4,5,6)

Concatena?on of tuples means that we are adding the elements of


one tuple at the end of another tuple.

Q10. What are func?ons in Python?

Page 5 of 9
iNeuron Intelligence Pvt Ltd

Ans: Func?ons in Python refer to blocks that have organized, and


reusable codes to perform single, and related events. Func?ons are
important to create bemer modularity for applica?ons that reuse a
high degree of coding. Python has a number of built-in func?ons like
print(). However, it also allows you to create user-defined func?ons.

Q11. What are Pandas?

Pandas is an open-source python library that has a very rich set of


data structures for data-based opera?ons. Pandas with their cool
features fit in every role of data opera?on, whether it be academics
or solving complex business problems. Pandas can deal with a large
variety of files and are one of the most important tools to have a grip
on.

Q12. How can you randomize the items of a list in place in Python?

Ans-

Q13. How can you generate random numbers in Python?

Page 6 of 9
iNeuron Intelligence Pvt Ltd

Ans: Random module is the standard module that is used to generate


a random number. The method is defined as:

The statement random.random() method return the floa?ng-point


number that is in the range of [0, 1). The func?on generates random
float numbers. The methods that are used with the random class are
the bound methods of the hidden instances. The instances of the
Random can be done to show the mul?-threading programs that
creates a different instance of individual threads. The other random
generators that are used in this are:

1. randrange (a, b): it chooses an integer and define the range in-
between [a, b). It returns the elements by selec?ng it randomly
from the range that is specified. It doesn’t build a range object.
2. Uniform (a, b): it chooses a floa?ng point number that is defined
in the range of [a,b). Iyt returns the floa?ng point number
3. Normalvariate (mean, sdev): it is used for the normal distribu?on
where the mu is a mean and the sdev is a sigma that is used for
standard devia?on.
4. The Random class that is used and instan?ated creates
independent mul?ple random number generators.

Q14. What is the difference between range & xrange?

Ans: For the most part, xrange and range are the exact same in terms
of func?onality. They both provide a way to generate a list of integers
for you to use, however you please. The only difference is that range
returns a Python list object and x range returns an xrange object.

This means that xrange doesn’t actually generate a sta?c list at run-
?me like range does. It creates the values as you need them with a
Page 7 of 9
iNeuron Intelligence Pvt Ltd

special technique called yielding. This technique is used with a type of


object known as generators. That means that if you have a really
gigan?c range, you’d like to generate a list for, say one billion, xrange
is the func?on to use.

Q15. What is pickling and unpickling?

Ans: Pickle module accepts any Python object and converts it into a
string representa?on and dumps it into a file by using dump func?on,
this process is called pickling. While the process of retrieving original
Python objects from the stored string representa?on is called
unpickling.

Q16. What are the generators in python?

Ans: Func?ons that return an iterable set of items are called


generators.

Q17. How will you capitalize the first lemer of string?

Ans: In Python, the capitalize () method capitalizes the first lemer of a


string. If the string already consists of a capital lemer at the beginning,
then, it returns the original string.

Q18. How will you convert a string to all lowercase?

Ans: To convert a string to lowercase, lower () func?on can be used.

Q19. How to comment mul?ple lines in python?

Ans: Mul?-line comments appear in more than one line. All the lines
to be commented are to be prefixed by a #. You can also a very

Page 8 of 9
iNeuron Intelligence Pvt Ltd

good shortcut method to comment mul?ple lines. All you need to do


is hold the ctrl key and lel click in every place wherever you want to
include a # character and type a # just once. This will comment all the
lines where you introduced your cursor.

Q20. What is the purpose of ‘is’, ‘not’ and ‘in’ operators?

Ans: Operators are special func?ons. They take one or more values
and produce a corresponding result.

is: returns true when 2 operands are true (Example: “a” is ‘a’)

not: returns the inverse of the Boolean value

in: checks if some element is present in some sequence

Page 9 of 9
iNeuron Intelligence Pvt Ltd

Q1. What is the usage of help () and dir () func8on in Python?

Ans: Help() and dir() both func8ons are accessible from the Python
interpreter and used for viewing a consolidated dump of built-in
func8ons.

Q2. Whenever Python exits, why isn’t all the memory de-allocated?

Ans:

1. Whenever Python exits, especially those Python modules which


are having circular references to other objects or the objects that
are referenced from the global namespaces are not always de-
allocated or freed.
2. It is impossible to de-allocate those por8ons of memory that are
reserved by the C library.
3. On exit, because of having its own efficient clean up mechanism,
Python would try to de-allocate/destroy every other object.

Q3. What does this mean: *args, **kwargs? And why would we use it?

Ans: We use *args when we aren’t sure how many arguments are
going to be passed to a func8on, or if we want to pass a stored list or
tuple of arguments to a func8on. **kwargs is used when we don’t
know how many keyword arguments will be passed to a func8on, or it
can be used to pass the values of a dic8onary as keyword arguments.
The iden8fiers args and kwargs are a conven8on, you could also use
*bob and **billy but that would not be wise.

Page 2 of 9
iNeuron Intelligence Pvt Ltd

Q4. Explain split(), sub(), subn() methods of “re” module in Python.

Ans: To modify the strings, Python’s “re” module is providing 3


methods. They are:

• split() – uses a regex paXern to “split” a given string into a list.


• sub() – finds all substrings where the regex paXern matches and
then replace them with a different string
• subn() – it is similar to sub() and also returns the new string along
with the no. of replacements.

Q5. What are nega8ve indexes and why are they used?

Ans: The sequences in Python are indexed and it consists of the


posi8ve as well as nega8ve numbers. The numbers that are posi8ve
uses ‘0’ that is uses as first index and ‘1’ as the second index and the
process goes on like that.

The index for the nega8ve number starts from ‘-1’ that represents the
last index in the sequence and ‘-2’ as the penul8mate index and the
sequence carries forward like the posi8ve number.

The nega8ve index is used to remove any new-line spaces from the
string and allow the string to except the last character that is given as
S[:-1]. The nega8ve index is also used to show the index to represent
the string in correct order.

Q6. What are Python packages?

Ans: Python packages are namespaces containing mul8ple modules.

Page 3 of 9
iNeuron Intelligence Pvt Ltd

Q7.How can files be deleted in Python?

Ans: To delete a file in Python, you need to import the OS Module.


Ader that, you need to use the os. remove() func8on.

Q8. What advantages do NumPy arrays offer over (nested) Python


lists?

Ans:

1. Python’s lists are efficient general-purpose containers. They


support (fairly) efficient inser8on, dele8on, appending, and
concatena8on, and Python’s list comprehensions make them
easy to construct and manipulate.
2. They have certain limita8ons: they don’t support “vectorized”
opera8ons like elementwise addi8on and mul8plica8on, and the
fact that they can contain objects of differing types mean that
Python must store type informa8on for every element, and must
execute type dispatching code when opera8ng on each element.
3. NumPy is not just more efficient; it is also more convenient. You
get a lot of vector and matrix opera8ons for free, which
some8mes allow one to avoid unnecessary work. And they are
also efficiently implemented.
4. NumPy array is faster and You get a lot built in with NumPy, FFTs,
convolu8ons, fast searching, basic sta8s8cs, linear
algebra, histograms, etc.

Page 4 of 9
iNeuron Intelligence Pvt Ltd

Q9. How to remove values to a python array?

Ans: Array elements can be removed


using pop() or remove() method. The difference between these
two func8ons is that the former returns the deleted value
whereas the laXer does not.

Q10. Does Python have OOps concepts?

Ans: Python is an object-oriented programming language. This means


that any program can be solved in python by crea8ng an object
model. However, Python can be treated as a procedural as well as
structural language.

Q11. What is the difference between deep and shallow copy?

Ans: Shallow copy is used when a new instance type gets created and
it keeps the values that are copied in the new instance. Shallow copy
is used to copy the reference pointers just like it copies the values.
These references point to the original objects and the changes made
in any member of the class will also affect the original copy of
it. Shallow copy allows faster execu8on of the program and it depends
on the size of the data that is used.

Deep copy is used to store the values that are already copied. Deep
copy doesn’t copy the reference pointers to the objects. It makes the
reference to an object and the new object that is pointed by some
other object gets stored. The changes made in the original copy won’t
Page 5 of 9
iNeuron Intelligence Pvt Ltd

affect any other copy that uses the object. Deep copy makes execu8on
of the program slower due to making certain copies for each object
that is been called.

Q12. How is Mul8threading achieved in Python?

Ans:

1. Python has a mul8-threading package but if you want to mul8-


thread to speed your code up, then it’s usually not a good idea
to use it.
2. Python has a construct called the Global Interpreter Lock (GIL).
The GIL makes sure that only one of your ‘threads’ can execute
at any one 8me. A thread acquires the GIL, does a liXle work,
then passes the GIL onto the next thread.
3. This happens very quickly so to the human eye it may seem like
your threads are execu8ng in parallel, but they are really just
taking turns using the same CPU core.
4. All this GIL passing adds overhead to execu8on. This means that
if you want to make your code run faster then using the
threading package oden isn’t a good idea.

Q13. What is the process of compila8on and linking in python?

Ans: The compiling and linking allow the new extensions to be


compiled properly without any error and the linking can be done only
when it passes the compiled procedure. If the dynamic loading is used
then it depends on the style that is being provided with the system.
The python interpreter can be used to provide the dynamic loading of
the configura8on setup files and will rebuild the interpreter.

Page 6 of 9
iNeuron Intelligence Pvt Ltd

The steps that are required in this as:

1. Create a file with any name and in any language that is supported
by the compiler of your system. For example file.c or file.cpp
2. Place this file in the Modules/ directory of the distribu8on which
is gepng used.
3. Add a line in the file Setup. Local that is present in the Modules/
directory.
4. Run the file using spam file.o
5. Ader a successful run of this rebuild the interpreter by using the
make command on the top-level directory.
6. If the file is changed then run rebuildMakefile by using the
command as ‘make Makefile’.

Q14. What are Python libraries? Name a few of them.

Ans- Python libraries are a collec8on of Python packages. Some of the


majorly used python libraries are – Numpy, Pandas, Matplotlib, Scikit-
learn and many more.

Q15. What is split used for?

Ans- The split() method is used to separate a given String in Python.

Q16. What is the usage of help () and dir () func8on in Python?

Ans: Help() and dir() both func8ons are accessible from the Python
interpreter and used for viewing a consolidated dump of built-in
func8ons.
Page 7 of 9
iNeuron Intelligence Pvt Ltd

Q17. Whenever Python exits, why isn’t all the memory de-allocated?

Ans:

4. Whenever Python exits, especially those Python modules which


are having circular references to other objects or the objects that
are referenced from the global namespaces are not always de-
allocated or freed.
5. It is impossible to de-allocate those por8ons of memory that are
reserved by the C library.
6. On exit, because of having its own efficient clean up mechanism,
Python would try to de-allocate/destroy every other object.

Q18. What does this mean: *args, **kwargs? And why would we use
it?

Ans: We use *args when we aren’t sure how many arguments are
going to be passed to a func8on, or if we want to pass a stored list or
tuple of arguments to a func8on. **kwargs is used when we don’t
know how many keyword arguments will be passed to a func8on, or it
can be used to pass the values of a dic8onary as keyword arguments.
The iden8fiers args and kwargs are a conven8on, you could also use
*bob and **billy but that would not be wise.

Q19. Explain split(), sub(), subn() methods of “re” module in Python.

Ans: To modify the strings, Python’s “re” module is providing 3


methods. They are:
Page 8 of 9
iNeuron Intelligence Pvt Ltd

• split() – uses a regex paXern to “split” a given string into a list.


• sub() – finds all substrings where the regex paXern matches and
then replace them with a different string
• subn() – it is similar to sub() and also returns the new string along
with the no. of replacements.

Q20. What are nega8ve indexes and why are they used?

Ans: The sequences in Python are indexed and it consists of the


posi8ve as well as nega8ve numbers. The numbers that are posi8ve
uses ‘0’ that is uses as first index and ‘1’ as the second index and the
process goes on like that.

The index for the nega8ve number starts from ‘-1’ that represents the
last index in the sequence and ‘-2’ as the penul8mate index and the
sequence carries forward like the posi8ve number.

The nega8ve index is used to remove any new-line spaces from the
string and allow the string to except the last character that is given as
S[:-1]. The nega8ve index is also used to show the index to represent
the string in correct order.

Page 9 of 9
iNeuron Intelligence Pvt Ltd

Q1. What are Python packages?

Ans: Python packages are namespaces containing mul;ple modules.

Q2.How can files be deleted in Python?

Ans: To delete a file in Python, you need to import the OS Module.


AGer that, you need to use the os. remove() func;on.

Q3. What advantages do NumPy arrays offer over (nested) Python


lists?

Ans:

1. Python’s lists are efficient general-purpose containers. They


support (fairly) efficient inser;on, dele;on, appending, and
concatena;on, and Python’s list comprehensions make them
easy to construct and manipulate.
2. They have certain limita;ons: they don’t support “vectorized”
opera;ons like elementwise addi;on and mul;plica;on, and the
fact that they can contain objects of differing types mean that
Python must store type informa;on for every element, and must
execute type dispatching code when opera;ng on each element.
3. NumPy is not just more efficient; it is also more convenient. You
get a lot of vector and matrix opera;ons for free, which
some;mes allow one to avoid unnecessary work. And they are
also efficiently implemented.

Page 2 of 10
iNeuron Intelligence Pvt Ltd

4. NumPy array is faster and You get a lot built in with NumPy, FFTs,
convolu;ons, fast searching, basic sta;s;cs, linear
algebra, histograms, etc.

Q53. How to remove values to a python array?

Ans: Array elements can be removed


using pop() or remove() method. The difference between these
two func;ons is that the former returns the deleted value
whereas the la\er does not.

Q4. Does Python have OOps concepts?

Ans: Python is an object-oriented programming language. This means


that any program can be solved in python by crea;ng an object
model. However, Python can be treated as a procedural as well as
structural language.

Q5. What is the difference between deep and shallow copy?

Ans: Shallow copy is used when a new instance type gets created and
it keeps the values that are copied in the new instance. Shallow copy
is used to copy the reference pointers just like it copies the values.
These references point to the original objects and the changes made

Page 3 of 10
iNeuron Intelligence Pvt Ltd

in any member of the class will also affect the original copy of
it. Shallow copy allows faster execu;on of the program and it depends
on the size of the data that is used.

Deep copy is used to store the values that are already copied. Deep
copy doesn’t copy the reference pointers to the objects. It makes the
reference to an object and the new object that is pointed by some
other object gets stored. The changes made in the original copy won’t
affect any other copy that uses the object. Deep copy makes execu;on
of the program slower due to making certain copies for each object
that is been called.

Q6. How is Mul;threading achieved in Python?

Ans:

1. Python has a mul;-threading package but if you want to mul;-


thread to speed your code up, then it’s usually not a good idea
to use it.
2. Python has a construct called the Global Interpreter Lock (GIL).
The GIL makes sure that only one of your ‘threads’ can execute
at any one ;me. A thread acquires the GIL, does a li\le work,
then passes the GIL onto the next thread.
3. This happens very quickly so to the human eye it may seem like
your threads are execu;ng in parallel, but they are really just
taking turns using the same CPU core.
4. All this GIL passing adds overhead to execu;on. This means that
if you want to make your code run faster then using the
threading package oGen isn’t a good idea.

Page 4 of 10
iNeuron Intelligence Pvt Ltd

Q7. What is the process of compila;on and linking in python?

Ans: The compiling and linking allow the new extensions to be


compiled properly without any error and the linking can be done only
when it passes the compiled procedure. If the dynamic loading is used
then it depends on the style that is being provided with the system.
The python interpreter can be used to provide the dynamic loading of
the configura;on setup files and will rebuild the interpreter.

The steps that are required in this as:

1. Create a file with any name and in any language that is supported
by the compiler of your system. For example file.c or file.cpp
2. Place this file in the Modules/ directory of the distribu;on which
is gehng used.
3. Add a line in the file Setup. Local that is present in the Modules/
directory.
4. Run the file using spam file.o
5. AGer a successful run of this rebuild the interpreter by using the
make command on the top-level directory.
6. If the file is changed then run rebuildMakefile by using the
command as ‘make Makefile’.

Q8. What are Python libraries? Name a few of them.

Ans- Python libraries are a collec;on of Python packages. Some of the


majorly used python libraries are – Numpy, Pandas, Matplotlib, Scikit-
learn and many more.

Page 5 of 10
iNeuron Intelligence Pvt Ltd

Q9. What is split used for?

Ans- The split() method is used to separate a given String in Python.

Q10. What is the difference between range & xrange?

Func;ons in Python, range() and xrange(), are used to iterate inside a


for loop for a fixed number of ;mes. Func;onality-wise, both these
func;ons are the same. The difference comes when talking
about the Python version support for these func;ons and their return
values.

Q11. What is pickling and unpickling?

The Pickle module accepts the Python object and converts it into a
string representa;on and stores it into a file by using the dump
func;on. This process is called pickling. On the other hand, the process
of retrieving the original Python objects from the string representa;on
is called unpickling.

Q12. What do you understand by the word Tkinter?

Ans- Tkinter is a built-in Python module that is used to create GUI


applica;ons and it is Python’s standard toolkit for GUI development.

Page 6 of 10
iNeuron Intelligence Pvt Ltd

Tkinter comes pre-loaded with Python so there is no separate


installa;on needed. You can start using it by impor;ng it in your script.

Q13. Is Python fully object oriented?

Python does follow an object-oriented programming paradigm and


has all the basic OOPs concepts such as inheritance, polymorphism,
and more, with the excep;on of access specifiers. Python doesn’t
support strong encapsula;on (adding a private keyword before data
members). Although, it has a conven;on that can be used for data
hiding, i.e., prefixing a data member with two underscores.

Q14. What do file-related modules in Python do? Can you name


some file-related modules in Python?

Python comes with some file-related modules that have func;ons to


manipulate text files and binary files in a file system. These modules
can be used to create text or binary files, update content by carrying
out opera;ons like copy, delete, and more.

Some file-related modules are os, os.path, and shu;l.os. The os.path
module has func;ons to access the file system, while the shu;l.os
module can be used to copy or delete files.

Page 7 of 10
iNeuron Intelligence Pvt Ltd

Q15. Explain the use of the 'with' statement and its syntax?

In Python, using the ‘with’ statement, we can open a file and close it
as soon as the block of code, where ‘with’ is used, exits. In this way,
we can opt for not using the close() method.

Q16. What does *args and **kwargs mean in Python?

Ans- *args: It is used to pass mul;ple arguments in a func;on.

**kwargs: It is used to pass mul;ple keyworded arguments in a


func;on in Python.

Q17. How will you remove duplicate elements from a list?

To remove duplicate elements from the list we use the set() func;on.

Consider the below example:

demo_list = [5, 4, 4, 6, 8, 12, 12, 1, 5]

unique_list = list(set(demo_list))

output = [1, 5, 6, 8, 12]


Page 8 of 10
iNeuron Intelligence Pvt Ltd

Q18. How can files be deleted in Python?

Ans- You need to import the OS Module and use os.remove()


func;on for dele;ng a file in python.

consider the code below:

import os

os.remove("file_name.txt")

Q19. How will you read a random line in a file?

We can read a random line in a file using the random module.

For example:

import random

def read_random(fname):

lines = open(fname).read().splitlines()

return random.choice(lines)

print(read_random('hello.txt'))

Page 9 of 10
iNeuron Intelligence Pvt Ltd

Q20. Write a Python program to count the total number of lines in a


text file?

Refer the code below to count the total number of lines in a text file-

def file_count(fname):

with open(fname) as f:

for i, _ in enumerate(f):

pass

return i + 1

print("Total number of lines in the text file:",

file_count("file.txt"))

Page 10 of 10
iNeuron Intelligence Pvt Ltd

Q1. What is the purpose of “is”, “not” and “in” operators?

Operators are referred to as special func:ons that take one or more


values (operands) and produce a corresponding result.

• is: returns the true value when both the operands are
true (Example: “x” is ‘x’)
• not: returns the inverse of the boolean value based upon
the operands (example:”1” returns “0” and vice-versa.

In: helps to check if the element is present in a given Sequence or not.

Q2. Whenever Python exits, why isn’t all the memory de-allocated?

• Whenever Python exits, especially those Python modules


which are having circular references to other objects or the
objects that are referenced from the global namespaces, the
memory is not always de-allocated or freed.
• It is not possible to de-allocate those por:ons of memory
that are reserved by the C library.
• On exit, because of having its own efficient clean up
mechanism, Python will try to de-allocate every object.

Q3. How to remove values to a python array?

Elements can be removed from a python array by using pop() or


remove() methods.

Page 2 of 13
iNeuron Intelligence Pvt Ltd

pop(): This func:on will return the removed element .

remove():It will not return the removed element.

Consider the below example :

x=arr.array('d', [8.1, 2.4, 6.8, 1.1, 7.7, 1.2, 3.6])

print(x.pop())

print(x.pop(3))

x.remove(8.1)

print(x)

Q4. Why would you use NumPy arrays instead of lists in Python?

NumPy arrays provide users with three main advantages as shown


below:

• NumPy arrays consume a lot less memory, thereby making


the code more efficient.

Page 3 of 13
iNeuron Intelligence Pvt Ltd

• NumPy arrays execute faster and do not add heavy


processing to the run:me.
• NumPy has a highly readable syntax, making it easy and
convenient for programmers.

Q5. What is polymorphism in Python?

Polymorphism is the ability of the code to take mul:ple forms. Let’s


say, if the parent class has a method named XYZ then the child class
can also have a method with the same name XYZ having its own
variables and parameters.

Q6. Define encapsula:on in Python?

Encapsula:on in Python refers to the process of wrapping up the


variables and different func:ons into a single en:ty or
capsule. The Python class is the best example of encapsula:on in
python.

Q7. What advantages do NumPy arrays offer over (nested) Python


lists?

Nested Lists:

• Python lists are efficient, general-purpose containers that


support efficient opera:ons like
inser:on, appending, dele:on and concatena:on.
Page 4 of 13
iNeuron Intelligence Pvt Ltd

• The limita:ons of lists are that they don’t support


“vectorized” opera:ons like element wise addi:on and
mul:plica:on, and the fact that they can contain objects of
differing types means that Python must store the data type
informa:on for every element, and must execute type
dispatching code when opera:ng on each element.

Numpy:

• NumPy is more efficient and more convenient as you get a


lot of vector and matrix opera:ons for free, this helps avoid
unnecessary work and complexity of the code. NumPy is
also efficiently implemented when compared to nested lists.
• NumPy array is faster and contains a lot of built-in func:ons
which will help in FFTs, convolu:ons, fast searching, linear
algebra, basic sta:s:cs, histograms, etc.

Q8. What is the lambda func:on in Python?

A lambda func:on is an anonymous func:on (a func:on that does


not have a name) in Python. To define anonymous func:ons, we use
the ‘lambda’ keyword instead of the ‘def’ keyword, hence the name
‘lambda func:on’. Lambda func:ons can have any number of
arguments but only one statement.

For example:
Page 5 of 13
iNeuron Intelligence Pvt Ltd

l = lambda (x,y) : x*y

print(a(5, 6))

Q9. What is the difference between append() and extend() methods?

Both append() and extend() methods are methods used to add


elements at the end of a list.

The primary differen:a:on between the append() and extend()


methods in Python is that append() is used to add a single element to
the end of a list. In contrast, open () is used to append mul:ple aspects,
such as another list or an iterable, to the end of a list.

Q10. How does Python Flask handle database requests?

Ans- Flask supports a database-powered applica:on (RDBS). Such a


system requires crea:ng a schema, which needs piping the schema.
SQL file into the sqlite3 command. Python developers need to install
the sqlite3 command to create or ini:ate the database in Flask.

Flask allows to request for a database in three ways:

• before_request(): They are called before a request and pass


no arguments.
Page 6 of 13
iNeuron Intelligence Pvt Ltd

• aoer_request(): They are called aoer a request and pass the


response that will be sent to the client.
• teardown_request(): They are called in a situa:on when an
excep:on is raised and responses are not guaranteed. They
are called aoer the response has been constructed. They are
not allowed to modify the request, and their values are
ignored.

Q11. How is mul:-threading achieved in Python?

Ans- Python has a mul:-threading package but commonly not


considered a good prac:ce to use it as it results in increased code
execu:on :me.

• Python has a constructor called the Global Interpreter Lock


(GIL). The GIL ensures that only one of your ‘threads’ can
execute at one :me. The process makes sure that a thread
acquires the GIL, does work, then passes the GIL onto the
next thread.
• This occurs almost instantaneously, giving the illusion of
parallel execu:on to the human observer. However, the
threads execute sequen:ally, taking turns u:lizing the same
CPU core.

Page 7 of 13
iNeuron Intelligence Pvt Ltd

Q12. What is slicing in Python?

Ans- Slicing is a technique employed to extract a specific range of


elements from sequen:al data types, such as lists, strings, and tuples.
Slicing is beneficial and easy to extract out elements. It requires a :
(colon) which separates the start index and end index of the field. All
the data sequence types, list or tuple, allows users to use slicing to get
the needed elements. Although we can get elements by specifying an
index, we get only a single element. Whereas, using slicing, we can get
a group or appropriate range of needed elements.

Q13. What is func:onal programming? Does Python follow a


func:onal programming style? If yes, list a few methods to
implement func:onally oriented programming in Python.

Func:onal programming is a coding style where the main source of


logic in a program comes from func:ons.

Incorpora:ng func:onal programming in our codes means wri:ng


pure func:ons.

Pure func:ons are func:ons that cause lirle or no changes outside the
scope of the func:on. These changes are referred to as side effects. To
reduce side effects, pure func:ons are used, which makes the code
easy-to-follow, test, or debug.

Page 8 of 13
iNeuron Intelligence Pvt Ltd

Q14. What is monkey patching in Python?

Ans - Monkey patching is the term used to denote modifica:ons that


are done to a class or a module during run:me. This can only be
done as Python supports changes in the behaviour of the program
while being executed.

The following is an example, deno:ng monkey patching in Python:

# monkeyy.py

class X:

def func(self):

print("func() is being called")

Q15. What is pandas?

Pandas is an open source python library which supports data


structures for data based opera:ons associated with data analyzing
and data manipula:on . Pandas, with its rich sets of features, fits in
every role of data opera:on, whether it be related to implemen:ng
Page 9 of 13
iNeuron Intelligence Pvt Ltd

different algorithms or for solving complex business problems. Pandas


helps to deal with a number of files in performing certain opera:ons
on the data stored by files.

Q16. What are dataframes?

Ans- A dataframes refers to a two dimensional mutable data structure


or data aligned in the tabular form with labelled axes(rows and
column).

Syntax:

pandas.DataFrame( data, index, columns, dtype)

data: It refers to various forms like ndarray, series, map, lists, dict,
constants and can take other DataFrame as Input.

index: This argument is op:onal as the index for row labels will be
automa:cally taken care of by pandas library.

columns: This argument is op:onal as the index for column labels will
be automa:cally taken care of by pandas library.

Dtype: refers to the data type of each column.

Page 10 of 13
iNeuron Intelligence Pvt Ltd

Q17. What is regression?

Regression is termed as a supervised machine learning algorithm


technique which is used to find the correla:on between variables. It
helps predict the value of the dependent variable(y) based upon the
independent variable (x). It is mainly used for predic:on, :me series
modelling , forecas:ng, and determining the causal-effect
rela:onship between variables.

Scikit library is used in python to implement the regression and all


machine learning algorithms.

There are two different types of regression algorithms in machine


learning :

Linear Regression: Used when the variables are con:nuous and


numeric in nature.

Logis:c Regression: Used when the variables are con:nuous and


categorical in nature.

Page 11 of 13
iNeuron Intelligence Pvt Ltd

Q18. Write a program in Python to check if a number is prime?

Ans-

Q19. Write a Program to print ASCII Value of a character in python?

Ans-

Q20. Write a sor:ng algorithm for a numerical dataset in Python.

Ans- my_list = ["8", "4", "3", "6", "2"]

my_list = [int(i) for i in list]

Page 12 of 13
iNeuron Intelligence Pvt Ltd

my_list.sort()

print (my_list)

Page 13 of 13
iNeuron Intelligence Pvt Ltd

Q1. What are the different types of func6on in Python?


Ans- a) Built-in func6on
b) User defined func6on

Q2. Why are func6ons required?


Ans- Many 6mes in a program a certain set of instruc6ons may be
called again and again. Instead of wri6ng same piece of code
whether it is required it is beHer to define a func6on and place the
code in it. This func6on can be called whenever there is ned. This
save 6me effort and program can be developed easily. Func6ons help
in organizing coding work and tes6ng of code also becomes easy.

Q3. What is a func6on header?


Ans- First line of func6on defini6on that starts with def and ends
with a colon(:) is called a func6on header.

Q4. When does a func6on execute?


Ans- A func6on executes when a call is made to it. It can be called
directly from Python prompt or from another func6on.

Q5. What is a parameter? What is the difference between a


parameter and argument?
Ans- A parameter is a variable that is defined in a func6on defini6on
whereas an argument is an actual value that is passed on to the
func6on. The data carried in the argument is passed on to the
parameters.

Q6. Why do we use the Python startup environment variable?

Page 2 of 5
iNeuron Intelligence Pvt Ltd

Ans- The variable consists of the path in which the ini6aliza6on file
carrying the Python source code can be executed. This is needed to
start the interpreter.

Q7. What is the Pythoncaseok environment variable?


Ans- The Pythoncaseok environment variable is applied in Windows
with the purpose of direc6ng Python to find the first case-insensi6ve
match in an import statement.

Q8. What are posi6ve and nega6ve indices?


Ans- Posi6ve indices are applied when the search begins from leW to
right. In nega6ve indices, the search begins from right to leW. For
example, in the array list of size n the posi6ve index, the first index is
0, then comes 1, and un6l the last index is n-1. However, in the
nega6ve index, the first index is -n, then -(n-1) un6l the last index -1.

Q9. What is the permiHed length of the iden6fier?


Ans- The length of the iden6fier in Python can be of any length. The
longest iden6fier will be from PEP – 8 and PEP – 20.

Q10. What does the method object() do?


Ans- The method returns a featureless object that is the base for all
classes. This method does not take any parameters.

Q11. What is pep 8?


Ans- Python Enhancement Proposal, or pep 8, is a set of rules that
specify how to format Python code for maximum readability.

Q12. What is namespace in Python?


Ans- A namespace is a naming system used to make sure names are
unique to avoid naming conflicts.

Page 3 of 5
iNeuron Intelligence Pvt Ltd

Q13. Is indenta6on necessary in Python?


Ans- Indenta6on is required in Python. If not done properly, the code
is not executed properly and might throw errors. Indenta6on is
usually done using four space characters.

Q14. Define self in Python.


Ans- Self is an instance of a class or an object in Python. It is included
as the first parameter. It helps differen6ate between the methods
and aHributes of a class with local variables.

Q15. What is the Pass statement?


Ans- A Pass statement in Python is used when we cannot decide
what to do in our code, but we must type something to make it
syntac6cally correct.

Q16. What are the limita6ons of Python?


Ans- There are limita6ons to Python, which include the following:

It has design restric6ons.


It is slower when compared with C and C++ or Java.
It is inefficient for mobile compu6ng.
It consists of an underdeveloped database access layer

Q17. Why do we need a con6nue?


Ans- A con6nue helps control the Python loop by making jumps to
the next itera6on of the loop without exhaus6ng it.

Q18. Can we use a break and con6nue together in Python? How?

Page 4 of 5
iNeuron Intelligence Pvt Ltd

Ans- Break and con6nue can be used together in Python. The break
will stop the current loop from execu6on, while the jump will take it
to another loop.

Q19. Does Python support an intrinsic do-while loop?


Ans- No, Python does not support an intrinsic do-while loop.

Q20. What are rela6onal operators, assignment operators, and


membership operators?
Ans- The purpose of rela6onal operators is to compare values.
The assignment operators in Python can help in combining all the
arithme6c operators with the assignment symbol.
Membership operators in Python with the purpose of valida6ng the
membership of a value in a sequence.

Page 5 of 5
iNeuron Intelligence Pvt Ltd

Q1. How are iden.ty operators different from membership


operators?
Ans- Unlike membership operators, iden.ty operators compare the
values to find out if they have the same value or not.

Q2. What are Python decorators?


Ans- A specific change made in Python syntax to alter the func.ons
easily is termed a Python decorator.

Q3. Differen.ate between list and tuple.


Ans- Tuple is not mutable. It can be hashed e.g. key for dic.onaries.
On the other hand, lists are mutable.

Q4. Describe mul.threading in Python.


Ans- Using Mul.threading to speed up the code is not the go-to
op.on, even though Python comes with a mul.-threading package.

The package has the GIL or Global Interpreter Lock, which is a


construct. It ensures that only one of the threads executes at any
given .me. A thread acquires the GIL and then performs work before
passing it to the next thread.

This happens so fast that to a user, it seems that threads are


execu.ng in parallel. Obviously, this is not the case, as they are just
taking turns while using the same CPU core. GIL passing adds to the
overall overhead of the execu.on.

As such, if you intend to use the threading package to speed up the


execu.on, using the package is not recommended.

Q5. Draw a comparison between the range and xrange in Python.

Page 2 of 9
iNeuron Intelligence Pvt Ltd

Ans- In terms of func.onality, both range and xrange are iden.cal.


Both allow for genera.ng a list of integers. The main difference
between the two is that while range returns a Python list object,
xrange returns an xrange object.

Xrange is not able to generate a sta.c list at run.me the way range
does. On the contrary, it creates values along with the requirements
via a special technique called yielding. It is used with a type of object
known as a generator.

If you have an enormous range for which you need to generate a list,
then xrange is the func.on to opt for. This is especially relevant for
scenarios dealing with a memory-sensi.ve system, such as a
smartphone.

Q6. Explain Inheritance.


Ans- Inheritance enables a class to acquire all members of another
class. These members can be aYributes, methods, or both. By
providing reusability, inheritance makes it easier to create as well as
maintain an applica.on.

The class which acquires is known as the child class or the derived
class. The one that it acquires from is known as the superclass, base
class, or parent class. There are 4 forms of inheritance supported by
Python:

Single inheritance: A single derived class acquires members from one


superclass.
Mul.-Level inheritance: At least 2 different derived classes acquire
members from two dis.nct base classes.

Page 3 of 9
iNeuron Intelligence Pvt Ltd

Hierarchical inheritance: A number of child classes acquire members


from one superclass
Mul.ple inheritance: A derived class acquires members from several
super classes.

Q7. What is the difference between deep copy and shallow copy?
Ans- We use a shallow copy when a new instance type gets created.
It keeps the values that are copied in the new instance. Just like it
copies the values, the shallow copy also copies the reference
pointers.

Reference points copied in the shallow copy reference to the original


objects. Any changes made in any member of the class affect the
original copy of the same. Shallow copy enables faster execu.on of
the program.

Deep copy is used for storing values that are already copied. Unlike
shallow copy, it doesn’t copy the reference pointers to the objects.
Deep copy makes the reference to an object in addi.on to storing the
new object that is pointed by some other object.

Changes made to the original copy will not affect any other copy that
makes use of the referenced or stored object. Contrary to the shallow
copy, deep copy makes the execu.on of a program slower. This is due
to the fact that it makes some copies for each object that is called.

Q8. How do you dis.nguish between NumPy and SciPy?


Ans- Typically, NumPy contains nothing but the array data type and
the most basic opera.ons, such as basic element-wise func.ons,
indexing, reshaping, and sor.ng. All the numerical code resides in
SciPy.

Page 4 of 9
iNeuron Intelligence Pvt Ltd

As one of NumPy’s most important goals is compa.bility, the library


tries to retain all features supported by either of its predecessors.
Hence, NumPy contains a few linear algebra func.ons despite the
fact that these more appropriately belong to the SciPy library.

SciPy contains fully-featured versions of the linear algebra modules


available to NumPy in addi.on to several other numerical algorithms.

Q9. What is the output of the following code?


A0 = dict(zip(('a', 'b', 'c', 'd', 'e'),(1,2,3,4,5)))
A1 = range(10)A2 = sorted([i for i in A1 if i in A0])
A3 = sorted([A0[s] for s in A0])
A4 = [i for i in A1 if i in A3]
A5 =
A6 = [[i, i*i] for i in A1]
print(A0,A1,A2,A3,A4,A5,A6)
A0 = {'a': 1, 'c': 3, 'b': 2, 'e': 5, 'd': 4} # The order may vary

A1 = range(0, 10)

A2 = []

A3 = [1, 2, 3, 4, 5]

A4 = [1, 2, 3, 4, 5]

A5 =

Page 5 of 9
iNeuron Intelligence Pvt Ltd

A6 = [[0, 0], [1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64],
[9, 81]]

Q10. Explain dic.onaries with an example.


A dic.onary in the Python programming language is an unordered
collec.on of data values such as a map. The dic.onary holds the key:
value pair. This helps define a one-to-one rela.onship between keys
and values. Indexed by keys, a typical dic.onary contains a pair of
keys and corresponding values.

Let us take an example with three keys, namely website, language,


and offering. Their corresponding values are hackr.io, Python, and
Tutorials. The code for would be:

dict={‘Website’:‘hackr.io’,‘Language’:‘Python’:‘Offering’:‘Tutorials’}
print dict[Website] #Prints hackr.io
print dict[Language] #Prints Python
print dict[Offering] #Prints Tutorials

Q11. Python supports nega.ve indexes. What are they and why are
they used?
The sequences in Python are indexed. It consists of posi.ve and
nega.ve numbers. Posi.ve numbers use 0 as the first index, 1 as the
second index, and so on. Hence, any index for a posi.ve number n is
n-1.

Unlike posi.ve numbers, index numbering for nega.ve numbers


starts from -1, and it represents the last index in the sequence.
Likewise, -2 represents the penul.mate index. These are known as
nega.ve indexes. Nega.ve indexes are used for:

Page 6 of 9
iNeuron Intelligence Pvt Ltd

Removing any new-line spaces from the string, thus allowing the
string to except the last character, represented as S[:-1]
Showing the index to represent the string in the correct order.

Q12. What is the output of the following code?


Ans- try: if '1' != 1:
raise "someError"
else: print("someError has not occurred")
except "someError": pr
int ("someError has occurred")
The output of the program will be “invalid code.” This is because a
new excep.on class must inherit from a Base Excep.on.

Q13. Explain the process of compila.on and linking.


Ans- In order to compile new extensions without any error, compiling
and linking is used in Python. Linking ini.ates only and only when the
compila.on is complete.

In the case of dynamic loading, the process of compila.on and linking


depends on the style that is provided with the concerned system. In
order to provide dynamic loading of the configura.on setup files and
rebuild the interpreter, the Python interpreter is used.

Q14. What is Flask and what are the benefits of using it?
Ans- Flask is a web microframework for Python with Jinja2 and
Werkzeug as its dependencies. As such, it has some notable
advantages:

Page 7 of 9
iNeuron Intelligence Pvt Ltd

Flask has liYle to no dependencies on external libraries.


Because there is a liYle external dependency to update and fewer
security bugs, the web microframework is lightweight.
It has an inbuilt development server and a fast debugger.

Q15. What is the map() func.on used for?


Ans- The map() func.on applies a given func.on to each item of an
iterable. It then returns a list of the results. The value returned from
the map() func.on can then be passed on to func.ons to the likes of
the list() and set().

Typically, the given func.on is the first argument, and the iterable is
available as the second argument to a map() func.on. Several tables
are given if the func.on takes in more than one argument.

Q16. Whenever Python exits, not all the memory is deallocated. Why
is it so?
Ans- Upon exi.ng, Python’s built-in effec.ve cleanup mechanism
comes into play and tries to deallocate or destroy every other object.
However, Python modules that have circular references to other
objects, or the objects that are referenced from the global
namespaces, aren’t always deallocated or destroyed.

This is because it is not possible to deallocate those por.ons of the


memory that are reserved by the C library.

Q17. Write a program in Python for geung indices of N maximum


values in a NumPy array.

Page 8 of 9
iNeuron Intelligence Pvt Ltd

import numpy as np
arr = np.array([1, 3, 2, 4, 5])
print(arr.argsort()[-3:][::-1])
Output:
[4 3 1]

Q18. How is memory managed in Python?


Ans- Python private heap space takes the place of memory
management in Python. It contains all Python objects and data
structures. The interpreter is responsible to take care of this private
heap, and the programmer does not have access to it. The Python
memory manager is responsible for the alloca.on of Python heap
space for Python objects. The programmer may access some tools for
the code with the help of the core API. Python also provides an
inbuilt garbage collector, which recycles all the unused memory and
frees the memory, and makes it available to heap space.

Q19. What is the lambda func.on?


Ans- A lambda func.on is an anonymous func.on. This func.on can
have only one statement but can have any number of parameters.

a = lambda x,y : x+y


print(a(5, 6))

Q20. How are arguments passed in Python? By value or by


reference?
Everything in Python is an object, and all variables hold references to
the object. The reference values are according to the func.ons; as a
result, the value of the reference cannot be changed.

Page 9 of 9
iNeuron Intelligence Pvt Ltd

Q1. What are the built-in types provided by Python?


Ans- Mutable built-in types:

Lists
Sets
Dic@onaries
Immutable built-in types:

Strings
Tuples
Numbers

Q2. What are Python modules?


Ans- A file containing Python code, like func@ons and variables, is a
Python module. A Python module is an executable file with a .py
extension. Some built-in modules are:

os
sys
math
random
data @me
JSON

Q3. What is the // operator? What is its use?


The // is a floor division operator used for dividing two operands with
the result as a quo@ent displaying digits before the decimal point. For
instance, 10//5 = 2 and 10.0//5.0 = 2.0.

Page 2 of 8
iNeuron Intelligence Pvt Ltd

Q4. What is the split func@on used for?


The split func@on breaks the string into shorter strings using the
defined separator. It returns the list of all the words present in the
string.

Q5. Explain the Dogpile effect.


The dogpile effect is when the cache expires, and websites are hit by
mul@ple requests made by the client at the same @me. Using a
semaphore lock prevents the Dogpile effect. In this system, when a
value expires, the first process acquires the lock and starts genera@ng
a new value.

Q6. What is a pass in Python?


Ans- The no-opera@on Python statement refers to a pass. It is a
placeholder in the compound statement, where there should have a
blank le\ or nothing wri]en there.

Q7. What is [::-1} used for?


Ans- [::-1} reverses the order of an array or a sequence. However, the
original array or the list remains unchanged.

import array as arr


Num_Array=arr.array('k',[1,2,3,4,5])
Num_Array[::-1]

Q8. How do you capitalize the first le]er of string?


Ans- The capitalize() method capitalizes the first le]er of the string,
and if the le]er is already capitalized it returns the original string

Page 3 of 8
iNeuron Intelligence Pvt Ltd

Q9. What are the is, not, and in operators?


Ans- Operators are func@ons that take two or more values and return
the corresponding result.

is: returns true when two operands are true


not: returns inverse of a boolean value
in: checks if some element is present in some sequence.

Q10. How are modules imported in Python?


Ans- Modules are imported using the import keyword in either of the
following three ways:

import array
import array as arr
from array import *

Q11.How would you convert a list to an array?


Ans- During programming, there will be instances when you will need
to convert exis@ng lists to arrays in order to perform certain
opera@ons on them (arrays enable mathema@cal opera@ons to be
performed on them in ways that lists do not).

Here we’ll be using numpy.array(). This func@on of the numpy library


takes a list as an argument and returns an array that contains all the
elements of the list.

Q12. How is memory managed in Python?


Ans- Memory management in python is managed by Python private
heap space. All Python objects and data structures are located in a

Page 4 of 8
iNeuron Intelligence Pvt Ltd

private heap. The programmer does not have access to this private
heap. The python interpreter takes care of this instead.
The alloca@on of heap space for Python objects is done by Python’s
memory manager. The core API gives access to some tools for the
programmer to code.
Python also has an inbuilt garbage collector, which recycles all the
unused memory and so that it can be made available to the heap
space.

Q13. How do you achieve mul@threading in Python?


Ans- Python has a mul@-threading package but if you want to mul@-
thread to speed your code up, then it’s usually not a good idea to use
it.
Python has a construct called the Global Interpreter Lock (GIL). The
GIL makes sure that only one of your ‘threads’ can execute at any one
@me. A thread acquires the GIL, does a li]le work, then passes the
GIL onto the next thread.
This happens very quickly so to the human eye it may seem like your
threads are execu@ng in parallel, but they are really just taking turns
using the same CPU core.
All this GIL passing adds overhead to execu@on. This means that if
you want to make your code run faster then using the threading
package o\en isn’t a good idea.

Q14. What is monkey patching?


Ans- In Python, the term monkey patch only refers to dynamic
modifica@ons of a class or module at run-@me.

Page 5 of 8
iNeuron Intelligence Pvt Ltd

Q15. What is pickling and unpickling?


Ans- Pickle module accepts any Python object and converts it into a
string representa@on and dumps it into a file by using dump func@on,
this process is called pickling. While the process of retrieving original
Python objects from the stored string representa@on is called
unpickling.

Q16. What advantages do NumPy arrays offer over (nested) Python


lists?
Ans- Python’s lists are efficient general-purpose containers. They
support (fairly) efficient inser@on, dele@on, appending, and
concatena@on, and Python’s list comprehensions make them easy to
construct and manipulate.
They have certain limita@ons: they don’t support “vectorized”
opera@ons like elementwise addi@on and mul@plica@on, and the fact
that they can contain objects of differing types mean that Python
must store type informa@on for every element, and must execute
type dispatching code when opera@ng on each element.
NumPy is not just more efficient; it is also more convenient. You get a
lot of vector and matrix opera@ons for free, which some@mes allow
one to avoid unnecessary work. And they are also efficiently
implemented.
NumPy array is faster and You get a lot built in with NumPy, FFTs,
convolu@ons, fast searching, basic sta@s@cs, linear algebra,
histograms, etc.

Q17. How would you make a deep copy in Python?


Ans- A deep copy refers to cloning an object. When we use the =
operator, we are not cloning the object; instead, we reference our
variable to the same object (a.k.a. shallow copy).

Page 6 of 8
iNeuron Intelligence Pvt Ltd

This means that changing one variable’s value affects the other
variable’s value because they are referring (or poin@ng) to the same
object. This difference between a shallow and a deep copy is only
applicable to objects that contain other objects, like lists and
instances of a class.

Q18. What is a Python Docstring?


Ans- The Python docstrings provide a suitable way of associa@ng
documenta@on with:

Python modules
Python func@ons
Python classes
It is a specified document for the wri]en code. Unlike conven@onal
code comments, the doctoring should describe what a func@on does,
not how it works.

Q19. What is defaultdict in Python?


Ans- The Python dic@onary, dict, contains words and meanings as
well as key-value pairs of any data type. The defaultdict is another
subdivision of the built-in dict class.

How is defaultdict different?

The defaultdict is a subdivision of the dict class. Its importance lies in


the fact that it allows each new key to be given a default value based
on the type of dic@onary being created.

A defaultdict can be created by giving its declara@on, an argument


that can have three values; list, set or int. According to the specified

Page 7 of 8
iNeuron Intelligence Pvt Ltd

data type, the dic@onary is created and when any key, that does not
exist in the defaultdict is added or accessed, it is assigned a default
value as opposed to giving a Key Error.

Q20. What is Flask?


Ans. Flask (source code) is a Python micro web framework and it
does not require par@cular tools or libraries. It is used for deploying
python code into web apps.

Page 8 of 8
iNeuron Intelligence Pvt Ltd

Q1. How will you perform sta4c analysis in a Python applica4on or


find bugs?
Ans- PyChecker can be helpful as a sta4c analyser to iden4fy the bugs
in the Python project. This also helps to find out the complexity-
related bugs. Pylint is another tool that helps check if the Python
module is at par with the coding standards.

Q2. What are the tools required to unit test your code?
Ans. To test units or classes, we can use the “uniJest” python
standard library. It is the easiest way to test code, and the features
required are similar to the other unit tes4ng tools like TestNG, JUnit.

Q3. How to get indices of N maximum values in a NumPy array?


Ans. With the help of below code, we can get the maximum values in
a NumPy array :

Import numpy as nm

arr=nm.array([1, 6, 2, 4, 7])

print (arr.argsort() [-3:] [::-1])

Output:

[ 4 6 1]

Q4. How can you use ternary operators (Ternary) in Python?


Ans. Ternary operators are used to display condi4onal statements.
This consists of the true or false values. Syntax :

The ternary operator is indicated as:

Page 2 of 7
iNeuron Intelligence Pvt Ltd

[on_true] if [expression] else [on_false] x, y = 25, 50big = x if x <y else


y

Example: The expression is evaluated as if x <and else and, in this


case, if x <y is true, then the value is returned as big = x and if it is
incorrect then big = y will be returned as a result.

Q5. What does this mean? * args, ** kwargs? Why would we use it?
Ans. * Args is used when you are not sure how many arguments to
pass to a func4on, or if you want to pass a list or tuple of stored
arguments to a func4on.

** kwargs is used when we don’t know how many keyword


arguments to pass to a func4on, or it is used to pass the values from
a dic4onary as the keyword argument.

The args and kwargs iden4fiers are a conven4on, you can also use *
bob and ** billy but that would not be wise

Q6. Does Python have OOps concepts?


Ans. Python is an object-oriented programming language. This means
that any program can be solved in Python, crea4ng an object model.
However, Python can also be treated as a procedural and structural
language.

Q7. How do I save an image locally using Python whose URL I already
know?
Ans. We will use the following code to store an image locally from a
URL

Page 3 of 7
iNeuron Intelligence Pvt Ltd

import urllib.request

urllib.request.urlretrieve (“URL”, “file-name.jpg”)

Q8. How are percentages calculated with Python / NumPy?


Ans. Percentages can be calculated using the following code:

import numpy as np

a = np.array ([1,2,3,4,5])

p = np.percen4le (a, 50) #Returns 50%.

print (p)

Q9. When does Abnormal Termina4on occur?


Ans. First of all, I should men4on that abend or abnormal termina4on
is bad. You don’t want it to happen during your programming
experience. However, it is prac4cally unavoidable, in one way or
another especially when you are a beginner.

Abend is an error in your program during its execu4on, while the


main tasks con4nue to perform processes. This is caused by a code
error or some sooware problem.

Q10. Explain the bytes() func4on in Python.


Ans. The bytes() func4on in Python returns a bytes object. It converts
objects into bytes objects. It also creates empty bytes objects of the
specified size.

Page 4 of 7
iNeuron Intelligence Pvt Ltd

Q11. Explain the ‘with statement’.


Ans. In Python, the ‘with statement’ is used for excep4on handling
and resource management. It makes the code cleaner and readable
as it allows a file to be opened and closed while execu4ng a block of
code containing the ‘with statement’.

Q12. What are Pandas Data Frames?


Ans. Pandas DataFrame is a two-dimensional tabular data structure
with labelled axes. The data is aligned in a tabular manner in rows
and columns. Data Frames are widely used in data science, machine
learning, scien4fic compu4ng, etc.

Here are some features of Dataframes:

2-dimensional
Labelled axes (rows and columns)
Size-mutable
Arithme4c opera4ons can be performed on rows and columns.

Q13. How to combine Data Frames in Pandas?


Ans. We can combine Data Frames using the following func4ons:

Concat() func4on: It is used for ver4cal stacking.


pd.concat([data_frame1, data_frame2])

append(): It is used for horizontal stacking of DataFrames.


data_frame1.append(data_frame2)

join(): It is used to extract data from different DataFrames which have


one or more columns common.

Page 5 of 7
iNeuron Intelligence Pvt Ltd

Q14. How to access the top n rows of a dataframe?


Ans. To access the top n rows of a data frame, we will use df.head(n).

Q15. How to access the last n rows of a dataframe?


Ans. We will use df.tail(n) to access the last n rows of a dataframe.

Q16. What are Python namespaces?


Ans. A namespace is a mapping from names to objects. It is a system
that ensures that all the object names in a program are unique and
can be used without any conflict. Python maintains a namespace in
the form of a Python dic4onary. These namespaces are implemented
as dic4onaries with ‘name as key’ mapped to its respec4ve ‘object as
value’. Namespaces have different life4mes as they are ooen created
at different points in 4me.

Some of the namespaces in a Python program are:

Local Namespace – it contains local names inside a func4on. The


local namespace is created for a func4on call and lasts un4l the
func4on returns.
Global Namespace – It consists of the names from various imported
modules that are being used in the ongoing project. This namespace
is created when the package is imported into the script and lasts un4l
the script ends.
Built-In Namespace – This namespace contains built-in func4ons and
built-in excep4on names.

Q17. Write a python program to check if the number given is a


palindrome or not

Page 6 of 7
iNeuron Intelligence Pvt Ltd

Ans. Below is the code to check if the given number is palindrome or


not:
Num =input(“Enter a number:”)
if num==num[::-1]
print (“It is a Palindrome!”)
else:
print(“It is not a Palindrome!”)

Q18. What is Scope Resolu4on in Python?


Ans: In some cases, objects within the same scope have the same
name. However, they work differently. In such cases, scope resolu4on
help in Python automa4cally.

Q19. How is data abstrac4on done in Python?


Ans. It can be achieved in Python using abstract classes and
interfaces. Data abstrac4on only supplies the necessary details and
hides the implementa4on.
Abstrac4on is selec4ng data from a larger pool to show only the
relevant details to the object.

Page 7 of 7
iNeuron Intelligence Pvt Ltd

Q1. What are the different subsets of SQL?

Ans-

• Data Defini;on Language (DDL) – It allows you to perform various


opera;ons on the database such as CREATE, ALTER, and DELETE
objects.
• Data Manipula;on Language (DML) – It allows you to access
and manipulate data. It helps you to insert, update, delete and
retrieve data from the database.
• Data Control Language (DCL) – It allows you to control access to
the database. Example – Grant, Revoke access permissions.

Q2. What do you mean by DBMS? What are its different types?

Ans- A Database Management System (DBMS) is a soTware


applica;on that interacts with the user, applica;ons, and the database
itself to capture and analyze data. A database is a structured collec;on
of data.

A DBMS allows a user to interact with the database. The data stored in
the database can be modified, retrieved and deleted and can be of any
type like strings, numbers, images, etc.

There are two types of DBMS:

• Rela;onal Database Management System: The data is stored in


rela;ons (tables). Example – MySQL.
• Non-Rela;onal Database Management System: There is no
concept of rela;ons, tuples and aXributes. Example – MongoDB

Page 2 of 11
iNeuron Intelligence Pvt Ltd

Q3. What is a Self-Join?

Ans- A self-join is a type of join that can be used to connect two


tables. As a result, it is a unary rela;onship. Each row of the table is
aXached to itself and all other rows of the same table in a self-join.
As a result, a self-join is mostly used to combine and compare rows
from the same database table.

Q4. What is the SELECT statement?

Ans- A SELECT command gets zero or more rows from one or more
database tables or views. The most frequent data manipula;on
language (DML) command is SELECT in most applica;ons. SELECT
queries define a result set, but not how to calculate it, because SQL is
a declara;ve programming language.

Q5. What are some common clauses used with SELECT query in SQL?

Ans- The following are some frequent SQL clauses used in


conjunc;on with a SELECT query:

WHERE clause: In SQL, the WHERE clause is used to filter records that
are required depending on certain criteria.
ORDER BY clause: The ORDER BY clause in SQL is used to sort data in
ascending (ASC) or descending (DESC) order depending on specified
field(s) (DESC).
GROUP BY clause: GROUP BY clause in SQL is used to group entries
with iden;cal data and may be used with aggrega;on methods to
obtain summarised database results.
HAVING clause in SQL is used to filter records in combina;on with
Page 3 of 11
iNeuron Intelligence Pvt Ltd

the GROUP BY clause. It is different from WHERE, since the WHERE


clause cannot filter aggregated records.

Q6. What is UNION, MINUS and INTERSECT commands?

Ans- The UNION operator is used to combine the results of two


tables while also removing duplicate entries.

The MINUS operator is used to return rows from the first query but
not from the second query.

The INTERSECT operator is used to combine the results of both


queries into a single row.
Before running either of the above SQL statements, certain
requirements must be sa;sfied –
Within the clause, each SELECT query must have the same amount of
columns.
The data types in the columns must also be comparable.
In each SELECT statement, the columns must be in the same order.

Q7. What is Cursor? How to use a Cursor?

Ans- ATer any variable declara;on, DECLARE a cursor. A SELECT


Statement must always be coupled with the cursor defini;on.

Page 4 of 11
iNeuron Intelligence Pvt Ltd

To start the result set, move the cursor over it. Before obtaining rows
from the result set, the OPEN statement must be executed.

To retrieve and go to the next row in the result set, use the FETCH
command.

To disable the cursor, use the CLOSE command.

Finally, use the DEALLOCATE command to remove the cursor


defini;on and free up the resources connected with it.

Q8. List the different types of rela;onships in SQL.

Ans- There are different types of rela;ons in the database:

One-to-One – This is a connec;on between two tables in which each


record in one table corresponds to the maximum of one record in the
other.

One-to-Many and Many-to-One – This is the most frequent


connec;on, in which a record in one table is linked to several records
in another.

Many-to-Many – This is used when defining a rela;onship that


requires several instances on each sides.

Self-Referencing RelaAonships – When a table has to declare a


connec;on with itself, this is the method to employ.

Page 5 of 11
iNeuron Intelligence Pvt Ltd

Q9. What is OLTP?

Ans- OLTP, or online transac;onal processing, allows huge groups of


people to execute massive amounts of database transac;ons in real
;me, usually via the internet. A database transac;on occurs when
data in a database is changed, inserted, deleted, or queried.

Q10. What are the differences between OLTP and OLAP?

Ans- OLTP stands for online transac;on processing, whereas OLAP


stands for online analy;cal processing. OLTP is an online database
modifica;on system, whereas OLAP is an online database query
response system.

Q11. How to create empty tables with the same structure as another
table?

Ans- To create empty tables:


Using the INTO operator to fetch the records of one table into a new
table while seing a WHERE clause to false for all entries, it is
possible to create empty tables with the same structure. As a result,
SQL creates a new table with a duplicate structure to accept the
fetched entries, but nothing is stored into the new table since the
WHERE clause is ac;ve.

Page 6 of 11
iNeuron Intelligence Pvt Ltd

Q12. What is PostgreSQL?

Ans- In 1986, a team lead by Computer Science Professor Michael


Stonebraker created PostgreSQL under the name Postgres. It was
created to aid developers in the development of enterprise-level
applica;ons by ensuring data integrity and fault tolerance in systems.
PostgreSQL is an enterprise-level, versa;le, resilient, open-source,
object-rela;onal database management system that supports
variable workloads and concurrent users.

Q13. What are SQL comments?

Ans- SQL Comments are used to clarify por;ons of SQL statements


and to prevent SQL statements from being executed. Comments are
quite important in many programming languages. The comments are
not supported by a MicrosoT Access database. As a result, the
MicrosoT Access database is used in the examples in Mozilla Firefox
and MicrosoT Edge.
Single Line Comments: It starts with two consecu;ve hyphens (–).
Mul;-line Comments: It starts with /* and ends with */.

Q14. What is the usage of the NVL () func;on?

Ans- You may use the NVL func;on to replace null values with a
default value. The func;on returns the value of the second
parameter if the first parameter is null. If the first parameter is
anything other than null, it is leT alone.

Page 7 of 11
iNeuron Intelligence Pvt Ltd

This func;on is used in Oracle, not in SQL and MySQL. Instead of


NVL() func;on, MySQL have IFNULL() and SQL Server have ISNULL()
func;on.

Q15. Explain character-manipula;on func;ons? Explains its different


types in SQL.

Ans- Change, extract, and edit the character string using character
manipula;on rou;nes. The func;on will do its ac;on on the input
strings and return the result when one or more characters and words
are supplied into it.

The character manipula;on func;ons in SQL are as follows:

A) CONCAT (joining two or more values): This func;on is used to join


two or more values together. The second string is always appended
to the end of the first string.

B) SUBSTR: This func;on returns a segment of a string from a given


start point to a given endpoint.

C) LENGTH: This func;on returns the length of the string in numerical


form, including blank spaces.

D) INSTR: This func;on calculates the precise numeric loca;on of a


character or word in a string.

E) LPAD: For right-jus;fied values, it returns the padding of the leT-


side character value.

F) RPAD: For a leT-jus;fied value, it returns the padding of the right-


side character value.

Page 8 of 11
iNeuron Intelligence Pvt Ltd

G) TRIM: This func;on removes all defined characters from the


beginning, end, or both ends of a string. It also reduced the amount
of wasted space.

H) REPLACE: This func;on replaces all instances of a word or a


sec;on of a string (substring) with the other string value specified.

Q16. What is the difference between the RANK() and DENSE_RANK()


func;ons?

Ans- The RANK () func;on in the result set defines the rank of each
row within your ordered par;;on. If both rows have the same rank,
the next number in the ranking will be the previous rank plus a
number of duplicates. If we have three records at rank 4, for
example, the next level indicated is 7.

The DENSE_RANK () func;on assigns a dis;nct rank to each row


within a par;;on based on the provided column value, with no gaps.
It always indicates a ranking in order of precedence. This func;on will
assign the same rank to the two rows if they have the same rank,
with the next rank being the next consecu;ve number. If we have
three records at rank 4, for example, the next level indicated is 5.

Q17. What is a UNIQUE constraint?

The UNIQUE Constraint prevents iden;cal values in a column from


appearing in two records. The UNIQUE constraint guarantees that
every value in a column is unique.

Page 9 of 11
iNeuron Intelligence Pvt Ltd

Q18. What is a Self-Join?

A self-join is a type of join that can be used to connect two tables. As


a result, it is a unary rela;onship. Each row of the table is aXached to
itself and all other rows of the same table in a self-join. As a result, a
self-join is mostly used to combine and compare rows from the same
database table.

Q19. What is UNION, MINUS and INTERSECT commands?

Ans- The UNION operator is used to combine the results of two


tables while also removing duplicate entries.

The MINUS operator is used to return rows from the first query but
not from the second query.

The INTERSECT operator is used to combine the results of both


queries into a single row.
Before running either of the above SQL statements, certain
requirements must be sa;sfied –

Within the clause, each SELECT query must have the same number of
columns.

The data types in the columns must also be comparable.

In each SELECT statement, the columns must be in the same order.

Page 10 of 11
iNeuron Intelligence Pvt Ltd

Q20. List the different types of rela;onships in SQL.

Ans- There are different types of rela;ons in the database:

a) One-to-One – This is a connec;on between two tables in which


each record in one table corresponds to the maximum of one
record in the other.
b) One-to-Many and Many-to-One – This is the most frequent
connec;on, in which a record in one table is linked to several
records in another.
c) Many-to-Many – This is used when defining a rela;onship that
requires several instances on each sides.
d) Self-Referencing Rela;onships – When a table has to declare a
connec;on with itself, this is the method to employ.

Page 11 of 11
iNeuron Intelligence Pvt Ltd

Q1. What is SQL example?

SQL is a database query language that allows you to edit, remove,


and request data from databases. The following statements are a few
examples of SQL statements:

• SELECT
• INSERT
• UPDATE
• DELETE
• CREATE DATABASE
• ALTER DATABASE

Q2. What are basic SQL skills?

Ans- SQL skills aid data analysts in the creaPon, maintenance, and
retrieval of data from relaPonal databases, which divide data into
columns and rows. It also enables users to efficiently retrieve,
update, manipulate, insert, and alter data.

The most fundamental abiliPes that a SQL expert should possess are:

1. Database Management
2. Structuring a Database
3. CreaPng SQL clauses and statements
4. SQL System Skills like MYSQL, PostgreSQL
5. PHP experPse is useful.
6. Analyze SQL data
7. Using WAMP with SQL to create a database
8. OLAP Skills
Page 2 of 12
iNeuron Intelligence Pvt Ltd

Q3. What is schema in SQL Server?

Ans- A schema is a visual representaPon of the database that is


logical. It builds and specifies the relaPonships among the database’s
numerous enPPes. It refers to the several kinds of constraints that
may be applied to a database. It also describes the various data
kinds. It may also be used on Tables and Views.

Schemas come in a variety of shapes and sizes. Star schema and


Snowflake schema are two of the most popular. The enPPes in a star
schema are represented in a star form, whereas those in a snowflake
schema are shown in a snowflake shape.
Any database architecture is built on the foundaPon of schemas.

Q4. List the different types of relaPonships in SQL.

Ans- There are different types of relaPons in the database:


One-to-One – This is a connecPon between two tables in which each
record in one table corresponds to the maximum of one record in the
other.
One-to-Many and Many-to-One – This is the most frequent
connecPon, in which a record in one table is linked to several records
in another.
Many-to-Many – This is used when defining a relaPonship that
requires several instances on each sides.
Self-Referencing RelaPonships – When a table has to declare a
connecPon with itself, this is the method to employ.

Page 3 of 12
iNeuron Intelligence Pvt Ltd

Q5. What is schema in SQL Server?

Ans- A schema is a visual representaPon of the database that is


logical. It builds and specifies the relaPonships among the database’s
numerous enPPes. It refers to the several kinds of constraints that
may be applied to a database. It also describes the various data
kinds. It may also be used on Tables and Views.

Schemas come in a variety of shapes and sizes. Star schema and


Snowflake schema are two of the most popular. The enPPes in a star
schema are represented in a star form, whereas those in a snowflake
schema are shown in a snowflake shape.
Any database architecture is built on the foundaPon of schemas.

Q6. How to install SQL Server in Windows 11?

Ans- Install SQL Server Management Studio In Windows 11

Step 1: Click on SSMS, which will take you to the SQL Server
Management Studio page.

Step 2: Moreover, click on the SQL Server Management Studio link


and tap on Save File.

Step 3: Save this file to your local drive and go to the folder.

Step 4: The setup window will appear, and here you can choose the
locaPon where you want to save the file.
Step 5: Click on Install.

Page 4 of 12
iNeuron Intelligence Pvt Ltd

Step 6: Close the window ader the installaPon is complete.


Step 7: Furthermore, go back to your Start Menu and search for SQL
server management studio.

Step 8: Furthermore, double-click on it, and the login page will


appear once it shows up.

Step 9: You should be able to see your server name. However, if


that’s not visible, click on the drop-down arrow on the server and tap
on Browse.

Step 10: Choose your SQL server and click on Connect.

Q7. What is the case when in SQL Server?

Ans- The CASE statement is used to construct logic in which one


column’s value is determined by the values of other columns.

At least one set of WHEN and THEN commands makes up the SQL
Server CASE Statement. The condiPon to be tested is specified by the
WHEN statement. If the WHEN condiPon returns TRUE, the THEN
sentence explains what to do.

When none of the WHEN condiPons return true, the ELSE statement
is executed. The END keyword brings the CASE statement to a close.

Page 5 of 12
iNeuron Intelligence Pvt Ltd

CASE

WHEN condiPon1 THEN result1

WHEN condiPon2 THEN result2

WHEN condiPonN THEN resultN

ELSE result

END;

Q8. What is the difference between NOW() and CURRENT_DATE()?

Ans- NOW() returns a constant Pme that indicates the Pme at which
the statement began to execute. (Within a stored funcPon or trigger,
NOW() returns the Pme at which the funcPon or triggering statement
began to execute.

The simple difference between NOW() and CURRENT_DATE() is that


NOW() will fetch the current date and Pme both in format ‘YYYY-
MM_DD HH:MM:SS’ while CURRENT_DATE() will fetch the date of the
current day ‘YYYY-MM_DD’.

Let’s move to the next quesPon in this SQL Interview QuesPons.

Page 6 of 12
iNeuron Intelligence Pvt Ltd

Q9. What is BLOB and TEXT in MySQL?

Ans- BLOB stands for Binary Huge Objects and can be used to store
binary data, whereas TEXT may be used to store a large number of
strings. BLOB may be used to store binary data, which includes
images, movies, audio, and applicaPons.

BLOB values funcPon similarly to byte strings, and they lack a


character set. As a result, bytes’ numeric values are completely
dependent on comparison and sorPng.

TEXT values behave similarly to a character string or a non-binary


string. The comparison/sorPng of TEXT is completely dependent on
the character set collecPon.

Q10. How to create a stored procedure using SQL Server?

A stored procedure is a piece of prepared SQL code that you can save
and reuse again and over.
So, if you have a SQL query that you create frequently, save it as a
stored procedure and then call it to run it.
You may also supply parameters to a stored procedure so that it can
act based on the value(s) of the parameter(s) given.

Stored Procedure Syntax

CREATE PROCEDURE procedure_name

AS

sql_statement

Page 7 of 12
iNeuron Intelligence Pvt Ltd

GO;

Execute a Stored Procedure

EXEC procedure_name;

Q11. What is Database Black Box TesPng?

Black Box TesPng is a sodware tesPng approach that involves tesPng


the funcPons of sodware applicaPons without knowing the internal
code structure, implementaPon details, or internal routes. Black Box
TesPng is a type of sodware tesPng that focuses on the input and
output of sodware applicaPons and is totally driven by sodware
requirements and specificaPons. Behavioral tesPng is another name
for it.

Q12. Where MyISAM table is stored?

Prior to the introducPon of MySQL 5.5 in December 2009, MyISAM


was the default storage engine for MySQL relaPonal database
management system versions. It’s based on the older ISAM code, but
it comes with a lot of extra features. Each MyISAM table is split into
three files on disc (if it is not parPPoned). The file names start with
the table name and end with an extension that indicates the file type.
The table definiPon is stored in a.frm file, however this file is not part
of the MyISAM engine; instead, it is part of the server. The data file’s
suffix is.MYD (MYData). The index file’s extension is.MYI (MYIndex). If
you lose your index file, you may always restore it by recreaPng
indexes.
Page 8 of 12
iNeuron Intelligence Pvt Ltd

Q13. How to find the nth highest salary in SQL?

Ans- The most typical interview quesPon is to find the Nth highest
pay in a table. This work can be accomplished using the dense rank()
funcPon.

Employee table

employee_name salary

A 24000

C 34000

D 55000

E 75000

F 21000

G 40000

H 50000

SELECT * FROM(

Page 9 of 12
iNeuron Intelligence Pvt Ltd

SELECT employee_name, salary, DENSE_RANK()

OVER(ORDER BY salary DESC)r FROM Employee)

WHERE r=&n;

To find to the 2nd highest salary set n = 2

To find 3rd highest salary set n = 3 and so on.

Q14. What do you mean by table and field in SQL?

A table refers to a collecPon of data in an organised manner in form


of rows and columns. A field refers to the number of columns in a
table. For example:

Table: StudentInformaPon

Field: Stu Id, Stu Name, Stu Marks

Page 10 of 12
iNeuron Intelligence Pvt Ltd

Q15. What is the difference between CHAR and VARCHAR2 datatype


in SQL?

Both Char and Varchar2 are used for characters datatype but varchar2
is used for character strings of variable length whereas Char is used for
strings of fixed length. For example, char(10) can only store 10
characters and will not be able to store a string of any other length
whereas varchar2(10) can store any length i.e 6,8,2 in this variable.

Q16. What is a Primary key?

• A Primary key in SQL is a column (or collecPon of columns) or a


set of columns that uniquely idenPfies each row in the table.
• Uniquely idenPfies a single row in the table
• Null values not allowed

Q17. What are Constraints?

Ans- Constraints in SQL are used to specify the limit on the data type
of the table. It can be specified while creaPng or altering the table
statement. The sample of constraints are:

• NOT NULL
• CHECK
• DEFAULT
• UNIQUE
• PRIMARY KEY
• FOREIGN KEY

Page 11 of 12
iNeuron Intelligence Pvt Ltd

Q18. What is a Unique key?

Ans- Uniquely idenPfies a single row in the table.

• MulPple values allowed per table.


• Null values allowed.

Q19. What is a foreign key in SQL?

• Foreign key maintains referenPal integrity by enforcing a link


between the data in two tables.
• The foreign key in the child table references the primary key in
the parent table.
• The foreign key constraint prevents acPons that would destroy
links between the child and parent tables.

Q20. What do you mean by data integrity?

Ans- Data Integrity defines the accuracy as well as the consistency of


the data stored in a database. It also defines integrity constraints to
enforce business rules on the data when it is entered into an
applicaPon or a database.

Page 12 of 12
iNeuron Intelligence Pvt Ltd

Q1. What is the difference between clustered and non-clustered index


in SQL?

Ans- The differences between the clustered and non-clustered index


in SQL are :

1. Clustered index is used for easy retrieval of data from the


database and its faster whereas reading from non- clustered
index is relaDvely slower.
2. Clustered index alters the way records are stored in a database
as it sorts out rows by the column which is set to be clustered
index whereas in a non-clustered index, it does not alter the way
it was stored but it creates a separate object within a table which
points back to the original table rows aJer searching.
3. One table can only have one clustered index whereas it can have
many non-clustered index.

Q2. Write a SQL query to display the current date?

Ans- In SQL, there is a built-in funcDon called Get Date() which helps
to return the current Dmestamp/date.

Q3. What are EnDDes and RelaDonships?

Ans- EnDDes: A person, place, or thing in the real world about which
data can be stored in a database. Tables store data that represents one
type of enDty. For example – A bank database has a customer table to
store customer informaDon. The customer table stores this
informaDon as a set of aXributes (columns within the table) for each
customer.
Page 2 of 10
iNeuron Intelligence Pvt Ltd

RelaDonships: RelaDon or links between enDDes that have something


to do with each other. For example – The customer name is related to
the customer account number and contact informaDon, which might
be in the same table. There can also be relaDonships between separate
tables (for example, customer to accounts).

Q4. What is an Index?

Ans- An index refers to a performance tuning method of allowing


faster retrieval of records from the table. An index creates an entry for
each value and hence it will be faster to retrieve data.

Q5. Explain different types of index in SQL.

Ans- There are three types of index in SQL namely:

Unique Index:

This index does not allow the field to have duplicate values if the
column is unique indexed. If a primary key is defined, a unique index
can be applied automaDcally.

Clustered Index:

This index reorders the physical order of the table and searches based
on the basis of key values. Each table can only have one clustered
index.

Page 3 of 10
iNeuron Intelligence Pvt Ltd

Non-Clustered Index:
Non-Clustered Index does not alter the physical order of the table and
maintains a logical order of the data. Each table can have many
nonclustered indexes.

Q6. What is NormalizaDon and what are the advantages of it?

Ans- NormalizaDon in SQL is the process of organizing data to avoid


duplicaDon and redundancy. Some of the advantages are:

• BeXer Database organizaDon


• More Tables with smaller rows
• Efficient data access
• Greater Flexibility for Queries
• Quickly find the informaDon
• Easier to implement Security
• Allows easy modificaDon
• ReducDon of redundant and duplicate data
• More Compact Database
• Ensure Consistent data aJer modificaDon

Q7. What is the difference between DROP and TRUNCATE commands?

Ans- DROP command removes a table and it cannot be rolled back


from the database whereas TRUNCATE command removes all the rows
from the table.

What are the differences between OLTP and OLAP?


Page 4 of 10
iNeuron Intelligence Pvt Ltd

OLTP stands for online transaction processing, whereas


OLAP stands for online analytical processing. OLTP is an
online database modification system, whereas OLAP is an
online database query response system.

Q8. How to create empty tables with the same structure


as another table?

To create empty tables:

Using the INTO operator to fetch the records of one table


into a new table while setting a WHERE clause to false for all
entries, it is possible to create empty tables with the same
structure. As a result, SQL creates a new table with a
duplicate structure to accept the fetched entries, but
nothing is stored into the new table since the WHERE clause
is active.

Ans- There are many successive levels of normalizaDon. These are


called normal forms. Each consecuDve normal form depends on the
previous one.The first three normal forms are usually adequate.

Normal Forms are used in database tables to remove or decrease


duplicaDon. The following are the many forms:

First Normal Form:


When every aXribute in a relaDon is a single-valued aXribute, it is
said to be in first normal form. The first normal form is broken when
a relaDon has a composite or mulD-valued property.

Second Normal Form:

Page 5 of 10
iNeuron Intelligence Pvt Ltd

A relaDon is in second normal form if it meets the first normal form’s


requirements and does not contain any parDal dependencies. In 2NF,
a relaDon has no parDal dependence, which means it has no non-
prime aXribute that is dependent on any suitable subset of any table
candidate key. OJen, the problem may be solved by sefng a single
column Primary Key.

Third Normal Form:


If a relaDon meets the requirements for the second normal form and
there is no transiDve dependency, it is said to be in the third normal
form.

Q9. What is OLTP?

Ans- OLTP, or online transacDonal processing, allows huge groups of


people to execute massive amounts of database transacDons in real
Dme, usually via the internet. A database transacDon occurs when
data in a database is changed, inserted, deleted, or queried.

What are the differences between OLTP and OLAP?

OLTP stands for online transacDon processing, whereas OLAP stands


for online analyDcal processing. OLTP is an online database
modificaDon system, whereas OLAP is an online database query
response system.

Q10. How to create empty tables with the same structure as another
table?

Ans- To create empty tables:


Page 6 of 10
iNeuron Intelligence Pvt Ltd

Using the INTO operator to fetch the records of one table into a new
table while sefng a WHERE clause to false for all entries, it is
possible to create empty tables with the same structure. As a result,
SQL creates a new table with a duplicate structure to accept the
fetched entries, but nothing is stored into the new table since the
WHERE clause is acDve.

Q11. What are SQL comments?

Ans- SQL Comments are used to clarify porDons of SQL statements


and to prevent SQL statements from being executed. Comments are
quite important in many programming languages. The comments are
not supported by a MicrosoJ Access database. As a result, the
MicrosoJ Access database is used in the examples in Mozilla Firefox
and MicrosoJ Edge.
Single Line Comments: It starts with two consecuDve hyphens (–).
MulD-line Comments: It starts with /* and ends with */.

Q12. What is the difference between the RANK () and DENSE_RANK ()


funcDons?

Ans- The RANK () funcDon in the result set defines the rank of each
row within your ordered parDDon. If both rows have the same rank,
the next number in the ranking will be the previous rank plus a
number of duplicates. If we have three records at rank 4, for
example, the next level indicated is 7.

Page 7 of 10
iNeuron Intelligence Pvt Ltd

Q13. How to do a palindrome funcDon in Python?

Ans- There are numerous ways to perform palindromes in Python.


We can do this using reverse and compare method, in-built method,
for loop, while loop, reverse and join, iteraDve loop and recursion
method.

Q14. How do you find a palindrome number?

Ans- Any number that runs back on itself or remains the same when
reversed is a palindrome number. For example, 16461, 11 and 12321.

Q15. What are the people who specialize in Python called?


1. Pythonic
2. Unpythonic
3. Monty Python
4. Pythoniasts
Answer. d. the people who specialize, or are great admirers of this
programming language are called as Pythoniasts. They are extremely
knowledgeable people.

Q16. What is the type of programming language supported by


Python?
1. Object-oriented
2. FuncDonal programming
3. Structured programming
4. All of the above

Page 8 of 10
iNeuron Intelligence Pvt Ltd

Answer. d. Python is an interpreted programming language,


supporDng object-oriented, structured, and funcDonal programming.

Q17. When Python is dealing with idenDfiers, is it case sensiDve?


1. Yes
2. No
3. Machine dependent
4. Can’t say
Answer. a. It is case sensiDve.
Q72. What is the extension of the Python file?
1. .pl
2. .py
3. . python
4. .p
Answer. b. The correct extension of python is .py and can be wriXen
in any text editor. We need to use the extension .py to save these
files.

Q18. All the keywords in Python are in_


1. Lower case
2. Upper case
3. Capitalized
4. None of the above
Answer. d. Only True, False and None are capitalized and all the
others in lower case.

Page 9 of 10
iNeuron Intelligence Pvt Ltd

Q19. What does pip mean in Python?


1. Unlimited length
2. All private members must have leading and trailing underscores
3. Preferred Installer Program
4. None of the above
Answer. c. Variable names can be of any length.

Q20. The built-in funcDon in Python is:


1. Print ()
2. Seed ()
3. Sqrt ()
4. Factorial ()
Answer. a. The funcDon seed is a funcDon which is present in the
random module. The funcDons sqrt and factorial are a part of the
math module. The print funcDon is a built-in funcDon which prints a
value directly to the system output.

Page 10 of 10
iNeuron Intelligence Pvt Ltd

Q1. Which of the following defini3ons is the one for packages in


Python?
1. A set of main modules
2. A folder of python modules
3. Set of programs making use of python modules
4. Number of files containing python defini3ons and statements
Answer. b. A folder of python modules is called as package of
modules.

Q2. What is the order in which namespaces in Python looks for an


iden3fier?
1. First, the python searches for the built-in namespace, then the
global namespace and then the local namespace
2. Python first searches for the built-in namespace, then local and
finally the global namespace
3. Python first searches for local namespace, then global
namespace and finally the built-in namespace
4. Python searches for the global namespace, followed by the
local namespace and finally the built-in namespace.
Answer. C. Python first searches for the local namespace, followed by
the global and finally the built-in namespace.

Q3. Which of the following is not a keyword used in Python


language?
1. Pass
2. Eval
3. Assert
4. Nonlocal
Answer. b. Eval is used as a variable in Python.

Page 2 of 14
iNeuron Intelligence Pvt Ltd

Q4. Which of the following is the use of func3on in python?


1. Func3ons do not provide beKer modularity for applica3ons
2. One can’t create our own func3ons
3. Func3ons are reusable pieces of programs
4. All of the above
Answer. c. Func3ons are reusable pieces of programs, which allow us
to give a name to a par3cular block of statements, allowing us to run
the block using the specified name anywhere in our program and any
number of 3mes.

Q5. Which of the following is a feature of Python Doc String?


1. All func3ons should have a docstring in python
2. Doc Strings can be accessed by the _doc_ aKribute on objects
3. This feature provides a very convenient way of associa3ng
documenta3on with python modules, func3ons, classes and
methods
4. All of the above
Answer. d. Python has a niSy feature, which is referred to as the
documenta3on strings, usually referred to by its abbreviated name of
docstrings. They are important tools and one must use them as they
help document the program beKer along with making it easier to
understand.

Q6. Which of the following is the use of the func3on id() in python?
1. Every object does not have a unique id in Python
2. The id func3on in python returns the iden3ty of the object
3. None
4. All

Page 3 of 14
iNeuron Intelligence Pvt Ltd

Answer. b. Every func3on in Python has a unique id. The id() func3on
helps return the id of the object

Q7. What is the func3on of pickling in python?


1. Conversion of a python object
2. Conversion of database into list
3. Conversion of byte stream into python object hierarchy
4. Conversion of list into database
Answer. a. The process of pickling refers to sterilizing a Python object,
which means conver3ng a byte stream into python object hierarchy.
The process which is the opposite of pickling is called unpickling.

Q8. What is Python code-compiled or interpreted?


1. The code is both compiled and interpreted
2. Neither compiled nor interpreted
3. Only compiled
4. Only interpreted
Answer. b. There are a lot of languages which have been
implemented using both compilers and interpreters, including C,
Pascal, as well as python.

Q9. What will be the output of the following Python function?

len(["hello",2, 4, 6])?

a) Error

b) 6

Page 4 of 14
iNeuron Intelligence Pvt Ltd

c) 4

d) 3

Answer: c

Explanation: The function len() returns the length of the number of


elements in the iterable. Therefore, the output of the function shown
above is 4.

Q10. What is the order of namespaces in which Python looks for an


identifier?

a) Python first searches the built-in namespace, then the global


namespace and finally the local namespace

b) Python first searches the built-in namespace, then the local


namespace and finally the global namespace

c) Python first searches the local namespace, then the global


namespace and finally the built-in namespace

d) Python first searches the global namespace, then the local


namespace and finally the built-in namespace

Answer: c

Explanation: Python first searches for the local, then the global and
finally the built-in namespace.

Page 5 of 14
iNeuron Intelligence Pvt Ltd

Q11. What will be the output of the following Python program?

def foo(x):

x[0] = ['def']

x[1] = ['abc']

return id(x)

q = ['abc', 'def']

print(id(q) == foo(q))

a) Error

b) None

c) False

d) True

Answer: d

Explana3on: The same object is modified in the func3on.

Page 6 of 14
iNeuron Intelligence Pvt Ltd

Q12. What will be the output of the following Python program?

z=set('abc')

z.add('san')

z.update(set(['p', 'q']))

a) {‘a’, ‘c’, ‘c’, ‘p’, ‘q’, ‘s’, ‘a’, ‘n’}

b) {‘abc’, ‘p’, ‘q’, ‘san’}

c) {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}

d) {‘a’, ‘b’, ‘c’, [‘p’, ‘q’], ‘san’}

Answer: c

Explana3on: The code shown first adds the element ‘san’ to the set z.
The set z is then updated and two more elements, namely, ‘p’ and ‘q’
are added to it. Hence the output is: {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}

Q13. What will be the output of the following Python code?

print("abc. DEF".capitalize())

Page 7 of 14
iNeuron Intelligence Pvt Ltd

a) Abc. def

b) abc. def

c) Abc. Def

d) ABC. DEF

Answer: a

Explana3on: The first leKer of the string is converted to uppercase


and the others are converted to lowercase.

Q14. What will be the value of ‘result’ in following Python program?

list1 = [1,2,3,4]

list2 = [2,4,5,6]

list3 = [2,6,7,8]

result = list()

result.extend(i for i in list1 if i not in (list2+list3) and i not in result)

result.extend(i for i in list2 if i not in (list1+list3) and i not in result)

result.extend(i for i in list3 if i not in (list1+list2) and i not in result)

a) [1, 3, 5, 7, 8]

Page 8 of 14
iNeuron Intelligence Pvt Ltd

b) [1, 7, 8]

c) [1, 2, 4, 7, 8]

d) error

Answer: a

Explana3on: Here, ‘result’ is a list which is extending three 3mes.


When first 3me ‘extend’ func3on is called for ‘result’, the inner code
generates a generator object, which is further used in ‘extend’
func3on.

Q15. What will be the output of the following Python code?

>>>list1 = [1, 3]

>>>list2 = list1

>>>list1[0] = 4

>>>print(list2)

a) [1, 4]

b) [1, 3, 4]

c) [4, 3]

d) [1, 3]
Page 9 of 14
iNeuron Intelligence Pvt Ltd

Answer: c

Explana3on: Lists should be copied by execu3ng [:] opera3on.

Q16. What will be the output of the following Python program?

i=0

while i < 5:

print(i)

i += 1

if i == 3:

break

else:

print(0)

a) error

b) 0 1 2 0

c) 0 1 2

d) none of the men3oned

Page 10 of 14
iNeuron Intelligence Pvt Ltd

Answer: c

Explana3on: The else part is not executed if control breaks out of the
loop.

Q17. What will be the output of the following Python code?

x = 'abcd'

for i in range(len(x)):

print(i)

a) error

b) 1 2 3 4

c) a b c d

d) 0 1 2 3

Answer: d

Explana3on: i takes values 0, 1, 2 and 3.

Page 11 of 14
iNeuron Intelligence Pvt Ltd

Q18. What will be the output of the following Python program?

def addItem(listParam):

listParam += [1]

mylist = [1, 2, 3, 4]

addItem(mylist)

print(len(mylist))

a) 5

b) 8

c) 2

d) 1

Answer: a

Explana3on: + will append the element to the list.

Q19.What will be the output of the following Python code snippet?

z=set('abc$de')

Page 12 of 14
iNeuron Intelligence Pvt Ltd

'a' in z

a) Error

b) True

c) False

d) No output

View Answer

Answer: b

Explana3on: The code shown above is used to check whether a


par3cular item is a part of a given set or not. Since ‘a’ is a part of the
set z, the output is true. Note that this code would result in an error in
the absence of the quotes.

Q20. What will be the output of the following Python expression?

round(4.576)

a) 4

b) 4.6

c) 5

d) 4.5
Page 13 of 14
iNeuron Intelligence Pvt Ltd

View Answer

Answer: c

Explana3on: This is a built-in func3on which rounds a number to give


precision in decimal digits. In the above case, since the number of
decimal places has not been specified, the decimal number is rounded
off to a whole number.

Page 14 of 14
iNeuron Intelligence Pvt Ltd

Q1. What will be the output of the following Python code?

x = [[0], [1]]

print((' '.join(list(map(str, x))),))

a) 01

b) [0] [1]

c) (’01’)

d) (‘[0] [1]’,)

Answer: d

ExplanaKon: (element,) is not the same as element. It is a tuple with


one item.

Q2. The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the


same.

a) True

b) False

View Answer

Answer: a

Page 2 of 12
iNeuron Intelligence Pvt Ltd

ExplanaKon: Although the presence of parenthesis does affect the


order of precedence, in the case shown above, it is not making a
difference. The result of both of these expressions is 1.333333333.
Hence the statement is true.

Q3. What will be the value of the following Python expression?

4+3%5

a) 4

b) 7

c) 2

d) 0

Answer: b

ExplanaKon: The order of precedence is: %, +. Hence the expression


above, on simplificaKon results in 4 + 3 = 7. Hence the result is 7.

Q4. What will be the output of the following Python code?

string = "my name is x"

for i in string:

print (i, end=", ")


Page 3 of 12
iNeuron Intelligence Pvt Ltd

a) m, y, , n, a, m, e, , i, s, , x,

b) m, y, , n, a, m, e, , i, s, , x

c) my, name, is, x,

d) error

Answer: a

ExplanaKon: Variable i takes the value of one character at a Kme.

Q5. What will be the output of the following Python code snippet?

a = [0, 1, 2, 3]

for a[0] in a:

print(a[0])

a) 0 1 2 3

b) 0 1 2 2

c) 3 3 3 3

d) error

Answer: a

Page 4 of 12
iNeuron Intelligence Pvt Ltd

ExplanaKon: The value of a[0] changes in each iteraKon. Since the


first value that it takes is itself, there is no visible error in the current
example.

Q6. What are the different subsets of SQL?

Ans-

• Data DefiniKon Language (DDL) – It allows you to perform various


operaKons on the database such as CREATE, ALTER, and DELETE
objects.
• Data ManipulaKon Language (DML) – It allows you to access
and manipulate data. It helps you to insert, update, delete and
retrieve data from the database.
• Data Control Language (DCL) – It allows you to control access to
the database. Example – Grant, Revoke access permissions.

Q7. What do you mean by DBMS? What are its different types?

Ans- A Database Management System (DBMS) is a sojware


applicaKon that interacts with the user, applicaKons, and the database
itself to capture and analyze data. A database is a structured collecKon
of data.

A DBMS allows a user to interact with the database. The data stored in
the database can be modified, retrieved and deleted and can be of any
type like strings, numbers, images, etc.

There are two types of DBMS:

• RelaKonal Database Management System: The data is stored in


relaKons (tables). Example – MySQL.

Page 5 of 12
iNeuron Intelligence Pvt Ltd

• Non-RelaKonal Database Management System: There is no


concept of relaKons, tuples and amributes. Example – MongoDB

Q8. What is a Self-Join?

Ans- A self-join is a type of join that can be used to connect two


tables. As a result, it is a unary relaKonship. Each row of the table is
amached to itself and all other rows of the same table in a self-join.
As a result, a self-join is mostly used to combine and compare rows
from the same database table.

Q9. What is the SELECT statement?

Ans- A SELECT command gets zero or more rows from one or more
database tables or views. The most frequent data manipulaKon
language (DML) command is SELECT in most applicaKons. SELECT
queries define a result set, but not how to calculate it, because SQL is
a declaraKve programming language.

Q10. What are some common clauses used with SELECT query in
SQL?

Ans- The following are some frequent SQL clauses used in


conjuncKon with a SELECT query:

WHERE clause: In SQL, the WHERE clause is used to filter records that
are required depending on certain criteria.
ORDER BY clause: The ORDER BY clause in SQL is used to sort data in

Page 6 of 12
iNeuron Intelligence Pvt Ltd

ascending (ASC) or descending (DESC) order depending on specified


field(s) (DESC).
GROUP BY clause: GROUP BY clause in SQL is used to group entries
with idenKcal data and may be used with aggregaKon methods to
obtain summarised database results.
HAVING clause in SQL is used to filter records in combinaKon with
the GROUP BY clause. It is different from WHERE, since the WHERE
clause cannot filter aggregated records.

Q11. What is UNION, MINUS and INTERSECT commands?

Ans- The UNION operator is used to combine the results of two


tables while also removing duplicate entries.

The MINUS operator is used to return rows from the first query but
not from the second query.

The INTERSECT operator is used to combine the results of both


queries into a single row.
Before running either of the above SQL statements, certain
requirements must be saKsfied –
Within the clause, each SELECT query must have the same amount of
columns.
The data types in the columns must also be comparable.
In each SELECT statement, the columns must be in the same order.

Page 7 of 12
iNeuron Intelligence Pvt Ltd

Q12. What is Cursor? How to use a Cursor?

Ans- Ajer any variable declaraKon, DECLARE a cursor. A SELECT


Statement must always be coupled with the cursor definiKon.

To start the result set, move the cursor over it. Before obtaining rows
from the result set, the OPEN statement must be executed.

To retrieve and go to the next row in the result set, use the FETCH
command.

To disable the cursor, use the CLOSE command.

Finally, use the DEALLOCATE command to remove the cursor


definiKon and free up the resources connected with it.

Q13. List the different types of relaKonships in SQL.

Ans- There are different types of relaKons in the database:

One-to-One – This is a connecKon between two tables in which each


record in one table corresponds to the maximum of one record in the
other.

One-to-Many and Many-to-One – This is the most frequent


connecKon, in which a record in one table is linked to several records
in another.

Many-to-Many – This is used when defining a relaKonship that


requires several instances on each sides.

Self-Referencing RelaAonships – When a table has to declare a


connecKon with itself, this is the method to employ.
Page 8 of 12
iNeuron Intelligence Pvt Ltd

Q14. What is OLTP?

Ans- OLTP, or online transacKonal processing, allows huge groups of


people to execute massive amounts of database transacKons in real
Kme, usually via the internet. A database transacKon occurs when
data in a database is changed, inserted, deleted, or queried.

Q15. What are the differences between OLTP and OLAP?

Ans- OLTP stands for online transacKon processing, whereas OLAP


stands for online analyKcal processing. OLTP is an online database
modificaKon system, whereas OLAP is an online database query
response system.

Q16. How to create empty tables with the same structure as another
table?

Ans- To create empty tables:


Using the INTO operator to fetch the records of one table into a new
table while seung a WHERE clause to false for all entries, it is
possible to create empty tables with the same structure. As a result,
SQL creates a new table with a duplicate structure to accept the
fetched entries, but nothing is stored into the new table since the
WHERE clause is acKve.

Page 9 of 12
iNeuron Intelligence Pvt Ltd

Q17. What is PostgreSQL?

Ans- In 1986, a team lead by Computer Science Professor Michael


Stonebraker created PostgreSQL under the name Postgres. It was
created to aid developers in the development of enterprise-level
applicaKons by ensuring data integrity and fault tolerance in systems.
PostgreSQL is an enterprise-level, versaKle, resilient, open-source,
object-relaKonal database management system that supports
variable workloads and concurrent users.

Q18. What are SQL comments?

Ans- SQL Comments are used to clarify porKons of SQL statements


and to prevent SQL statements from being executed. Comments are
quite important in many programming languages. The comments are
not supported by a Microsoj Access database. As a result, the
Microsoj Access database is used in the examples in Mozilla Firefox
and Microsoj Edge.
Single Line Comments: It starts with two consecuKve hyphens (–).
MulK-line Comments: It starts with /* and ends with */.

Q19. What is the usage of the NVL () funcKon?

Ans- You may use the NVL funcKon to replace null values with a
default value. The funcKon returns the value of the second
parameter if the first parameter is null. If the first parameter is
anything other than null, it is lej alone.

Page 10 of 12
iNeuron Intelligence Pvt Ltd

This funcKon is used in Oracle, not in SQL and MySQL. Instead of


NVL() funcKon, MySQL have IFNULL() and SQL Server have ISNULL()
funcKon.

Q20. Explain character-manipulaKon funcKons? Explains its different


types in SQL.

Ans- Change, extract, and edit the character string using character
manipulaKon rouKnes. The funcKon will do its acKon on the input
strings and return the result when one or more characters and words
are supplied into it.

The character manipulaKon funcKons in SQL are as follows:

A) CONCAT (joining two or more values): This funcKon is used to join


two or more values together. The second string is always appended
to the end of the first string.

B) SUBSTR: This funcKon returns a segment of a string from a given


start point to a given endpoint.

C) LENGTH: This funcKon returns the length of the string in numerical


form, including blank spaces.

D) INSTR: This funcKon calculates the precise numeric locaKon of a


character or word in a string.

E) LPAD: For right-jusKfied values, it returns the padding of the lej-


side character value.

F) RPAD: For a lej-jusKfied value, it returns the padding of the right-


side character value.

Page 11 of 12
iNeuron Intelligence Pvt Ltd

G) TRIM: This funcKon removes all defined characters from the


beginning, end, or both ends of a string. It also reduced the amount
of wasted space.

H) REPLACE: This funcKon replaces all instances of a word or a


secKon of a string (substring) with the other string value specified.

Page 12 of 12
iNeuron Intelligence Pvt Ltd

Q1. What is the difference between the RANK() and DENSE_RANK()


func?ons?

Ans- The RANK () func?on in the result set defines the rank of each
row within your ordered par??on. If both rows have the same rank,
the next number in the ranking will be the previous rank plus a
number of duplicates. If we have three records at rank 4, for
example, the next level indicated is 7.

The DENSE_RANK () func?on assigns a dis?nct rank to each row


within a par??on based on the provided column value, with no gaps.
It always indicates a ranking in order of precedence. This func?on will
assign the same rank to the two rows if they have the same rank,
with the next rank being the next consecu?ve number. If we have
three records at rank 4, for example, the next level indicated is 5.

Q2. What is a UNIQUE constraint?

The UNIQUE Constraint prevents iden?cal values in a column from


appearing in two records. The UNIQUE constraint guarantees that
every value in a column is unique.

Q3. What is a Self-Join?

A self-join is a type of join that can be used to connect two tables. As


a result, it is a unary rela?onship. Each row of the table is aYached to
itself and all other rows of the same table in a self-join. As a result, a
self-join is mostly used to combine and compare rows from the same
database table.

Page 2 of 14
iNeuron Intelligence Pvt Ltd

Q4. What is UNION, MINUS and INTERSECT commands?

Ans- The UNION operator is used to combine the results of two


tables while also removing duplicate entries.

The MINUS operator is used to return rows from the first query but
not from the second query.

The INTERSECT operator is used to combine the results of both


queries into a single row.
Before running either of the above SQL statements, certain
requirements must be sa?sfied –

Within the clause, each SELECT query must have the same number of
columns.

The data types in the columns must also be comparable.

In each SELECT statement, the columns must be in the same order.

Q5. List the different types of rela?onships in SQL.

Ans- There are different types of rela?ons in the database:

a) One-to-One – This is a connec?on between two tables in which


each record in one table corresponds to the maximum of one
record in the other.

Page 3 of 14
iNeuron Intelligence Pvt Ltd

b) One-to-Many and Many-to-One – This is the most frequent


connec?on, in which a record in one table is linked to several
records in another.
c) Many-to-Many – This is used when defining a rela?onship that
requires several instances on each sides.
d) Self-Referencing Rela?onships – When a table has to declare a
connec?on with itself, this is the method to employ.

Q6. What is SQL example?

SQL is a database query language that allows you to edit, remove,


and request data from databases. The following statements are a few
examples of SQL statements:

• SELECT
• INSERT
• UPDATE
• DELETE
• CREATE DATABASE
• ALTER DATABASE

Q7. What are basic SQL skills?

Ans- SQL skills aid data analysts in the crea?on, maintenance, and
retrieval of data from rela?onal databases, which divide data into
columns and rows. It also enables users to efficiently retrieve,
update, manipulate, insert, and alter data.

Page 4 of 14
iNeuron Intelligence Pvt Ltd

The most fundamental abili?es that a SQL expert should possess are:

1. Database Management
2. Structuring a Database
3. Crea?ng SQL clauses and statements
4. SQL System Skills like MYSQL, PostgreSQL
5. PHP exper?se is useful.
6. Analyze SQL data
7. Using WAMP with SQL to create a database
8. OLAP Skills

Q8. What is schema in SQL Server?

Ans- A schema is a visual representa?on of the database that is


logical. It builds and specifies the rela?onships among the database’s
numerous en??es. It refers to the several kinds of constraints that
may be applied to a database. It also describes the various data
kinds. It may also be used on Tables and Views.

Schemas come in a variety of shapes and sizes. Star schema and


Snowflake schema are two of the most popular. The en??es in a star
schema are represented in a star form, whereas those in a snowflake
schema are shown in a snowflake shape.
Any database architecture is built on the founda?on of schemas.

Q9. List the different types of rela?onships in SQL.

Ans- There are different types of rela?ons in the database:


One-to-One – This is a connec?on between two tables in which each
Page 5 of 14
iNeuron Intelligence Pvt Ltd

record in one table corresponds to the maximum of one record in the


other.
One-to-Many and Many-to-One – This is the most frequent
connec?on, in which a record in one table is linked to several records
in another.
Many-to-Many – This is used when defining a rela?onship that
requires several instances on each sides.
Self-Referencing Rela?onships – When a table has to declare a
connec?on with itself, this is the method to employ.

Q10. What is schema in SQL Server?

Ans- A schema is a visual representa?on of the database that is


logical. It builds and specifies the rela?onships among the database’s
numerous en??es. It refers to the several kinds of constraints that
may be applied to a database. It also describes the various data
kinds. It may also be used on Tables and Views.

Schemas come in a variety of shapes and sizes. Star schema and


Snowflake schema are two of the most popular. The en??es in a star
schema are represented in a star form, whereas those in a snowflake
schema are shown in a snowflake shape.
Any database architecture is built on the founda?on of schemas.

Page 6 of 14
iNeuron Intelligence Pvt Ltd

Q11. How to install SQL Server in Windows 11?

Ans- Install SQL Server Management Studio In Windows 11

Step 1: Click on SSMS, which will take you to the SQL Server
Management Studio page.

Step 2: Moreover, click on the SQL Server Management Studio link


and tap on Save File.

Step 3: Save this file to your local drive and go to the folder.

Step 4: The setup window will appear, and here you can choose the
loca?on where you want to save the file.
Step 5: Click on Install.
Step 6: Close the window amer the installa?on is complete.
Step 7: Furthermore, go back to your Start Menu and search for SQL
server management studio.

Step 8: Furthermore, double-click on it, and the login page will


appear once it shows up.

Step 9: You should be able to see your server name. However, if


that’s not visible, click on the drop-down arrow on the server and tap
on Browse.

Step 10: Choose your SQL server and click on Connect.

Page 7 of 14
iNeuron Intelligence Pvt Ltd

Q12. What is the case when in SQL Server?

Ans- The CASE statement is used to construct logic in which one


column’s value is determined by the values of other columns.

At least one set of WHEN and THEN commands makes up the SQL
Server CASE Statement. The condi?on to be tested is specified by the
WHEN statement. If the WHEN condi?on returns TRUE, the THEN
sentence explains what to do.

When none of the WHEN condi?ons return true, the ELSE statement
is executed. The END keyword brings the CASE statement to a close.

CASE

WHEN condi?on1 THEN result1

WHEN condi?on2 THEN result2


Page 8 of 14
iNeuron Intelligence Pvt Ltd

WHEN condi?onN THEN resultN

ELSE result

END;

Q13. What is the difference between NOW() and CURRENT_DATE()?

Ans- NOW() returns a constant ?me that indicates the ?me at which
the statement began to execute. (Within a stored func?on or trigger,
NOW() returns the ?me at which the func?on or triggering statement
began to execute.

The simple difference between NOW() and CURRENT_DATE() is that


NOW() will fetch the current date and ?me both in format ‘YYYY-
MM_DD HH:MM:SS’ while CURRENT_DATE() will fetch the date of the
current day ‘YYYY-MM_DD’.

Let’s move to the next ques?on in this SQL Interview Ques?ons.

Q14. What is BLOB and TEXT in MySQL?

Ans- BLOB stands for Binary Huge Objects and can be used to store
binary data, whereas TEXT may be used to store a large number of
strings. BLOB may be used to store binary data, which includes
images, movies, audio, and applica?ons.

Page 9 of 14
iNeuron Intelligence Pvt Ltd

BLOB values func?on similarly to byte strings, and they lack a


character set. As a result, bytes’ numeric values are completely
dependent on comparison and sor?ng.

TEXT values behave similarly to a character string or a non-binary


string. The comparison/sor?ng of TEXT is completely dependent on
the character set collec?on.

Q15. How to create a stored procedure using SQL Server?

A stored procedure is a piece of prepared SQL code that you can save
and reuse again and over.
So, if you have a SQL query that you create frequently, save it as a
stored procedure and then call it to run it.
You may also supply parameters to a stored procedure so that it can
act based on the value(s) of the parameter(s) given.

Stored Procedure Syntax

CREATE PROCEDURE procedure_name

AS

sql_statement

GO;

Execute a Stored Procedure

EXEC procedure_name;

Page 10 of 14
iNeuron Intelligence Pvt Ltd

Q16. What is Database Black Box Tes?ng?

Black Box Tes?ng is a somware tes?ng approach that involves tes?ng


the func?ons of somware applica?ons without knowing the internal
code structure, implementa?on details, or internal routes. Black Box
Tes?ng is a type of somware tes?ng that focuses on the input and
output of somware applica?ons and is totally driven by somware
requirements and specifica?ons. Behavioral tes?ng is another name
for it.

Q17. Where MyISAM table is stored?

Prior to the introduc?on of MySQL 5.5 in December 2009, MyISAM


was the default storage engine for MySQL rela?onal database
management system versions. It’s based on the older ISAM code, but
it comes with a lot of extra features. Each MyISAM table is split into
three files on disc (if it is not par??oned). The file names start with
the table name and end with an extension that indicates the file type.
The table defini?on is stored in a.frm file, however this file is not part
of the MyISAM engine; instead, it is part of the server. The data file’s
suffix is.MYD (MYData). The index file’s extension is.MYI (MYIndex). If
you lose your index file, you may always restore it by recrea?ng
indexes.

Page 11 of 14
iNeuron Intelligence Pvt Ltd

Q18. How to find the nth highest salary in SQL?

Ans- The most typical interview ques?on is to find the Nth highest
pay in a table. This work can be accomplished using the dense rank()
func?on.

Employee table

employee_name salary

A 24000

C 34000

D 55000

E 75000

F 21000

G 40000

H 50000

SELECT * FROM(

SELECT employee_name, salary, DENSE_RANK()

Page 12 of 14
iNeuron Intelligence Pvt Ltd

OVER(ORDER BY salary DESC)r FROM Employee)

WHERE r=&n;

To find to the 2nd highest salary set n = 2

To find 3rd highest salary set n = 3 and so on.

Q19. What do you mean by table and field in SQL?

A table refers to a collec?on of data in an organised manner in form


of rows and columns. A field refers to the number of columns in a
table. For example:

Table: StudentInforma?on

Field: Stu Id, Stu Name, Stu Marks

Page 13 of 14
iNeuron Intelligence Pvt Ltd

Q20. What is the difference between CHAR and VARCHAR2 datatype


in SQL?

Both Char and Varchar2 are used for characters datatype but varchar2
is used for character strings of variable length whereas Char is used for
strings of fixed length. For example, char(10) can only store 10
characters and will not be able to store a string of any other length
whereas varchar2(10) can store any length i.e 6,8,2 in this variable.

Page 14 of 14
iNeuron Intelligence Pvt Ltd

Q1. What is a Primary key?

• A Primary key in SQL is a column (or collec;on of columns) or a


set of columns that uniquely iden;fies each row in the table.
• Uniquely iden;fies a single row in the table
• Null values not allowed

Q2. What are Constraints?

Ans- Constraints in SQL are used to specify the limit on the data type
of the table. It can be specified while crea;ng or altering the table
statement. The sample of constraints are:

• NOT NULL
• CHECK
• DEFAULT
• UNIQUE
• PRIMARY KEY
• FOREIGN KEY

Q3. What is a Unique key?

Ans- Uniquely iden;fies a single row in the table.

• Mul;ple values allowed per table.


• Null values allowed.

Q4. What is a foreign key in SQL?

Page 2 of 10
iNeuron Intelligence Pvt Ltd

• Foreign key maintains referen;al integrity by enforcing a link


between the data in two tables.
• The foreign key in the child table references the primary key in
the parent table.
• The foreign key constraint prevents ac;ons that would destroy
links between the child and parent tables.

Q5. What do you mean by data integrity?

Ans- Data Integrity defines the accuracy as well as the consistency of


the data stored in a database. It also defines integrity constraints to
enforce business rules on the data when it is entered into an
applica;on or a database.

Q6. What is the difference between clustered and non-clustered index


in SQL?

Ans- The differences between the clustered and non-clustered index


in SQL are :

1. Clustered index is used for easy retrieval of data from the


database and its faster whereas reading from non- clustered
index is rela;vely slower.
2. Clustered index alters the way records are stored in a database
as it sorts out rows by the column which is set to be clustered
index whereas in a non-clustered index, it does not alter the way
it was stored but it creates a separate object within a table which
points back to the original table rows a`er searching.

Page 3 of 10
iNeuron Intelligence Pvt Ltd

3. One table can only have one clustered index whereas it can have
many non-clustered index.

Q7. Write a SQL query to display the current date?

Ans- In SQL, there is a built-in func;on called Get Date() which helps
to return the current ;mestamp/date.

Q8. What are En;;es and Rela;onships?

Ans- En;;es: A person, place, or thing in the real world about which
data can be stored in a database. Tables store data that represents one
type of en;ty. For example – A bank database has a customer table to
store customer informa;on. The customer table stores this
informa;on as a set of aeributes (columns within the table) for each
customer.

Rela;onships: Rela;on or links between en;;es that have something


to do with each other. For example – The customer name is related to
the customer account number and contact informa;on, which might
be in the same table. There can also be rela;onships between separate
tables (for example, customer to accounts).

Page 4 of 10
iNeuron Intelligence Pvt Ltd

Q9. What is an Index?

Ans- An index refers to a performance tuning method of allowing


faster retrieval of records from the table. An index creates an entry for
each value and hence it will be faster to retrieve data.

Q10. Explain different types of index in SQL.

Ans- There are three types of index in SQL namely:

Unique Index:

This index does not allow the field to have duplicate values if the
column is unique indexed. If a primary key is defined, a unique index
can be applied automa;cally.

Clustered Index:

This index reorders the physical order of the table and searches based
on the basis of key values. Each table can only have one clustered
index.

Non-Clustered Index:
Non-Clustered Index does not alter the physical order of the table and
maintains a logical order of the data. Each table can have many
nonclustered indexes.

Q11. What is Normaliza;on and what are the advantages of it?

Page 5 of 10
iNeuron Intelligence Pvt Ltd

Ans- Normaliza;on in SQL is the process of organizing data to avoid


duplica;on and redundancy. Some of the advantages are:

• Beeer Database organiza;on


• More Tables with smaller rows
• Efficient data access
• Greater Flexibility for Queries
• Quickly find the informa;on
• Easier to implement Security
• Allows easy modifica;on
• Reduc;on of redundant and duplicate data
• More Compact Database
• Ensure Consistent data a`er modifica;on

Q12. What is the difference between DROP and TRUNCATE


commands?

Ans- DROP command removes a table and it cannot be rolled back


from the database whereas TRUNCATE command removes all the rows
from the table.

What are the differences between OLTP and OLAP?

OLTP stands for online transaction processing, whereas


OLAP stands for online analytical processing. OLTP is an
online database modification system, whereas OLAP is an
online database query response system.

Page 6 of 10
iNeuron Intelligence Pvt Ltd

Q13. How to create empty tables with the same


structure as another table?

To create empty tables:

Using the INTO operator to fetch the records of one table


into a new table while setting a WHERE clause to false for all
entries, it is possible to create empty tables with the same
structure. As a result, SQL creates a new table with a
duplicate structure to accept the fetched entries, but
nothing is stored into the new table since the WHERE clause
is active.

Ans- There are many successive levels of normaliza;on. These are


called normal forms. Each consecu;ve normal form depends on the
previous one.The first three normal forms are usually adequate.

Normal Forms are used in database tables to remove or decrease


duplica;on. The following are the many forms:

First Normal Form:


When every aeribute in a rela;on is a single-valued aeribute, it is
said to be in first normal form. The first normal form is broken when
a rela;on has a composite or mul;-valued property.

Second Normal Form:

A rela;on is in second normal form if it meets the first normal form’s


requirements and does not contain any par;al dependencies. In 2NF,
a rela;on has no par;al dependence, which means it has no non-
prime aeribute that is dependent on any suitable subset of any table

Page 7 of 10
iNeuron Intelligence Pvt Ltd

candidate key. O`en, the problem may be solved by selng a single


column Primary Key.

Third Normal Form:


If a rela;on meets the requirements for the second normal form and
there is no transi;ve dependency, it is said to be in the third normal
form.

Q14. What is OLTP?

Ans- OLTP, or online transac;onal processing, allows huge groups of


people to execute massive amounts of database transac;ons in real
;me, usually via the internet. A database transac;on occurs when
data in a database is changed, inserted, deleted, or queried.

What are the differences between OLTP and OLAP?

OLTP stands for online transac;on processing, whereas OLAP stands


for online analy;cal processing. OLTP is an online database
modifica;on system, whereas OLAP is an online database query
response system.

Q15. How to create empty tables with the same structure as another
table?

Ans- To create empty tables:

Using the INTO operator to fetch the records of one table into a new
table while selng a WHERE clause to false for all entries, it is
possible to create empty tables with the same structure. As a result,

Page 8 of 10
iNeuron Intelligence Pvt Ltd

SQL creates a new table with a duplicate structure to accept the


fetched entries, but nothing is stored into the new table since the
WHERE clause is ac;ve.

Q16. What are SQL comments?

Ans- SQL Comments are used to clarify por;ons of SQL statements


and to prevent SQL statements from being executed. Comments are
quite important in many programming languages. The comments are
not supported by a Microso` Access database. As a result, the
Microso` Access database is used in the examples in Mozilla Firefox
and Microso` Edge.
Single Line Comments: It starts with two consecu;ve hyphens (–).
Mul;-line Comments: It starts with /* and ends with */.

Q17. What is the difference between the RANK () and DENSE_RANK ()


func;ons?

Ans- The RANK () func;on in the result set defines the rank of each
row within your ordered par;;on. If both rows have the same rank,
the next number in the ranking will be the previous rank plus a
number of duplicates. If we have three records at rank 4, for
example, the next level indicated is 7.

Page 9 of 10
iNeuron Intelligence Pvt Ltd

Q18. How to do a palindrome func;on in Python?

Ans- There are numerous ways to perform palindromes in Python.


We can do this using reverse and compare method, in-built method,
for loop, while loop, reverse and join, itera;ve loop and recursion
method.

Q19. How do you find a palindrome number?

Ans- Any number that runs back on itself or remains the same when
reversed is a palindrome number. For example, 16461, 11 and 12321.

Q20. What are the people who specialize in Python called?


1. Pythonic
2. Unpythonic
3. Monty Python
4. Pythoniasts
Answer. d. the people who specialize, or are great admirers of this
programming language are called as Pythoniasts. They are extremely
knowledgeable people.

Page 10 of 10
iNeuron Intelligence Pvt Ltd

Q1. What is the type of programming language supported by


Python?
1. Object-oriented
2. Functional programming
3. Structured programming
4. All of the above

Answer. d. Python is an interpreted programming language,


supporting object-oriented, structured, and functional programming.

Q2. When Python is dealing with identifiers, is it case sensitive?


1. Yes
2. No
3. Machine dependent
4. Can’t say
Answer. a. It is case sensitive.
Q72. What is the extension of the Python file?
1. .pl
2. .py
3. . python
4. .p
Answer. b. The correct extension of python is .py and can be written
in any text editor. We need to use the extension .py to save these
files.

Q3. All the keywords in Python are in_


1. Lower case
2. Upper case
3. Capitalized

Page 2 of 8
iNeuron Intelligence Pvt Ltd

4. None of the above


Answer. d. Only True, False and None are capitalized and all the
others in lower case.

Q4. What does pip mean in Python?


1. Unlimited length
2. All private members must have leading and trailing underscores
3. Preferred Installer Program
4. None of the above
Answer. c. Variable names can be of any length.

Q5. The built-in function in Python is:


1. Print ()
2. Seed ()
3. Sqrt ()
4. Factorial ()
Answer. a. The function seed is a function which is present in the
random module. The functions sqrt and factorial are a part of the
math module. The print function is a built-in function which prints a
value directly to the system output.

Q6. Which of the following definitions is the one for packages in


Python?
1. A set of main modules
2. A folder of python modules
3. Set of programs making use of python modules
4. Number of files containing python definitions and statements

Page 3 of 8
iNeuron Intelligence Pvt Ltd

Answer. b. A folder of python modules is called as package of


modules.

Q7. What is the order in which namespaces in Python looks for an


identifier?
1. First, the python searches for the built-in namespace, then the
global namespace and then the local namespace
2. Python first searches for the built-in namespace, then local and
finally the global namespace
3. Python first searches for local namespace, then global
namespace and finally the built-in namespace
4. Python searches for the global namespace, followed by the
local namespace and finally the built-in namespace.
Answer. C. Python first searches for the local namespace, followed by
the global and finally the built-in namespace.

Q8. Which of the following is not a keyword used in Python


language?
1. Pass
2. Eval
3. Assert
4. Nonlocal

Answer. b. Eval is used as a variable in Python.

Q9. Which of the following is the use of function in python?


1. Functions do not provide better modularity for applications
2. One can’t create our own functions
3. Functions are reusable pieces of programs

Page 4 of 8
iNeuron Intelligence Pvt Ltd

4. All of the above


Answer. c. Functions are reusable pieces of programs, which allow us
to give a name to a particular block of statements, allowing us to run
the block using the specified name anywhere in our program and any
number of times.

Q10. Which of the following is a feature of Python Doc String?


1. All functions should have a docstring in python
2. Doc Strings can be accessed by the _doc_ attribute on objects
3. This feature provides a very convenient way of associating
documentation with python modules, functions, classes and
methods
4. All of the above
Answer. d. Python has a nifty feature, which is referred to as the
documentation strings, usually referred to by its abbreviated name of
docstrings. They are important tools and one must use them as they
help document the program better along with making it easier to
understand.

Q11. Which of the following is the use of the function id() in python?
1. Every object does not have a unique id in Python
2. The id function in python returns the identity of the object
3. None
4. All
Answer. b. Every function in Python has a unique id. The id() function
helps return the id of the object

Page 5 of 8
iNeuron Intelligence Pvt Ltd

Q12. What is the function of pickling in python?


1. Conversion of a python object
2. Conversion of database into list
3. Conversion of byte stream into python object hierarchy
4. Conversion of list into database
Answer. a. The process of pickling refers to sterilizing a Python object,
which means converting a byte stream into python object hierarchy.
The process which is the opposite of pickling is called unpickling.

Q13. What is Python code-compiled or interpreted?


1. The code is both compiled and interpreted
2. Neither compiled nor interpreted
3. Only compiled
4. Only interpreted
Answer. b. There are a lot of languages which have been
implemented using both compilers and interpreters, including C,
Pascal, as well as python.

Q14. The abs function returns the


a) The absolute value of the specific number
b) The average value of some numbers
c) Mean value for the list of numbers
d)None of the above

Answer
a) The absolute value of a specified number

Page 6 of 8
iNeuron Intelligence Pvt Ltd

Q15. The output of bool(‘’) will return


a) True
b) False
c) Error
d) Nan

Answer
a)True

Q16. For the given program


def mul(x):
print(3*x)
if we call the function like mul(“ Hello”) the output should be

a) Hello^3
b) Hello Hello Hello
c) Error
d) None of the above

Answer
Hello Hello Hello

Q17. Parameters of a function can be defined


a) During the function creation
b) During the function calling
c)To find the bug in a function
d)None of the above

Answer
a) During function creation

Page 7 of 8
iNeuron Intelligence Pvt Ltd

Q18. What is MySQL?


MySQL is a Relational Database Management System (RDMS) such as
SQL Server, Informix, etc., and uses SQL as the standard database
language. It is open-source software backed by Oracle and used to
deploy cloud-native applications using an opensource database.

Q19. What is a Database?


It is the structured form of data stored in a well-organized manner
that can be accessed and manipulated in different ways. The
database is based on the collection of schemas, tables, queries, and
views. In order to interact with the database, different database
management systems are used. MySQL is used in WordPress and
gives you the option to create a MySQL database and its User with
the help of a control panel (cPanel).

Q20. Can you explain tables and fields?


The table is the set of organized data stored in columns and rows.
Each database table has a specified number of columns known as
fields and several rows which are called records. For example:

Table: Student

Field: Std ID, Std Name, Date of Birth

Data: 23012, William, 10/11/1989

Page 8 of 8
iNeuron Intelligence Pvt Ltd

Q1. What is the primary key?


The primary key is the combination of fields based on implicit NOT
NULL constraint that is used to specify a row uniquely. A table can
have only one primary key that can never be the NULL.

Q2. What is a unique key?


The unique key is the group of one or more fields or columns that
uniquely identifies the database record. The unique key is the same
as a primary key but it accepts the null value.

Q3. What is a foreign key?


The foreign key is used to link two tables together and it is a field that
refers to the primary key of another table.

Q4. What is a join?


As the name indicates, join is the name of combining columns from
one or several tables by using common values to each. Whenever the
joins are used, the keys play a vital role.

Q5. What are the types of join and explain each?

Depending on the relationship between tables, join has the following


types:

Inner Join
It returns rows when there is at least one match of rows between the
tables.

Right Join
It returns the common rows between the tables and all rows of the
Right-hand side table. In other words, it returns all the rows from the

Page 2 of 8
iNeuron Intelligence Pvt Ltd

right-hand side table even there is no matches in the left-hand side


table.

Left Join
It returns the common rows between the tables and all rows of the
left-hand side table. In other words, it returns all the rows from the
left-hand side table even there are no matches in the right-hand side
table.

Full Join
As the name indicates, full join returns rows when there are
matching rows in any one of the tables. It combines the results of
both left and right table records and it can return very large result-
sets.

Q6. What is normalization?


Normalization is the process of organizing fields into a related table
for increasing integrity and removing redundancy in order to improve
the performance of the query. The main aim of the normalization is
to add, delete, or modify the fields that can be made in a single table.

Q7. What is Denormalization.


It is a technique in which data from higher to lower normal forms
accessed and it also used to add redundant data to one or more
tables.

Q8. What are all the different normalizations?


Following are the different normalization forms:

Page 3 of 8
iNeuron Intelligence Pvt Ltd

First Normal Form (1NF):


It is the process of removing all the duplicate columns from the table
and ensuring that each cell contains only one piece of information. In
the first normal form, there are only atomic values without any
repeating groups.

Second Normal Form (2NF):


A relation is in 2NF if it satisfies the first normal form and does not
contain any partial dependency. Moreover, make sure the non-key
attributes are fully functional dependent on the primary key.

Third Normal Form (3NF):


Remove the columns that are not dependent on primary key
constraints and make sure it meets all the requirements of the
second normal form.

Fourth Normal Form (4NF):


It should not have multi-valued dependencies and meet all the
requirements of the third normal form.

It depends on the interviewers, they can only ask a single form of


normalization or all in their SQL interview questions.

9. What is a View?
The view is a virtual table that consists of the subset of data
contained in a table and takes less space to store. It can have data
from multiple tables depending on the relationship.

10. What is an Index?

Page 4 of 8
iNeuron Intelligence Pvt Ltd

The index is the method of creating an entry for each value in order
to retrieve the records from the table faster. It is a valuable
performance tuning method used for faster retrievals.

11. What are all the different types of indexes?


There are three types of indexes:

Unique Index
The unique index ensures the index key column has unique values
and it applies automatically if the primary key is defined. In case, the
unique index has multiple columns then the combination of values in
these columns should be unique.

Clustered Index
Clustered index reorders the physical order of a table and searches
based on its key values. Keep in mind, each table can have only one
clustered index.

Non-Clustered Index
Non-Clustered Index does not alter the physical order but maintains a
logical order of table data. Each table in the non-clustered index can
have 999 indexes.

12. What is a Cursor?


Cursor is known as the control of the database that enables traversal
over the rows in the table. It is very useful tool for different
operations such as retrieval, addition, and removal of database
records. You can view the cursor as a pointer to one row in a set of
rows.

Page 5 of 8
iNeuron Intelligence Pvt Ltd

13. What is a database relationship and what are they?


The database relationship is the connection between the tables of
any particular database. Following are the main types of
relationships:

One to One Relationship


One to Many Relationship
Many to One Relationship
Self-Referencing Relationship

14. What is a query?


The database query is the name of getting information back from the
database with the help of coding. We can get expected results from
the database without wasting our valuable time because the query
gives us output within a short-time period.

15. What is subquery?


As the name indicates, it is also a query but used in another query.
The outer query is known as the main query and the inner query is
called a subquery. The subquery will be executed first and pass the
results to the main query then the output of both queries will be
displayed.

16. What are the types of subquery?


Correlated and non-correlated are the types of subquery where the
non-correlated query is considered an independent query and
correlated is treated as a dependent query.

Page 6 of 8
iNeuron Intelligence Pvt Ltd

17. Enlist the name of different subsets of SQL?


There are four subsets of SQL:

DDL (Data Definition Language)


DML (Data Manipulation Language)
DCL (Data Control Language)
TCL (Transaction Control Language)

18. Explain DDL with its examples?


As the name indicates, Data Definition Language (DDL) is used to
define the structure of data, table, schema, and modify it. For
example:

CREATE: is used to create tables, databases, schema, etc.


DROP: is used to drop/remove tables and other database objects.
ALTER: is used to alter or change the definition of database objects.
TRUNCATE: is used to remove tables, procedures, and other database
objects.
ADD COLUMN: is used to add any column to table schema.
DROP COLUMN: is used to drop a column from any database table
structure.

19. Explain DML with its examples?


DML (Data Manipulation Language) is a computer programming
language is used for the addition (insertion), deletion and
modification of data in the database. For example:

SELECT INTO: is used to select data from one table and insert into
another table.

Page 7 of 8
iNeuron Intelligence Pvt Ltd

INSERT: is used to insert data or records into a table.


DELETE: is used to delete records from any database table.
UPDATE: is used to update the values of different records in the
database.

20. Explain DCL with its examples?


DCL (Data Control Language) deals with the access rights and
permission control of the database.

GRANT command is used to grant access rights to database objects.


REVOKE is used to withdraw permission from database objects.

Page 8 of 8
iNeuron Intelligence Pvt Ltd

1. Explain TCL with its examples?


TCL (Transaction Control Language) is a set of commands used to
perform a specific task on objects in a single unit of execution. In
simple words, TCL commands deal with transactions in a database.
For example:

COMMIT: is used to commit transactions. Once a commit is made it


cannot be rolled back, so the previous image of the database cannot
be retrieved before running this transaction.
ROLLBACK: is used to revert the steps in transactions if an error
arises.
SAVEPOINT: is used to set the savepoint in the transaction to which
steps can be rolled back.
SET TRANSACTION: is used to set characteristics of the transaction.

2. Write a SQL query to display the current date?


Following SQL query is used to return the database system date and
time:

SELECT GETDATE();

This type of short queries are asked in the SQL interview questions so
that they can understand about the candidate’s knowledge and
hands-on experience.

3. What is a stored procedure?


It is a subroutine available to applications that need to access a
relational database management system (RDBMS). These procedures
are stored in the data dictionary and only executed in the database
which is considered a big disadvantage because it occupies more

Page 2 of 7
iNeuron Intelligence Pvt Ltd

memory in the database server. Moreover, it provides security and


functionality to those users who are unable to access data directly, so
they can be granted access via stored procedures.

4. What is a trigger?
A database trigger is a code or program that helps to maintain the
integrity of the database. It automatically executes the response to
particular events on a table in the database.

For example, when a new employee is added to the employee


database, new records should be created in the related tables like
Salary, Attendance, and Bonus tables.

5. What is the difference between DELETE and TRUNCATE


commands?
TRUNCATE command removes all the table rows permanently that
can never be rolled back. DELETE command is also used to remove
the rows from the table but commit and rollback can be performed
after the deletion. Moreover, the WHERE clause is also used as
conditional parameters.

6. What is the main difference between local and global variables?


As the name indicates, the local variables can be used inside the
function but global ones are used throughout the program. Local
variables are only limited to the function and cannot be referred or
used with other functions.

7. What is a constraint and what are the common SQL constraints?

Page 3 of 7
iNeuron Intelligence Pvt Ltd

SQL constraint is used to specify the rules for data in a table and can
be specified while creating or altering the table statement. The
following are the most widely used constraints:

NOT NULL
CHECK
DEFAULT
UNIQUE
PRIMARY KEY
FOREIGN KEY

8. What is Data Integrity?


Data integrity is the overall accuracy, completeness, and consistency
of data stored in a database. For example, in order to maintain data
integrity, the numeric columns/sells should not accept alphabetic
data.

9. What is Auto Increment?


Auto increment allows the users to create a unique number to be
generated whenever a new record is inserted into the table. It helps
to keep the primary key unique for each row or record. If you are
using Oracle then AUTO INCREMENT keyword should be used
otherwise use the IDENTITY keyword in the case of the SQL Server.

10. What is the difference between the Cluster and Non-Cluster


Index?
The clustered index defines the order in which data is physically
stored in a database table and used for easy retrieval by altering the
way that the records are stored.

Page 4 of 7
iNeuron Intelligence Pvt Ltd

The non-clustered index improves the speed of data retrieval from


database tables but stores data separately from the data rows. It
makes a copy of selected columns of data with the links to the
associated table.

11. What is Datawarehouse?


It is the name of a central repository of data from multiple
information sources for analytics and business intelligence activities.
Datawarehouse has an enterprise-wide depth and based on its
subsets called data marts which are oriented to a specific business
line or team.

12. What is Self-Join?


A self-join SQL query is used to compare to itself and values in a
column are compared with other values in the same column in the
same database table.

13. What is Cross-Join?


Cross-join is used to generate a paired combination of each row of
table A with each row of table B. If the WHERE clause is used in cross
join then the SQL query will work like an INNER JOIN.

14. What is user-defined functions?


Like functions in programming languages, SQL user-defined functions
are routines or functions that accept parameters, perform an action,
such as a complex calculation, and return the output of that
particular action as a value. There is no need to write the same logic
several times because the function can be called whenever needed.

15. What are all types of user-defined functions?

Page 5 of 7
iNeuron Intelligence Pvt Ltd

Following are the user-defined functions:

Scalar Functions that return the unit or single-valued results


Inline Table-valued functions that return table as a return
Multi statement valued functions that return table as a return

16. What is collation?


Collation provides a set of rules that determine how character data
can be sorted and compared in a database. It also provides the case
and accent sensitivity properties. Collation is used to compare A and
other language characters with the help of ASCII value.

17. What are all different types of collation sensitivity?


Following are the different types of collation sensitivity:

Case Sensitivity (A & a, B & b or any other uppercase and lowercase


letters)
Accent Sensitivity
Kana Sensitivity (Japanese Kana characters)
Width Sensitivity (Single byte character (half-width) & same
character represented as a double-byte character)

18. What are the pros and cons of Stored Procedure?


The stored procedure is based on modular programming that means
create once, store and call several times whenever you need it. It
supports faster execution and reduces the network traffic for
optimum performance.

Page 6 of 7
iNeuron Intelligence Pvt Ltd

The main disadvantage of stored procedure is that it executed only in


the database and utilized more memory.

19. What is Online Transaction Processing (OLTP)?

As the name indicates, Online Transaction Processing (OLTP) is used


to manage transaction-based applications that can be used for data
entry, retrieval, and processing. It makes data management simple
and efficient that is the reason why bank transactions are using OLTP.
You can view an insight into the working of an OLTP system.

20. Define COMMIT.


COMMIT command is used to save all the transactions to the
database since the last COMMIT or ROLLBACK command where a
transaction is a unit of work performed against any database.

Here is the syntax of COMMIT command:

COMMIT;

Consider an example of the deletion of those records which have age


= 25 and then COMMIT the changes in the database.

SQL> DELETE FROM CUSTOMERS

WHERE AGE = 25;

SQL> COMMIT;

Page 7 of 7
iNeuron Intelligence Pvt Ltd

1. What is CLAUSE?
SQL clause is used to filter some rows from the whole set of records
with the help of different conditional statements. For example,
WHERE and HAVING conditions.

2. What is the difference between null, zero and blank space?


Null is neither same as zero nor blank space because it represents a
value that is unavailable, unknown, or not applicable at the moment.
Whereas zero is a number and blank space belongs to characters.

3. What is a recursive stored procedure?


It is the same as stored procedures but it calls by itself until it reaches
any boundary condition. So, it is the main reason why programmers
use recursive stored procedures to repeat their code any number of
times.

4. What is Union, minus and Intersect commands?


Union operator is used to combining the results of two tables and
removes the duplicate rows. Minus is used to return matching
records of the first and second queries and other rows from the first
query but not by the second one. The Intersect operator is used to
return the common rows returned by the two select statements.

5. What is an ALIAS command?


ALIAS name can be given to a column or table and referred in WHERE
clause to identify the column or table. Alias column syntax:

SELECT column_name AS alias_name

FROM table_name;

Page 2 of 8
iNeuron Intelligence Pvt Ltd

6. What are aggregate and scalar functions?


The aggregate function performs mathematical calculations against a
collection of values and returns a single summarizing value. The
scalar function returns a single value based on the input value.

7. How can you create an empty table from an existing table?


With the help of the following command, we can create an empty
table from an existing table with the same structure with no rows
copied:

Select * into copytable from student where 1=2

8. How to fetch common records from two tables?


Common records can be achieved by the following command:

Select studID from student INTERSECT Select StudID from Exam

59. How to fetch alternate records from a table?


Records can be fetched for both Odd and Even row numbers with the
following commands:

For even numbers:

Select studentId from (Select rownum, studentId from student)


where mod(rowno,2)=0

For odd numbers:

Select studentId from (Select rownum, studentId from student)


where mod(rowno,2)=1

Page 3 of 8
iNeuron Intelligence Pvt Ltd

10. How to select unique records from a table?


Apply the following SQL query to select unique records from any
table:

Select DISTINCT StudentID, StudentName from Student

11. What is the command used to fetch first 4 characters of the


string?
Following are the ways to fetch the first 4 characters of the string:

Select SUBSTRING(StudentName,1,4) as studentname from student


Select LEFT(Studentname,4) as studentname from student

12. What is a composite primary key?


The primary key that is created on more than one column is known
as composite primary key.

13. Which operator is used in query for pattern matching?


LIKE operator is used for pattern matching.

% (percent sign) Matches zero or more characters and _ (Underscore)


is used for matching exactly one character. For example:

Select * from Student where studentname like ‘m%’


Select * from Student where studentname like ‘meh_’
What do you mean by ROWID?
ROWID is an 18-character long pseudo column attached with each
row of a database table.

Page 4 of 8
iNeuron Intelligence Pvt Ltd

14. What are Entities and Relationships?


The entity is the name of real-world objects either tangible or
intangible and it is the key element of relational databases. For a
database entity, workflow and tables are optional but properties are
necessary. For example: In the database of any institute, students,
professors, workers, departments and projects can be known as
entities. Each entity has associated properties that offer it an identity.

The relationship is the name of links or relations between entities


that have something to do with each other. For example, the
employee table should be associated with the salary table in the
company’s database.

15. What are STUFF and REPLACE functions?


STUFF Function is used to insert a string into another string or
overwrite existing characters.

Syntax:

STUFF(string_expression,start, length, replacement_characters)


REPLACE function is used to replace any existing characters of all the
occurrences.

Syntax:

REPLACE (string_expression, search_string, replacement_string)

Page 5 of 8
iNeuron Intelligence Pvt Ltd

16. What are GROUP functions and give some examples?


Group functions are mathematical functions used to work on the set
of rows and return one result per group. AVG, COUNT, SUM,
VARIANCE, MAX, MIN are most commonly used Group functions.

17. What is the MERGE statement?


MERGE statement is used to combine insert, delete and update
operations into one statement. It is also used to synchronize two
tables and make the changes in one table based on values matched
from another.

18. What are the different case manipulation functions in SQL?


Following are the case manipulation functions in SQL:

LOWER: This function takes a string as an argument and returns it by


converting it into the lowercase string.
Syntax:

LOWER(‘string’)

UPPER: This function takes a string as an argument and returns it into


uppercase string. Syntax:
UPPER(‘string’)

INITCAP: This function returns the string with the first letter in
uppercase and others in lowercase.
Syntax:

INITCAP(‘string’)

19. What are the character manipulation functions?

Page 6 of 8
iNeuron Intelligence Pvt Ltd

Character-Manipulative Functions

1. CONCAT: This function is used to append or concatenate string2 to


the end of string1.

Syntax:

CONCAT(‘String1’, ‘String2’)

2. LENGTH : This function returns the total length of the input string
used.

Syntax:

LENGTH(Column|Expression)

3. SUBSTR : This function will return a portion of a string from any


given start point to an endpoint.

Syntax:

SUBSTR(‘String’,start-index,length_of_extracted_string)

4. INSTR : This function used to return numeric position of a


character (or a string) in any given string.

Syntax:

INSTR(Column|Expression, ‘String’, [,m], [n])

Page 7 of 8
iNeuron Intelligence Pvt Ltd

5. LPAD and RPAD: LPAD returns the strings padded to the left and
RPAD to the right (as per the use.

Syntax:

LPAD(Column|Expression, n, ‘String’)

Syntax:

RPAD(Column|Expression, n, ‘String’)

6.TRIM : This function is used to trim the string input from the start
or end (or both).

Syntax:

TRIM(Leading|Trailing|Both, trim_character FROM trim_source)

7. REPLACE : As the name indicates the REPLACE function searches


for a character string and, if found, replaces it with a given
replacement string at all the occurrences.

Syntax:

REPLACE(Text, search_string, replacement_string)

20. What is a shared lock?


Shared lock doesn’t cause much problems and occurs when the
object needs to be read. It comes when two transactions are granted
and read access. There is no conflict because noting is being updated
due to read-only mode of both transactions.

Page 8 of 8
iNeuron Intelligence Pvt Ltd

1. What is a deadlock?
A deadlock situation is created when two processes are competing
for the access to a resource but unable to obtain because the other
process is preventing it. So, the process cannot proceed until one of
the processes to be terminated.

For example: Process A locks the Table A and process B locks the
Table B. Now the process A requests the Table B and waiting for it
and Process B is also waiting for Table A.

2. What is lock escalation?


Lock escalation is an optimization technique used to convert many
fine-grained locks such as row or page locks into table locks for
handling the large updates. SQL Server is using row-level locking by
default, so it is easier to convert a large number of row locks into a
single table lock for optimum results.

3. Does View contain Data?


No, because views are virtual structures.

4. What is CTE?
Common Table Expression (CTE) is an expression that contains
temporary results defined in a SQL statement.

5. What are aggregate functions used for?


Aggregate functions are used to perform a calculation on one or
more values, and returns a single value of more meaningful
information.

Page 2 of 10
iNeuron Intelligence Pvt Ltd

Some aggregate functions are COUNT(), SUM(), MAX(), MIN(), AVG(),


and ROUND().

6. What is a join?
A join is a way to combine rows from two or more tables, based on a
related column between them.

7. What is the difference between an INNER JOIN and LEFT JOIN?


An INNER JOIN is used to include combined rows from two tables
that match the ON condition. The final result does not include rows
with no match for the ON condition.

A LEFT JOIN is used to keep all rows from the first table, regardless of
whether there is a matching row in the second table for the ON
condition.

8. What is the purpose of windows functions?


Windows functions are used when you want to maintain the values
of your original table while displaying grouped or summative
information alongside. It is similar to aggregate functions, but does
not reduce the number of rows in the result by combining or
grouping them into a few result.

9. What are indexes and why are they needed?


Indexes are a powerful tool used in the background of a database to
speed up querying, by acting as a lookup table for data.

Page 3 of 10
iNeuron Intelligence Pvt Ltd

They are needed to efficiently store data for quicker retrieval, which
can be paramount to the success of large tech companies which need
to process on the scale of petabytes of data each day.

10. What is PL/SQL?


The Procedural Language/Structured Query Language is a
programming language used to create, manage and manipulate
Oracle database objects. It provides powerful procedural control of
the data stored in an Oracle Database, including triggers, procedures,
functions, and packages. In addition, it offers many features not
available with regular SQL, such as explicit cursor handling for
iterative processing, error trapping capability, and support for object-
oriented programming extensions.

11. Explain the features of PL/SQL?


Features of PL/SQL:

It supports both SQL(Structured Query Language) & DML (Data


Manipulation commands).
Easy integration with web technology like HTML & XML via
embedded call interface or external procedure feature.
Error Handling mechanism helps in the debugging process, i.e.,
identify code errors quickly.
Allows execution of complex business logic by means of user-defined
functions without giving access to the table structure itself.
Supports package concept that enables developers separate
functionality into a logical group.
Supports Procedural Programming Paradigm – conditional
statements, loops, iteration, etc.
PL/SQL Features

Page 4 of 10
iNeuron Intelligence Pvt Ltd

12. What are the advantages of the PL/SQL in points?


Advantages of PL/SQL:

It is faster than other conventional programming languages.


Simplified Application Development as it supports procedural,
functional, and object-oriented Programming approaches.
Secure Access Management: It allows better control of data changes
with the help of privileges, constraints & triggers.
Enhanced Productivity due to advanced features like Object Oriented
capabilities debugging support etc.

13. Explain the structure of the PL/SQL?


PL/SQL is a procedural language extension of SQL. It has a block
structure that allows you to write programs with multiple executable
statements within it. A basic PL/SQL code block consists of three
sections:

DECLARE: This section includes variables, constants, and cursors


declarations for use in the program

BEGIN-END: This optional section includes any additional executable


statements required by the application logic.

EXCEPTION: Include exception-handling routines which help manage


errors during execution time.

PL/SQL supports the following statements:

• If-Then-Else

Page 5 of 10
iNeuron Intelligence Pvt Ltd

• While Loop

• For Loop

• GOTO

• Cursor Handling Statements

• DECLARE: Declare variables, constants, and cursors

•Fetch records from a result set driven by a cursor

•Exception handling

•Anonymous PL/SQL Blocks

•Triggers & Procedures

•Package variables & functions

Structure of PL/SQL

14. Explain the PL/SQL cursor and its types.


A PL/SQL cursor is a memory pointer that directs the user to a region
in memory where SQL statements and data related to statement
processing are stored. To retrieve and analyze many rows, this
section uses a unique feature called a cursor.
The cursor selects numerous rows from the database, and these
picked rows are independently handled within a program.

Page 6 of 10
iNeuron Intelligence Pvt Ltd

There are two types of Cursors:

Implicit Cursor: When invoking any of the implicit cursor commands


SELECT INTO, INSERT, DELETE, or UPDATE, Oracle automatically
constructs a cursor.
These cursors' execution cycles are managed internally by Oracle,
which uses the cursor properties ROWCOUNT, ISOPEN, FOUND, and
NOTFOUND to return information about the cursor's information and
state.
Explicit Cursor: A SELECT statement that was expressly declared in
the declaration block makes up this cursor. The cycle of these cursors'
execution, from OPEN through FETCH and closure, must be managed
by the programmer. Oracle also assigns a cursor to the SQL statement
and defines the execution cycle during SQL statement execution.
Cursors in PL/SQL

15. How to create and use user-defined exceptions in PL/SQL?


User-defined exceptions in PL/SQL allow developers to create custom
exception handling for their applications. They can be defined using
the EXCEPTION statement and raised with the RAISE statement. Once
created, these user-defined exceptions can be caught within a code
block using an exception handler containing WHEN clauses (for
expected errors) and other statements for unexpected errors or
conditions. The code then handles the error gracefully or allows it to
propagate further.

16. What are the different cursor attributes in PL/SQL?


In PL/SQL, a cursor is an interface for retrieving and processing data
from the database. Cursor attributes are used to manage cursors in
Oracle databases. Cursor attributes give information about the
execution states of SQL statements or the conditions that affect the

Page 7 of 10
iNeuron Intelligence Pvt Ltd

execution of these statements within PL/SQL blocks. Some common


cursor attributes in PL/SQL include %FOUND, %NOTFOUND,
%ROWCOUNT, and %ISOPEN.

The first two (found and not found) indicate whether a SELECT
statement successfully retrieved records as part of an explicit or
implicit cursor declaration;
rowcount indicates how many rows have been selected so far;
If ISOPEN returns TRUE if a corresponding query has not yet been
executed until its end or else FALSE if it already has ended with no
more rows being available for selection from now on.

17. How can we manipulate data stored within database tables using
SQL blocks in PL/SQL?
SQL blocks are sections of code in PL/SQL that allow developers to
create, delete, update, and manipulate data stored within database
tables. Using SQL blocks in PL/SQL offers a powerful way for
developers to interact with their databases programmatically by
executing standard Structured Query Language (SQL) commands.

This includes common operations like creating new records,


modifying existing ones, or deleting certain records from the table
entirely, and more complex queries such as searching for particular
values or joining multiple tables into one meaningful result set.

Developers can also execute stored procedures using SQL statement


execution within an Oracle block and take advantage of various
features like transaction control statements (COMMIT & ROLLBACK),
parameter substitution variables, and special functions provided by
the RDBMS.

Page 8 of 10
iNeuron Intelligence Pvt Ltd

18. What is the appropriate way to declare and define temporary


tables in PL/SQL?
In PL/SQL, temporary tables can be declared and defined by first
using the CREATE GLOBAL TEMPORARY statement, which creates a
new object in the system catalog views that persists until explicitly
dropped.

After this, information is inserted into this table from permanent or


temporary (or global) sources like another query result set, SELECT
statements, or INSERT values clauses. Developers may also use the
ON COMMIT PRESERVE ROWS clause to ensure any data loaded into
these temp-tables is not cleared after each commit operation
happens on its parent session defining it.

Finally, once all needed operations have been completed with these
objects, they must drop them properly with DROP TABLE syntax for
cleanliness and resource efficiency.

19. What precautions should be taken to deal with runtime errors


encountered when running a code snippet in PL/SQL?
When running a code snippet written in PL/SQL, runtime errors may
arise and cause the program to crash or behave unexpectedly. To
prevent this, developers must take some precautions when coding
their logic.

First of all, they should use proper error handling techniques like
using try-catch blocks and exception handlers where appropriate;
also, consider explicit transactions management statements such as
COMMIT & ROLLBACK for data integrity if modifying records directly
within database tables;

Page 9 of 10
iNeuron Intelligence Pvt Ltd

frequently test both during development by stepping through


instructions one line at a time;
pay attention to any suspicious messages or warnings Oracle’s engine
provides while debugging, preferably including specific IDs clearly
shown near each issue.

20. What is a database server, and how is it used in PL/SQL?


A computer system known as a database server processes and saves
data from one or more databases. In PL/SQL, the database server is a
fundamental component to process SQL commands sent via
application programs to store and retrieve data.

The primary functions of the database server include managing


connections between clients and databases, processing user requests
for information retrieval by translating them into queries acceptable
by relational databases, executing those queries on behalf of
connected clients, returning results to requesting applications,
ensuring successful transaction commits when requested, etc.

Database Server in PL/SQL.

Page 10 of 10
iNeuron Intelligence Pvt Ltd

1. How do you handle table errors in PL/SQL programming?


Table errors can occur in PL/SQL programming when a table
requested by the application program does not exist or has incorrect
column types.

In such cases, an exception must be handled to inform users of an


error in processing their request. This is possible because of the
Exception managing the design of PL/SQL, which has predefined
exceptions for various types of problems like 'NO_DATA_FOUND' and
'TOO_MANY_ROWS' for managing unusual data retrieval cases.

If required, specific user-defined exceptions can also be written


inside the application programs to handle those specific table errors
and any other type of Exceptions.

2. What types of exceptions can be encountered while working with


PL/SQL programs?
Any programming language, including PL/SQL, must provide
exception management. Exceptions are runtime errors that can occur
during the execution of a program and cause unexpected results or
terminate the processing.

In PL/SQL, there are both predefined and user-defined exceptions,


which help handle various error conditions gracefully during runtime.
The different types of Predefined Exceptions in PL/SQL include
NO_DATA_FOUND, TOO_MANY_ROWS, DUPE_VAL _ON _INDEX, etc.

In contrast, User Defined Exceptions can be written as required inside


application programs to handle specific scenarios effectively by
raising one’s custom exception messages (using the raise statement).

Page 2 of 12
iNeuron Intelligence Pvt Ltd

Exception Handling in PL/SQL

3. Describe the compilation process for a PL/SQL program?


The compilation process for a PL/SQL program involves converting
SQL and PL/SQL code into an executable format that the Oracle
Database can interpret. This is done with the help of the SQL*Plus
command-line interface, which first parses and translates all source
code statements, checks syntax errors (if any), and resolves schema
objects like tables & views referenced in query statements to their
respective base address before finally creating a database procedure
context from within which it executes those instructions.

4. List various schema objects associated with SQL tables in PL/SQL?


In PL/SQL, various schema objects are associated with SQL tables
used to define database structure and the interaction between
different queries in an application program. These include:

1. Tables - Tables are collections of connected data items made up of


rows and columns that include details about a specific subject or
entity;

2. Views - A view is a virtual table containing data from one or


multiple tables;

3. Sequences - Sequences generate unique numerical values


automatically whenever required;

4. Indexes – An index helps improve query performance by providing


quick access to specific records within large datasets;

Page 3 of 12
iNeuron Intelligence Pvt Ltd

5. Synonyms - Synonyms act as aliases for schema objects like tables


& views to be referenced using more structured naming conventions
without repeating their underlying structures across applications
programs repeatedly each time they need fetching from databases at
runtime.

6. Stored Procedures - Stored procedures contain PL/SQL code blocks


that execute predefined tasks on behalf of application programs,
making them easier to maintain centrally rather than repeating
similar sections in all related client programs independently.

7. Triggers – Triggers react dynamically based on defined events


inside databases, like before update, after insert etc., allowing
developers to write custom code for processing complex operations.

8. Packages – Packages contain predefined procedures and functions


that provide abstracted access to underlying data structures (like
tables & views).

It is easier to use the same Table/View structure in multiple


applications programs without having to repeat its definitions
repeated each time a query needs to run against those objects from
within any given application or program.

Schema objects associated with SQL tables in PL/SQL

5. What is the syntax for creating a SQL table in PL/SQL?


The syntax for creating a SQL table in PL/SQL involves using the
CREATE TABLE statement, which requires specifying an optional list of

Page 4 of 12
iNeuron Intelligence Pvt Ltd

column definitions and other necessary parameters. Generally, this is


done by providing details like name, data type to be used (e.g., text,
number, etc.), size if applicable, and any default constraints that need
setting up before actual row data can be added to those tables.

For example:
CREATE TABLE myTableName(id INTEGER PRIMARY KEY NOT NULL,
name VARCHAR2(50) DEFAULT 'John Doe');

In this example, "myTableName" is the new Table being defined


internally inside the Oracle database having two columns named id &
Names, both conforming to predefined types 'INTEGER' &
'VARCHAR2' respectively.

Syntax for creating a SQL table in PL/SQL

6. What is a Rollback statement in PL/SQL?


A PL/SQL command known as a rollback statement is used to undo
database changes that have been made since the last commit or
rollback was executed. It undoes all transactions that have been
completed in the current session by reverting any data changes and
returning to its prior state. This statement is commonly used to undo
any unintentional changes or incorrect transactions that users may
have committed.

Rollback statement in PL/SQL

7. How do you write a block of statements in PL/SQL?


A block of statements in PL/SQL is a set of SQL or PL/SQL commands
grouped to execute as a single unit. A basic structure for writing

Page 5 of 12
iNeuron Intelligence Pvt Ltd

blocks of statements consists of declarations, an execution section,


an exception-handling section and an optional end statement.

Declarations can include variable definitions, which must be on the


first line followed by BEGIN keyword; this is followed by one or more
lines with executable statements within it such as SELECT, INSERT
etc.;

finally, any exceptions should be handled so the process completes


successfully, without errors using EXCEPTION keyword before ending
the block with END keyword.

8. What are the record-type statements available in PL/SQL?


Record-type statements in PL/SQL store data from database tables or
other queries as a set of related elements. These statements provide
the ability to process multiple values simultaneously instead of
looping through each row individually.

The four record types in PL/SQL are CURSOR, RECORD, TABLE, and
%ROWTYPE.

Cursor is a special type that enables users to iterate the results set
multiple times;
Record allows access to individual columns within rows contained by
query results;
Table can hold one or more records for further operations such as
sorting and selection;
%ROWTYPE provides variable declarations which contain all fields
from an associated table automatically populated with their
corresponding values upon execution against it.

Page 6 of 12
iNeuron Intelligence Pvt Ltd

9. How to create and use database links in different schemas using


PL/SQL programs?
Creating and using database links in different schemas using PL/SQL
programs is a process that allows users to access or identify remote
databases from their local ones. It enables distributed queries,
transactions, and heterogeneous system integration by allowing data
to be accessed across platforms or between networks for
applications such as replication and migration.

To create a link, use the CREATE DATABASE LINK command followed


by the name of the link being defined; then specify information
regarding the target hostname (if applicable) along with its username
and password credentials if required before concluding statement
execution.

Create database links in different schemas using PL/SQL programs

10. How can one identify common errors while executing a set of
commands using the syntaxes within a program unit defined by
declarative sections, executable sections, exception handling
sections, etc.?
Common errors while executing a set of commands written using the
PL/SQL syntax in a program unit can be identified by understanding
its structure and meaning.

To identify common errors,

users must review each line within these sections and verify their
correctness with regard to data type definitions associated with
existing parameters, including formal ones.;

Page 7 of 12
iNeuron Intelligence Pvt Ltd

this is also applicable when dealing with scalar datatypes for column
values for tables, plus checking if correct table names have been
specified, among other details and specific requirements stated
beforehand, including trigger declarations, etc.
These steps will help determine where mistakes might exist, allowing
issues to be addressed promptly, correcting them during the
development phase itself, and preventing actual code production
failures from occurring later on due to rigorous testing and earlier
assessments undertaken before submission into the system
environment.

11. Explain the concept of formal parameters used for passing data
within subprograms written with reference to procedures and
functions supported by PLSQL language?
Formal parameters are used for passing data within subprograms
written using PL/SQL. They typically consist of two parts: an
argument name and a default value (if applicable).

The argument name is used to define the scope of a parameter, and


the default value allows users to provide any additional information
required when calling this function or procedure from other code
blocks.
This also ensures that if no values are specified during execution,
then some predetermined fallback option exists, thereby preventing
program crashes due to missing data elements not supplied correctly
beforehand or throughout entire session processes.

12. What scalar data types are available for defining variables
associated with identifiers according to Oracle's specific ANSI
standards-compliant PL/SQL definition?

Page 8 of 12
iNeuron Intelligence Pvt Ltd

Scalar data types are available for defining variables associated with
identifiers according to Oracle's specific ANSI standards-compliant
PL/SQL definition. Scalar types, also known as elementary or
primitive datatypes, represent a single value and can be either
number (NUMBER), string (VARCHAR2) or date type (DATE).

13. How can table column be modified using ALTER command as part
of DDL operations?
To modify a table column using ALTER command as part of DDL
operations, the server-side hosting instance-related services running
under RDBMS software must support a dynamic SQL execution
mechanism.
Tables should reside inside schema-based repositories developed
based on a relational paradigm consistent with following ACID
principles adopted from transaction processing theory.
In order to execute such a statement, the user will have to login into
a database and acquire the necessary privileges for performing the
operation without any conflicts generated by other transactions in
the same or different schemas involved in the current session.

14. How do you create an update statement in PL/SQL?


An update statement in PL/SQL is a command used to modify or
change data from an existing table in the database. It has the syntax
of:

UPDATE <table_name> SET column1 = value1, [column2 = value2...]


WHERE <condition>

Page 9 of 12
iNeuron Intelligence Pvt Ltd

where you can specify which columns need updating and what
conditions should be met before making the changes. For example,
UPDATE Employee's SET salary = 1000 WHERE id = 100; This
statement would update all employees whose id equals 100 to have a
salary of 1000.

15. What is the purpose of a database trigger in PL/SQL?


A database trigger in PL/SQL is a stored program that gets
automatically executed when certain conditions are satisfied. They
are employed to uphold data integrity, enforce business rules, or
audit record-keeping modifications. They can be associated with
INSERT, UPDATE, or DELETE operations on one or more tables and
execute arbitrary SQL code every time they activate.

For example, A 'salary change' trigger could enforce a rule that salary
must not go below 1000 for any employee, preventing updates from
being committed if this condition is violated.

Database trigger in PL/SQL

16. How can numeric values be manipulated using PL/SQL?


Numeric values can be manipulated using PL/SQL in various ways.
This includes performing basic arithmetic operations (such as
addition, subtraction, multiplication, and division), rounding numbers
to the nearest integer or decimal place, and calculating exponentials
or logarithms with complex functions such as SQRT(), LOG() or
POW().

Page 10 of 12
iNeuron Intelligence Pvt Ltd

17. Can you explain how to use an exception block within a PL/SQL
package body?
An exception block within a PL/SQL package body can be used to
handle any errors that occur during execution. It is defined by using
the keyword EXCEPTION followed by one or more WHEN clause
statements which check for specific error conditions and execute
particular code if they are met.

For example:

EXCEPTION WHEN OTHERS THEN INSERT INTO log_table (error)


VALUES (SQLCODE);

This block would catch all other exceptions not explicitly handled in
an earlier statement, log them into a separate table and then
continue with normal program flow. You can also define your own
custom exceptions and create additional nested blocks when needed.

18. What are actual parameters, and how do they work with current
transactions when programming with PL/SQL?
Actual parameters are values passed to a procedure or function
during invocation. When programming with PL/SQL, they can be used
within the current transaction by referencing them in SQL statements
(e.g., SELECT * FROM TABLE WHERE id =:p_id). This enables
developers to conditionally execute database operations depending
on the values provided during execution.

For example: if some procedure was designed to retrieve data only


from recent entries, then p_id being not null would trigger a query
that selects all records created after the given date. Having it set as
NULL would cause those lines of code to be skipped altogether.

Page 11 of 12
iNeuron Intelligence Pvt Ltd

19. Can video clips be included inside a PL/SQL program code?


No, it is impossible to include video clips inside a PL/SQL program
code. This language is designed for manipulating structured data
within Oracle databases. It, therefore, does not support media
formats like videos or audio files that are better served through other
technologies (e.g., HTML5).

20. Describe a Database Management System (DBMS) and explain


how PL/SQL uses one.

Data that is held in a database is stored, managed, and handled by a


piece of software called a database management system (DBMS).
Users can execute various activities, such as creating, changing, or
removing records within their databases, thanks to the interface it
offers between them and the underlying database server.

The DBMS plays a crucial role in PL/SQL by offering effective access


techniques for querying data from tables or views and guaranteeing
that transactions are carried out correctly with the least amount of
overhead. This includes employing locks to stop other sessions from
changing shared resources.

Page 12 of 12
iNeuron Intelligence Pvt Ltd

1. In PL/SQL, how do you add a new table row using DML operations?

New table rows can be added using DML (Data Manipulation


Language) methods in PL/SQL. The INSERT statement, which
describes the columns and values of a specific row that you want to
add to your database, is used to do this.

For instance: (column1, column2,...) INSERT INTO MY TABLE VALUES


('value1', 'value2',...); This will create a new table row in "my_table"
containing the appropriate values for each provided column. You can
insert several rows simultaneously using stored procedures or
dynamic SQL.

2. How can you use Pseudo columns to manipulate data within


PL/SQL?
Pseudo columns are virtual columns that present particular values in
a SELECT statement but have no actual existence within the
underlying table. In PL/SQL, pseudo-columns can manipulate data by
providing additional information for operations such as sorting or
replacing existing column names when selecting records from tables.

For example, you could use the ROWID pseudo-column to retrieve


the unique row identifier of each record without having it explicitly
defined in your SELECT

query like so: SELECT ... FROM my_table ORDER BY ROWID;

This would result in all queried rows being sorted according to their
row identifiers instead of any other previously specified order
criteria.

Page 2 of 14
iNeuron Intelligence Pvt Ltd

3. Describe the purpose of raising an exception with a raise


statement in PL/SQL?
Raising an exception is a process of indicating the occurrence of
errors within PL/SQL programs. It can be done using the raise
statement, which specifies particular error codes so that users can
quickly recognize and react to any potential issues they may have
encountered during execution.

By raising exceptions, developers can handle and control errors more


efficiently than before since it helps them identify exactly what might
have gone wrong, provide appropriate user feedback, or take
corrective action whenever necessary.

Such Raise statements also help maintain data integrity through


transactions by allowing you to roll back changes if something
unexpected occurs while executing a script.

4. Explain what happens when the commit statement changes are


made using DML operations within the context of a sequence of
statements implemented using PL/SQL programming language?
The commit statement is used in PL/SQL to save changes made using
DML operations such as INSERT, UPDATE, and DELETE. When this
commit statement is included at the end of a sequence of
statements, it tells the database server that all data manipulation
language (DML) commands should be permanently recorded within
its tables on disk.

This means that even if an error occurs during execution or the


program stops before completion for any other reason, whatever
modifications have been successfully committed will remain effective
and won't require manual intervention from users afterwords.

Page 3 of 14
iNeuron Intelligence Pvt Ltd

The commit statement also serves to release any resources that were
previously held by a cursor or other database objects while the
sequence of statements was being executed.

5. What is a SQL Cursor, and what purpose does it serve within the
context of PL/SQL programming language?
Within the context of PL/SQL programming language, a SQL Cursor is
an internal structure used to handle and process multiple rows of
data. It acts as a pointer within your program which points at each
row returned from queries in sequence so that you can take
appropriate action depending on the result set specified by such
statement (e.g., updating records).

As a result, developers may use SQL cursors to retrieve data regularly


without constantly relying on database server resources, which
greatly reduces overhead when working with huge amounts of data.

6. How can you write a single query in PL/SQL to search for duplicate
values?
In PL/SQL, you may use the SELECT query with the DISTINCT keyword
to extract the distinct results from a specified table or view and do a
search for duplicate values.

The single query should look like this: SELECT DISTINCT * FROM
<tablename>; This will return all distinct (unique) records from your
selected table or view, allowing you to identify any duplicates within
your data set quickly.

Page 4 of 14
iNeuron Intelligence Pvt Ltd

Example:

DECLARE
-- Declare a cursor to store the query result
CURSOR duplicate_cursor IS
SELECT column_name, COUNT(*) AS count
FROM table_name
GROUP BY column_name
HAVING COUNT(*) > 1;

-- Variables to store the query result


column_value table_name.column_name%TYPE;
row_count INTEGER := 0;
BEGIN
-- Open the cursor
OPEN duplicate_cursor;

-- Fetch the cursor records


LOOP
FETCH duplicate_cursor INTO column_value, row_count;
EXIT WHEN duplicate_cursor%NOTFOUND;

-- Print the duplicate values


DBMS_OUTPUT.PUT_LINE('Duplicate value: ' || column_value || ',
Count: ' || row_count);
END LOOP;

-- Close the cursor


CLOSE duplicate_cursor;
END;
/

Page 5 of 14
iNeuron Intelligence Pvt Ltd

Reference Output:

Duplicate value: PQR, Count: 4

7. What different object types are available when using PL/SQL?


PL/SQL has six different object types that can be used to write
efficient code.

These include tables, views, sequences, synonyms, packages, and


procedures.

Tables are structures that store data in rows and columns;


Views provide a virtual table where the underlying query is stored as
text;
Sequences generate unique values based on certain conditions
provided in their definition;
Synonyms act as aliases to other database objects like tables or
functions;
Packages allow multiple related procedures and functions to be
grouped within an object type; and
Procedures offer a set of SQL statements that, when called, will
execute them sequentially.

8. Is it possible to execute an entire block of code with one command


in PL/SQL?
Yes, executing an entire block of code with one command is possible
using PL/SQL's EXECUTE IMMEDIATE statement syntax. This allows
you to group multiple statements into one and execute them

Page 6 of 14
iNeuron Intelligence Pvt Ltd

together as a single unit without having to declare each line


separately beforehand:

EXECUTE IMMEDIATE 'BEGIN <statement1>; <statement2>; ... END';

Example:

BEGIN
EXECUTE IMMEDIATE '
DECLARE
-- Declare variables
first_name VARCHAR2(50);
last_name VARCHAR2(50);
BEGIN
-- Assign values to variables
first_name := ''John'';
last_name := ''Wink'';

-- Display the full name


DBMS_OUTPUT.PUT_LINE(''Full Name: '' || first_name || '' '' ||
last_name);
END;
';
END;
/

Output:

Full Name: John Wink

Page 7 of 14
iNeuron Intelligence Pvt Ltd

9. How can you use string literals within my queries while


programming with PL/SQL?
String literals are used when writing queries in PL/SQL to represent
text-based information such as names, titles and descriptions, etc.,
stored inside database tables or views previously by other
applications using character strings instead of numerical integers and
floats, etc.

You can write string literals directly into your queries simply by
enclosing them within single quote marks ('): SELECT * FROM
<tablename> WHERE name = 'John Doe';

10. How can you select a range of values within my PL/SQL query?
PL/SQL allows you to select a range of values within your query using
the BETWEEN operator.

For example, SELECT * FROM mytable WHERE somecolumn


BETWEEN x AND y;

In the example, it records all from the 'mytable' table where the
value in column 'somecolumn' is between two specified values (x and
y) are returned as part of the result set.

You can also choose not to specify one end of a range, such as
selecting only those records which have values greater than or equal
to x with: SELECT * FROM mytable WHERE somecolumn >= x;

Combining operators like =, <>, <=, >= etc., with BETWEEN allows it to
create more complex queries for obtaining data based on specific
ranges.

Page 8 of 14
iNeuron Intelligence Pvt Ltd

Example:

DECLARE

start_value INTEGER := 30;


end_value INTEGER := 40;

BEGIN
-- Using BETWEEN operator
SELECT column_name
INTO variable_name
FROM table_name
WHERE column_name BETWEEN start_value AND end_value;

SELECT column_name
INTO variable_name
FROM table_name
WHERE column_name >= start_value AND column_name <=
end_value;
END;

11. What are the modes of parameters available in PL/SQL when


passing arguments to stored procedures?
When passing arguments to stored procedures in PL/SQL, there are
different modes of parameters available which can be used. The four
main modes are IN, OUT, INOUT, and DEFAULT, which indicate the
type of input accepted for a particular parameter or argument.

The mode 'IN' indicates an argument passed into the procedure from
its calling environment;
'OUT' specifies that data will flow back to its calling environment; and

Page 9 of 14
iNeuron Intelligence Pvt Ltd

'INOUT' signifies both incoming and outgoing information between a


given procedure's environment.
Finally, when no explicit mode is specified, it defaults to 'DEFAULT'
mode, where any changes this parameter makes within the execution
context remain local.
Modes of parameters available in PL/SQL

12. What is the purpose of single-line comments in PL/SQL?


Single-line comments in PL/SQL are used to add remarks and notes to
code. They begin with two hyphens (--) followed by the comment,
which can span a single line of text. When compiling your program or
script, the compiler ignores anything on the same line after the
double hyphens, allowing developers to clarify their work for other
readers without changing its function. For example, the following
single-line comment in PL/SQL explains what a line of code does
without changing how it functions. This code checks if there are any
new entries in the database table.

Example:

DECLARE
-- Declare variables
first_name VARCHAR2(50);
last_name VARCHAR2(50);
BEGIN
-- Assign values to variables
first_name := 'John'; -- First name
last_name := 'Doe'; -- Last name

-- Display the full name

Page 10 of 14
iNeuron Intelligence Pvt Ltd

DBMS_OUTPUT.PUT_LINE('Full Name: ' || first_name || ' ' ||


last_name);
END;
/

13. How can we write a multi-line comment within a PL/SQL


program?
Multi-line comments in PL/SQL are used to add remarks and notes
over multiple lines of code. They begin with a double hyphen (--)
followed by an asterisk (*), then the comment text, and finally, they
end with an asterisk (*) followed by two hyphens (--).

Anything between these characters will be ignored when compiling


your program or script, allowing developers to clarify their work for
other readers without changing its functions.

For example, the following multi-line comment in PL/SQL explains


what several lines of code do together: --* This block checks if there
is new data added to the database table since the last execution *--

14. What are row-level triggers, and how do they work in PL/SQL
programming?
Row-level triggers are a type of trigger in PL/SQL programming that
fire for each row affected by the triggering statement. They allow
developers to specify actions based on changes made to individual
rows, such as inserting data into logging tables or raising an
exception if certain conditions are unmet.

When triggered, these stored procedures will modify or query


information related to the modified row and make decisions

Page 11 of 14
iNeuron Intelligence Pvt Ltd

accordingly before executing any additional statements. Row-level


triggers can be beneficial when writing complex business rules as
they offer precise control over data processing within a database
application.

15. Can PL/SQL commands store or display graphic images?


Yes, PL/SQL commands can store and display graphic images.
Graphics files such as JPEGs or PNGs can be stored in the database
within BLOB (binary large objects) fields that efficiently store digital
properties. Likewise, these binary data types can then be used to
output graphical elements from the results of a query via display
packages like Oracle's own HTP package.

This package allows developers to store pictures directly into their


application databases and then render them on webpages without
any extra work by utilizing functions like htp.image or even
generating dynamic bar charts with graphs with code similar to htp.p
('<img src="data:image/png;base64,' || utl_encode( img ) || '" />' );

16. How can network traffic be monitored with the help of PL/SQL
commands?
Network traffic can be monitored with the help of PL/SQL commands
using database packet sniffing. Packet sniffing is a method of
intercepting and analyzing network packets sent over various
networks, including local area and wide-area networks.

With this technique, developers can use PL/SQL packages such as


DBMS_NETWORK_PACKET to look at all incoming and outgoing
network requests from their program or script in order to detect

Page 12 of 14
iNeuron Intelligence Pvt Ltd

malicious activity or analyze performance issues like slow response


times.

17. What types of records may be manipulated through PL/SQL


programming?
PL/SQL programming allows developers to manipulate different types
of records. These include database tables, views, sequences,
synonyms and functions that can all be manipulated in order to
facilitate different operations, such as creating new entries or
modifying existing ones.

Additionally, PL/SQL programs support complex transactions like


manipulating multiple related components, allowing them to handle
heavier workloads with fewer conflicts than single-execution
statements alone.

18. What is the use of package body statements while working on a


complex database system with PL/SQL code?
The package body statement in PL/SQL is used to develop complex
database systems with procedural logic. A package body is a
collection of related functions and procedures whose code must be
defined for the program to run properly, and it can also serve as a
wrapper around several other elements, like any variables and type
definitions it needs.

With this form of encapsulation, developers can better organize their


programs into logical groupings based on what they do, making them

Page 13 of 14
iNeuron Intelligence Pvt Ltd

easier to read while maintaining their performance when executing


tasks.

19. What is a cursor variable, and how can it be used in PL/SQL?


A cursor variable is a pointer or reference to the memory address of
an Oracle server-side cursor that enables stored procedures and
functions in PL/SQL to access data from relational databases.

It can be used to retrieve rows from one or more database tables by


using SQL queries within PL/SQL code. The returned result set is
assigned into a record structure that remains accessible for the
duration of the program execution.

Cursor Variable in PL/SQL

20. How do you check for duplicate records within an outer query in
PL/SQL?
In PL/SQL, you can check for duplicate records within an outer query
using the SELECT DISTINCT clause. The SELECT DISTINCT clause
ensures that only the specified columns' distinct (unique) values are
returned in a record set.

When combined with other clauses such as GROUP BY and ORDER BY,
it can detect duplicate rows based on specific criteria or group them
using various column combinations.

Additionally, aggregate functions such as COUNT, MAX and MIN can


be used to calculate statistics on the returned individual records.

Page 14 of 14
iNeuron Intelligence Pvt Ltd

1. Describe the process of creating nested tables in a relational


database management system?
Nested tables are collection objects in an Oracle database that allow
storing and retrieving multiple records within one data structure.
They can store complex data sets such as arrays, multidimensional
collections, or entire tabular structures.

Creating nested tables typically involves creating an SQL table with


columns defined to support the type and number of elements stored
in each row, then inserting values using either Insert Statements or
Select statements into that newly created nested table.

2. What are the different collection types available for EXIT


statements in PL/SQL programming language?
In PL/SQL, the EXIT command is used to exit a loop or branch
immediately. It helps developers control the flow of program
execution and can be applied with various collection types such as
arrays, records, references (pointers) and tables. Arrays are like
collections that store multiple values under one name; for example,
an array called 'numbers' could contain [5 2 8 0 1].

Records allow you to define data structures with named fields so that
individual elements can be accessed quickly and easily; for instance,
a record containing student information might look something like
('Name': John Doe,' 'Age': 24). References provide pointers within
your codebase to help keep track of certain objects such as cursors or
nested table columns.

Page 2 of 12
iNeuron Intelligence Pvt Ltd

3. How does one create objects at the schema level using PL/SQL
code?
In PL/SQL, one can create objects at the schema level by executing a
CREATE statement. This needs to be followed by specifying the name
and type of object that will be created within the database.

For example, consider a situation where PL/SQL code can be used to


build a table in the Oracle Database. In that case, all required
columns must be defined with data types and primary key constraints
before any INSERT statements are issued against this newly created
table.

Other objects, such as sequences or triggers, may also have various


constraints associated with them; for instance, an
AUTONOMOUS_TRANSACTION trigger will not fire while COMMIT
occurs due to its PRAGMA clause settings that must first be set
accordingly before execution of CREATE TRIGGER statement.

4. Explain what Cursor-based records mean and how can they be


managed through PL/SQL commands?
Cursor-based records are the result sets that can be retrieved by
performing a query using cursors in PL/SQL. A cursor is an object
used to point to and process individual rows at a time from a
returned record set when data retrieval is done either through
standard SELECT statements or complex stored procedures and
functions.

To work with such cursor-based records,

Page 3 of 12
iNeuron Intelligence Pvt Ltd

You must first Declare your Cursor variable name along with all
necessary parameters associated with the given SQL query;
Open said Variable once declared correctly - this allocates memory
resources needed for processing the underlying dataset;
Fetch particular values out from opened variables using ensuing fetch
commands;
Perform updates/deletions upon certain conditions (if any)
depending upon your application's logic;
Close finally reallocating corresponding used database resources
enabling other programs waiting in line.

5. Can EXECUTE keyword be used to execute anonymous blocks in


PL/SQL?
Yes, the EXECUTE keyword can be used to execute anonymous blocks
in PL/SQL. An anonymous block is a set of valid SQL and PL/SQL
statements grouped together as one segment that does not have an
assigned name.

They are typically typed directly into command-line interfaces such as


Oracle SQL*Plus or used within application programming sources to
interact with underlying relational databases without having actual
subprogram definitions created for the same operations every time
they need to be executed again later on.

6. What is the return type of a PL/SQL function? Explain each return


type.
The return type of a PL/SQL function can be any valid data type such
as NUMBER, VARCHAR2, BOOLEAN, and DATE.

Page 4 of 12
iNeuron Intelligence Pvt Ltd

The NUMBER type is used to hold numeric values such as integers,


real numbers, and floating point numbers.
The VARCHAR2 data type stores character (or string) values of fixed
or variable length up to 4 gigabytes.
BOOLEAN datatype holds a boolean "true" or "false." It can be
represented by 0 for false and 1 for true value.
DATE types are used to store date and time information in the Oracle
Database, which includes the year, month, day, hours, minutes, etc.;
each DATE column occupies 7 bytes on disk and has maximum
precision up to 9 decimal places.

7. How do you use the PL/SQL function return statement?


The return statement is used in a PL/SQL function to define the value
of the data type declared in the RETURN clause and end execution of
that particular function. In other words, it specifies what type of data
should be returned by a given function when called.

For example, A simple mathematical expression may use multiple


functions within one larger assembling program (e.g., parametric
equation), with each component’s values being taken from different
variables or external sources.

The entire sub-program can then be compiled into one callable unit
by using returning statements for each part which will read as
follows: RETURN x + y, where x & y are two separate numerical
parameters defined prior. Then this assembled program can, later on,
be utilized like any other normal stand-alone utility!

8. Name two concatenation operators used in PL/SQL programming


language.

Page 5 of 12
iNeuron Intelligence Pvt Ltd

The two concatenation operators used in PL/SQL programming


language are the period (.) and double vertical bar (||) operators.
The period operator is used to combine a column name with its table
or view. In contrast, the double vertical bars combine strings
together, typically within an expression or as part of a larger
statement. For example, ‘Hello’ || ‘World’ will result in Hello World
being printed out when executed on the database console.

9. Describe the control structures used in PL/SQL programming


language.
PL/SQL control structure helps to design a program in an orderly
manner. It provides the flexibility and functionality of large programs
by allowing blocks of code to execute conditionally or repeatedly
based on user input, conditions, etc. All programming languages have
their implementation of these structures; in PL/SQL, there are three
main categories: statements, loops, and branches.

Statements: A statement is used when no further decision-making


needs to be done – it simply allows you to perform one action at a
time (e.g., assign values).
Loops: Loops allow you to set up instructions that will repeat until
some criteria are reached - for example, iterate through records
returned from SQL query or looping over data defined within your
block itself (using ‘for’ loops).
Branches: Branches let you specify different sets of instructions
depending on certain factors – such as variables being equal/not-
equal - if the result is true, then branch down this route; else, take
another path. This gives great flexibility when designing complex
functions inside your application that require multiple outcomes to
fulfill specific results.

Page 6 of 12
iNeuron Intelligence Pvt Ltd

10. Explain how to construct a logical table using SQL queries and
statements in a database environment?
A logical table in a database environment is an organized set of data
stored according to a predetermined structure that allows easy
retrieval of information from relational databases. To construct a
logical table using SQL queries and statements, one needs to create a
table statement consisting of three sub-parts - column definitions
(name, type), constraints (primary key or foreign key), and storage
parameters.

The first step involves defining the columns with "data types" such as
INTEGER(number without decimal points); VARCHAR2 for character
strings;
DATE for date fields etc., followed by 'constraints' defining rules
about inserting values into specific columns like NOT NULL for
mandatory inserts or UNIQUE KEY when records need not repeat
themselves in more than one row/column pairs.
The last part specifies how much memory will be allocated while
saving data and other details related to Indexes on particular tables,
allowing quick search operations over them.
Once all these elements are supplied properly using CREATE TABLE
command, this should successfully form your desired Logical Table
structure within any given DBMS system!

11. What are duplicate tables, and what purpose do they serve when
working with databases?
Duplicate tables are used to store copies of data from another table.
They can be particularly useful in database management systems

Page 7 of 12
iNeuron Intelligence Pvt Ltd

where a single mistake in the original table could have disastrous


effects if not corrected quickly.

Duplicate tables can provide an extra layer of protection by providing


access to unburdened versions of the same information that allows
for any changes made in one version without affecting another or
even reversing any mistakes before they affect other users. This helps
organizations avoid costly mistakes and reduces time spent
troubleshooting them when they do happen.

12. How do triggers work in Oracle PL/SQL?


Triggers in Oracle PL/SQL are stored programs that fire when a
specific event occurs, such as data modification. They are primarily
used to enforce business rules and maintain database integrity by
preventing unauthorized access or changes to data. Triggers can also
be used for auditing purposes, and they typically take the form of
SQL statements that execute when a table is changed. The trigger
usually contains an IF statement that executes commands based on
whether certain conditions have been met; this allows triggers to
selectively process only those rows that need additional processing
beyond what happens during normal inserts or updates on tables.

13. What are the different types of joins in Oracle PL/SQL?


There are four different types of joins in Oracle PL/SQL:

Oracle Simple JOIN: This type of join is also known as an inner or


equi-join. It displays all the records from both tables where there is a
match with the specified columns in each table.

Page 8 of 12
iNeuron Intelligence Pvt Ltd

Oracle LEFT JOIN: The left join returns all rows that exist in the left
side table and optionally any matching rows from the right side table
if it exists. If there are no matches, NULL values will be returned for
the right column’s results.
Oracle RIGHT JOIN: The Right outer join performs similarly to Left
Outer join but reverses roles between the two tables, returning
information from the second table (right) and matching info from the
first one (left). Unmatched entries containing Nulls will be included
for Right Table data fields only, while on the Left side - the usual
query output and result set will appear.
Oracle FULL JOIN: A full outer join combines elements of a left outer
join and a right outer join into one statement, thus giving us access to
every row existing within either joined relation regardless of if there
was/was not a matched value present when comparing keys across
participating relations

14. What is the purpose of using a DUAL table in Oracle PL/SQL?


The purpose of the DUAL table is to provide developers with a single-
row, single-column table used in SELECT statements to validate your
code. It can be particularly useful when entering complex SQL
queries that use Oracle functions and operators such as NVL(),
DECODE() or CONCAT(). It can also be used to test SQL statements
without creating and populating a table.

15. How can we use single quotes in Oracle PL/SQL?


We can use single quotes in Oracle PL/SQL by escaping them using a
backslash (\).
For example: SELECT * FROM mytable WHERE name = 'John\'s Place';

Page 9 of 12
iNeuron Intelligence Pvt Ltd

16. What is the syntax for declarations of cursors in PL/SQL?


The syntax for declaring of cursors in PL/SQL is: CURSOR
<cursor_name> [ ( <parameter list>) ] IS SELECT statement;
Example: CURSOR student_cursor IS SELECT * FROM students;

17. Name and explain some implicit cursor attributes associated with
cursors in PL/SQL.
The implicit cursor attributes associated with cursors in PL/SQL are:

%FOUND: This attribute is a Boolean variable that returns true if the


last fetch from the cursor was successful and false otherwise. If no
rows were found, an exception would be raised instead of returning
false for this value.
%NOTFOUND: This attribute is also a Boolean variable that returns
true when nothing has been returned by the previous fetch
statement or query execution but can return NULL when no data
operation has occurred yet on that particular context area (i.e., after
opening the cursor).
%ISOPEN: A built-in function that checks whether or not your defined
SQL Cursor is open, and if so, it's True; else, False.
%ROWCOUNT: It keeps track of how many records have been fetched
from within its loop to return multiple rows as part of its results set
as per user requirement.
%BULK_ROWCOUNT: This attribute returns the total number of rows
processed in a bulk operation, such as when using FORALL or BULK
COLLECT operations to insert multiple rows at once into an Oracle
table with PL/SQL code (i.e., "bulk DML").

Page 10 of 12
iNeuron Intelligence Pvt Ltd

18. What are some of the cursor operations that can be performed
on a created using PL/SQL?
The most common cursor operations that can be performed on a
PL/SQL cursor include:

Opening the cursor.


Fetching rows from the result set one at a time or in bulk amounts.
Closing the cursor when finished processing.
Bind Variables for passing parameters to query execution.
Explicit Cursor Attributes such as %ISOPEN, %ROWCOUNT and
%NOTFOUND that take values based on query resultset information

19. What are some of the list of parameters used to define a cursor
inside an anonymous block or stored procedure?
The list of parameters used to define a cursor inside an anonymous
block or stored procedure includes:

CURSOR_NAME: This is the name you assign to the cursor.


SELECT_STATEMENT: This is the SQL query that forms your result set.
ORDER BY: An optional clause that can be used to sort your data in
ascending/descending order based on one or more columns.
FOR UPDATE [OF column_list]: Specify this option if you want other
users (in another session) to be blocked from updating rows included
in the resultset while it’s being processed by the current user’s open
cursor statement.
OPEN, CLOSE and FETCH statements for fetching records from the
database into program variables.
NO_PARSE: Specifying this clause will force the engine to parse your
SQL query once instead of parsing it every time when fetched.

Page 11 of 12
iNeuron Intelligence Pvt Ltd

USING Clause: This is an optional clause used to pass values from


program variables in a PL/SQL block while opening the cursor or
during fetching records.

20. How does one use access operators such as FOR UPDATE, READ
ONLY and FOR SHARE within their Cursors in PL/SQL?
The FOR UPDATE, READ ONLY and FOR SHARE access operators are
used within the Cursor declaration in PL/SQL. These operators specify
the types of locks Oracle should acquire when executing the query
associated with a cursor.
For example:
CURSOR my_cursor IS
SELECT * FROM customers WHERE customer_id = someID
FOR UPDATE;

In this example, an advisory lock (table-level) will be placed on the


"customers" table for each row returned from the SELECT statement
once it has been opened by executing OPEN my_cursor.

Page 12 of 12
iNeuron Intelligence Pvt Ltd

1. What kinds of variables should you declare when using integers in


range func9ons like BETWEEN etc.?
When using range func9ons like BETWEEN in PL/SQL, you should
declare two variables: one for the lower bound of the range and
another for the upper bound. Both variables should be declared as
integers. For example:
DECLARE
lower_bound INTEGER;
upper_bound INTEGER;
BEGIN

SELECT * FROM customers WHERE customer_number BETWEEN


:lower_bound AND :upper_Bound; END;

2. How does equi join work when programming with cursors in PL/
SQL?
When programming with cursors in PL/SQL, equi joins work by
joining two or more tables on a column or set of columns with the
same values. The syntax for an equi join includes specifying the
names and condi9ons of each table involved as well as the common
fields being used for comparison:
FOR cur1 IN (SELECT * FROM TableA A , TableB B WHERE A.fieldone =
B.fieldtwo)
LOOP
-- do something with cur1
END LOOP;

3. How do you ensure that Ini9al values are correctly assigned when
execu9ng a PL/SQL program?

Page 2 of 10
iNeuron Intelligence Pvt Ltd

We can ensure ini9al values are correctly assigned when execu9ng a


PL/SQL program by defining default values for variables in the
declara9on sec9on of the block and using an IF-THEN statement to
execute the appropriate code based on whether or not an ini9al
value is supplied. Addi9onally, we can use excep9on handling within
our programs configured to trigger in cases where incorrect input is
provided, providing informa9on about how errors should be handled.
Furthermore, we could incorporate data valida9on into our program
logic to check that input parameter values meet certain criteria
before being accepted as valid inputs.

4. What is the purpose of Triggers in PL/SQL, and explain the


execu9on of triggers?
A trigger is a stored PL/SQL block fired automa9cally in response to
an event (INSERT, UPDATE or DELETE) on a par9cular table. It can be
used to check and modify the values of newly inserted rows or
update exis9ng records with new values. Triggers are generally
executed when data changes occur inside specific tables, and they
usually contain SQL statements that use much of the same syntax as
normal SQL statements.
The execu9on process for triggers begins aaer an insert, delete, or
update statement has been issued against the associated table(s).
The following steps outline how this occurs:

Oracle reads through each row affected by insert, delete, or updates


statement before any commit opera9on
Any constraints defined against rows being modified are checked
A list of all applicable triggers for those opera9ons is assembled
For each such trigger found, its code is fetched

Page 3 of 10
iNeuron Intelligence Pvt Ltd

If specified via SET CONSTRAINTS mode (eager), then checks for


possible triggering ac9ons based on what occurred
All other applicable valida9ons take place
Assembled sequence calls one firing procedure
Each firing procedure executes according
Lastly, once all these processes have been completed without error,
then only it returns 'success' status

5. How does one handle different integer types within the scope of a
PL/SQL program?
PL/SQL datatypes can be categorized into two types - numerical
(NUMBER, BINARY_INTEGER) and character (CHAR, VARCHAR2). To
handle different integer types within the scope of a PL/SQL program,
use an implicit data conversion func9on to convert one type to
another. For example:

-- Conversion from NUMBER to BINARY_INTEGER


BinaryIntegerVariable := To_binaryInteger(NumberVariable);

-- Conversion from CHAR or VARCHAR2 to NUMBER


NumberVariable := To_number(CharacterVarialble);

-- Conversion from BINARY_INTEGER to NUMBER


NumberVariable := To_number(BinaryIntegerVariable);

Page 4 of 10
iNeuron Intelligence Pvt Ltd

6. In what situa9ons will LOOP statements be necessary for


developing complex logic in a PL/SQL program?
Loop statements can be used in a variety of situa9ons when
developing complex logic, such as:

Itera9ng through data stored in collec9ons like arrays or records.


Genera9ng test data for debugging and tes9ng purposes.
Performing repe99ve calcula9ons or tasks on mul9ple items (e.g.,
calcula9ng an average).
Execu9ng a code block while certain condi9ons are met (looping un9l
they no longer hold true).
Performing an ac9on for each element in a list or table.

1. What are the various SQL subsets?


DDL, DML and DCL are the various subsets of SQL.

DDL (Data Defini9on Language) is the language used to define the


structure of a database so that you may create, alter, and delete
objects.

You can access the data and modify it in the Data Manipula9on
Language (DML). One can use Database Management Soaware for a
variety of tasks.

Data Control Language (DCL) can restrict access to a database.


Permissions can be granted or revoked.

Page 5 of 10
iNeuron Intelligence Pvt Ltd

7. Why is String immutable in Java?


Security, synchronisa9on and concurrency, caching, and class loading
make the String immutable in Java. It is necessary to make the string
final to prevent others from extending the string's immutability.
There is no way to modify a series cached in the String pool.

8. Why are OOPs required?


OOPs enable you to simulate actual objects, decouple interfaces and
implementa9on specifics, and persistently store object-oriented data
in the database.

OOPs make it easier for consumers to grasp the soaware, even if


they don't know how to implement it.
The code becomes much easier to read, comprehend, and
maintain when wrilen using OOPs.
Using OOPs, even the most complex soaware can be built and
managed quickly and easily.

9. What is the Graphical based interface in SQL?


A diagramma9c form that presents a schema to the user is included
in a graphical user interface. By adjus9ng the diagram, the user poses
a ques9on. In these interfaces, the mouse is used as a poin9ng tool
to select certain areas of the diagram.

The users of electronic devices like touch screens and mobile phones
use these types of interfaces.

Page 6 of 10
iNeuron Intelligence Pvt Ltd

10. Explain RDBMS?


IT professionals and others can use a rela9onal database
management system (RDBMS) to create, modify, administer, or
interact with rela9onal databases. Structured Query Language (SQL)
is the query language most commonly used by commercial rela9onal
database management systems to access data contained in tables.

RDBMS

11. What do you mean by self-join?


Self joins, also known as unary rela9onships, represent a method
where a table is joined to itself, par9cularly when the table has a
foreign key that refers to its own primary key. When a table is joined,
each row is merged with every other row in the table as well as with
itself.

12. What is the SELECT statement?


A SELECT command can return zero or more rows in one or more
database tables or views. SELECT is the most used command in data
manipula9on languages (DML). SELECT queries define a result set but
do not specify how to calculate it, as SQL is a declara9ve
programming language,

Page 7 of 10
iNeuron Intelligence Pvt Ltd

13. Explain PostgreSQL?


Postgres was built in 1986 by a group led by Professor of Computer
Science Michael Stonebraker. By providing data integrity and fault
tolerance in systems, it was designed to help developers develop
enterprise-level applica9ons. PostgreSQL is an open-source object-
rela9onal database management system designed for large
organisa9ons. The interna9onal developer community has always
supported it.

14. Give a brief descrip9on of SQL comments?


To prevent SQL statements from being run, SQL Comments can be
used to explain specific parts of the SQL statement. Many
programming languages place a high value on comments. A Microsoa
Access database does not back up the comments. Consequently,
both Firefox and Edge demonstrate using the Microsoa Access
database.

15. What is schema?


It is the visual depic9on of the database that is logical. It creates and
specifies the database's various rela9onships. It is a term used to
describe the different SQL data types of database restric9ons. Tables
and views can benefit from this feature.

Page 8 of 10
iNeuron Intelligence Pvt Ltd

16. What are the types of databases?


Numerous types of databases exist, some of them are:

Hierarchical databases
Object-oriented databases
Rela9onal databases
Network databases
Complex and extensive databases are constructed using the same
design and modelling principles. Large databases are stored on
computer clusters or in the cloud, unlike file systems, which are
beler suited for smaller databases.

17. Explain normalisa9on


Normalisa9on is a process to reduce data redundancy and
dependency by arranging fields and tables in databases in a
normalised manner. In this process, tables are built, and linkages
between tables are established using rules. These principles make
normalisa9on more flexible by removing redundant and inconsistent
dependencies.

18. What is the primary key?


All records in a table can be uniquely iden9fied using a primary key. It
can't contain any NULL values and must have only one data set. A
composite key can have single or numerous fields, but only one can
exist in a given table.

Page 9 of 10
iNeuron Intelligence Pvt Ltd

19. Are there any programming language features supported by SQL?


The Standard Query Language is referred to as SQL. As a result, while
SQL is technically a language, it does not provide any programming
assistance. This common language has no loops, condi9onal
statements, or logical opera9ons. It can only be used to manipulate
data and nothing else.

20. What is the significance of the DDL language?


Data defini9on language is referred to as DDL. DDL commands in SQL
are the part of a database that specifies the data structure of the
database when it is first set up. – Tables can be added, removed, or
modified using DDL commands.

Page 10 of 10
iNeuron Intelligence Pvt Ltd

1. Explain tables
Some rows and columns make up a table. It provides the ability to
store and display data in a structured fashion. Similar to spreadsheet
worksheets, it is a type of document. The tuples are represented by
rows, while columns represent the a?ributes of the data items in a
specific row. It's possible to think of rows as horizontal and columns
as verCcal.

2. State the difference between primary and unique keys


To uniquely idenCfy records in a database, a primary key might be
one or more table fields. A unique key, on the other hand, stops two
rows from having idenCcal items in a column.
In a relaConal database, a table can have numerous unique keys, but
it can only have one primary key.
A unique key can have NULL values, however only one NULL is
permi?ed in a table, whereas a main key column cannot have NULL
values.
Although uniqueness is preferred for the main key, it's not a
requirement that it serves as the primary key.

3. What is a foreign key?


A foreign key is an a?ribute or feature group that refers to a table's
primary key in a different database. A foreign key is a data structure
that connects two databases.

4. What are operators in SQL?


In SQL queries, specific operaCons can be performed using SQL
operators, keywords, or characters. The WHERE clause of SQL

Page 2 of 11
iNeuron Intelligence Pvt Ltd

statements can employ these operators. SQL operators filter data


based on the condiCon.

5. Explain data integrity


It guarantees data accuracy and consistency throughout its lifecycle.
Systems that store, process, or retrieve data necessitate this feature
in their design, implementaCon, and use.

6. Is SQL a programming language?

The Standard Query Language (SQL) is a query language, not a


programming language. SQL does not have a loop, condiConal
statements, or logical operaCons, so it can only be used to
manipulate informaCon. It is used to navigate databases in the same
way as commanding (Query) language is used. The primary goal of
SQL is to acquire, manipulate, alter, and execute complex operaCons
on database records, such as joins.

7. What is a Data DefiniCon Language, and how does it work?

Data definiCon language (DDL) is a database subset that specifies the


database's data structure in the iniCal stages of development. It's
made up of the following instrucCons: CREATE, ALTER, and DELETE
database objects, including schemas, tables, views, and sequences,
among others.

Page 3 of 11
iNeuron Intelligence Pvt Ltd

8. What are the applicaCons of SQL?

SQL is in charge of keeping the database's relaConal records and data


models up to date.

● To submit queries against a database

● To get details out of a database

● To add informaCon to a database

● To make changes to the records in a folder

● To exclude data from a database

● To create new databases

● Adding new tables to a database

● To populate a database of views

● To operate on the servers in a complex manner

Page 4 of 11
iNeuron Intelligence Pvt Ltd

9. What do you mean by a database management system? What are


the various types?

A database management system (DBMS) is a soaware applicaCon


that communicates with the individual, other programs, and the
database to collect and interpret data. A database is a list of ordered
records.

A database management system (DBMS) enables users to


communicate with the database. The database's data can be
changed, restored, and erased, and it can be of any kind, including
strings, numbers, and illustraCons.

There are two kinds of database management systems:

● Data is maintained in connecCons in a relaConal database


management system (tables). MySQL is a good example.

● There is no definiCon of links, tuples, or a?ributes in a non-


relaConal database management system. MongoDB as an illustraCon.

10. What is the difference between the SQL data types CHAR and
VARCHAR2?

Both Char and Varchar2 are uClized for character data types, but
Varchar2 is used for variable-length character strings, while Char is
used for fixed-length character strings. For instance, Char(10) can
only store ten characters and cannot store strings of any other
length, while varchar2(10) can store strings of any length, e.g. 6,8,2.

Page 5 of 11
iNeuron Intelligence Pvt Ltd

11. In SQL, what is a foreign key?

By imposing a relaCon between the data in any two tables, a foreign


key preserves referenCal integrity. The child table's internaConal key
refers to the parent table's primary key.

The internaConal key restricCon avoids behaviour that might cause


the child and parent tables to lose their links.

12. What are SQL joins?

A JOIN clause is used to join rows from two or more tables together
cantered on a common column. It is used to join two tables together
or to extract data from one of them. There are four disCnct forms of
joins, as detailed below:

● Inner join:
The most oaen used form of join in SQL is the inner join. It is used to
return all rows from mulCple tables that saCsfy the join condiCon.

● Lea Join:
In SQL, a lea join returns all rows from the lea table but only those
that saCsfy the join condiCon in the right table.

● Right Join:

Page 6 of 11
iNeuron Intelligence Pvt Ltd

In SQL, a right join returns all rows from the right table but only those
that saCsfy the join condiCon in the lea table.

● Full Join:
When there is a similarity in either of the columns, a full join recovers
all of the data. As a result, it recovers both rows from both the lea-
hand side table and the right-hand side table.

13. How can a user disCnguish between clustered and non-clustered


indexes?

The following are the disCncCons between clustered and non-


clustered indexes in SQL:

● Clustered indexes are used to facilitate data extracCon from the


database and are quicker while reading from a non-clustered index is
slower.

● A clustered index modifies the way records are stored in a database


by sorCng them by the clustered index column, while a non-clustered
index does not change the way records are stored but also generates
a different object inside a table that leads back to the iniCal table
rows when searching.

● A table may have just one clustered index but may have several
non-clustered indexes.

Page 7 of 11
iNeuron Intelligence Pvt Ltd

14. What do you mean when you say "query opCmizaCon"?

The process in which a strategy for evaluaCng a database is defined


that has the lowest expected cost is referred to as query
opCmizaCon.

The below are the benefits of query opCmizaCon:

● The product is delivered more quickly.


● One can execute a greater amount of queries in a shorter period.
● It reduces the uncertainty of Cme and space.

15. Describe the various forms of indexes available in SQL.

In SQL, there are three kinds of indexes:

A unique index:

If the column is uniquely indexed, this index prevents the sector from
having repeated values. If a primary key is established, one can
create a unique automated index.

A clustered Index that:

Page 8 of 11
iNeuron Intelligence Pvt Ltd

This index reorders the table's physical columns and performs


queries dependent on key values. Each table can have a maximum of
one clustered index.

The non-clustered index does not affect the spaCal order of the table
and preserves the data's conceptual order. Each table can contain a
large number of nonclustered indexes.

16. What are you referring to when you say "DenormalizaCon"?

DenormalizaCon is a method for accessing data from a database's


higher to lower forms. It enables database administrators to boost
the overall efficiency of the infrastructure by introducing redundancy
into a table. It populates a table with redundant data by adding
database queries that consolidate data from several tables into a
single table.

17. What exactly is an index?

An index is a performance opCmizaCon technique that enables the


quicker retrieval of records from a table. An index provides an entry
for each value, making data retrieval easier. SQL indexes are a way of
lowering the cost of a query since a high cost of a query would result
in a drop in query results. An index is used to improve efficiency and
enable quicker retrieval of records from the table. The amount of
data pages we need to access to locate a certain data page is reduced

Page 9 of 11
iNeuron Intelligence Pvt Ltd

thanks to indexing. Indexing, therefore, provides a one-of-a-kind


significance, which ensures that one can’t duplicate the index. An
index provides an entry for each value, making data retrieval easier.
E.g., suppose you have a book with naCon details, and you want to
learn more about India, instead of going through every page of the
book. In that case, you could go straight to the index, and then from
the index, you could go to the specific page where all the informaCon
about India is provided.

18. What is the Difference Between EnCCes and RelaConships?

● EnCty: In the physical world, an enCty, locaCon, or thing about


which data can be stored in a database. Tables are used to store data
that pertains to a certain class of object. For instance, a bank
database contains a customer table that stores customer data. This
informaCon is stored in the customer table as a set of a?ributes
(columns inside the table) for each customer.

● RelaConships: RelaConships or connecCons is when two enCCes


share something in common. For instance, a customer's name is
associated with the customer's account number and contact details,
stored in the same table. AddiConally, associaCons between different
tables are possible (for example, customer to accounts).

19. What is a relaConal database management system (RDBMS)?

It's a database management framework using a relaConal database


architecture. RDBMS is a database management system that stores

Page 10 of 11
iNeuron Intelligence Pvt Ltd

data in a series of tables and links them together with relaConal


operators when required. Using relaConal operators, you can modify
the data in the tables more quickly. Microsoa Access, MySQL, SQL
Server, Oracle client, among other relaConal database management
systems, are examples.

20. What exactly is normalizaCon, and what are the benefits of doing
so?

The method of arranging data in SQL to prevent repeCCon and


replicaCon is known as normalizaCon. The below are some of the
benefits:

● Improved Database Management


● Tables with narrower rows
● Data access that is quick and easy
● Greater Queries Flexibility
● Locate the details quickly.
● Security is easier to enforce.
● Allows for simple customizaCon
● Data duplicaCon and redundancy are reduced.
● More compact database
● Ensure the data remains consistent since it has been modified.

Page 11 of 11
iNeuron Intelligence Pvt Ltd
1. What are set in SQL?

Ans. The set command is used with update keyword to specify which column and value should be updated in a
table.

2. If set A = {L M N O P} and set B = {P Q R S T}, what sets are generated by the following operations?
• A union B
• A union all B

Ans.
1. A union B = {L M N O P Q R S T}
2. A union all B = {L M N O P P Q R S T}

3. On the above set also find out :


• A intersect B
• A except B

Ans.
1. A interest B = {P}
2. A except B = {L M N O}

4. Write a compound query that finds the first and last names of all actors and customers whose last name
starts with L.

Ans.

5. On the above question sort the sort the results by last name.

Ans
iNeuron Intelligence Pvt Ltd
6. How can you concatenate two strings in SQL?

Ans.

7. Write a query to extract a specific portion of a string.

Ans. Use the SUBSTRING function:

8. How do you determine the length of a string in SQL?

Ans.

9. How can you convert a string to uppercase or lowercase?

Ans. Use the UPPER or LOWER functions.

10. Explain different ways to trim leading and trailing spaces from a string.

Ans. Use the LTRIM and RTRIM functions for left and right trimming, or TRIM for both.

11. Write a query to replace a specific character in a string.

Ans. Use the REPLACE function.

12. Write a query that involves basic arithmetic operations on numeric columns.

Ans. Use standard arithmetic operators (+, -, *, /).


iNeuron Intelligence Pvt Ltd
13. Consider a table named employees with a column full_name containing full names of employees in the
format "First Last". Write a SQL query to retrieve the distinct last names (surnames) from the full_name
column.

Ans.

14. How can you round a numeric value to a specific number of decimal places?

Ans.

15. Write a query to find the maximum and minimum values in a numeric column.

Ans.

16. How would you calculate the percentage of a total based on numeric column values?

Ans. Divide the part by the total and multiply by 100

17. Write a query that returns the 17th through 25th characters of the string 'Please find the substring in
this string'.

Ans.
iNeuron Intelligence Pvt Ltd
18 Write a query that returns the absolute value and sign (−1, 0, or 1) of the number −25.76823. Also
return the number rounded to the nearest hundredth.

Ans.

19. Write a query to return just the month portion of the current date.

Ans.

20. Modify your query from the above question to count the number of payments made by each customer.
Show the customer ID and the total amount paid for each customer.

Ans.
iNeuron Intelligence Pvt Ltd

1. What are the drawbacks to failure to execute Database


Normaliza:on?

The below are the big drawbacks:

● The existence of redundant terminology in a database, resul:ng in


the waste of storage space.

● Inconsistency will arise due to redundant terms: if a modifica:on is


made in the data of one table but not in the same data of another
table, inconsistency will occur, causing a maintenance issue and
affec:ng the ACID proper:es.

2. Describe the various forms of normaliza:on.

There are some levels of normaliza:on to choose from. These are


referred to as regular types. Each subsequent normal type is
dependent on the one before it. In certain cases, the first three
typical types are sufficient.

● No repea:ng classes inside rows in the First Normal Form (1NF)


● Any non-key (suppor:ng) column value is based on the en:re
primary key in Second Normal Form (2NF).
● Third Normal Form (3NF) relies en:rely on the main key, with no
non-key (suppor:ng) column values.

Page 2 of 12
iNeuron Intelligence Pvt Ltd

3. In a database, what is denormaliza:on?

Denormaliza:on is a technique for retrieving data from a database


that is in a higher or lower regular form. It oTen incorporates data
from similar tables into a table to process redundancy.
Denormaliza:on applies necessary redundant terms to tables to
avoid complex joins and other complicated opera:ons.
Denormaliza:on does not imply that normaliza:on would not occur;
however, it occurs during the normaliza:on period.

4. In a database, what is the ACID property?

Atomicity, Consistency, Isola:on, and Durability (ACID) are acronyms


for ACID. It is used to ensure that data transfers in a computer system
are processed reliably.

● Atomicity:
Atomicity applies to accomplished or unsuccessful transac:ons. It is
when a transac:on refers to a specific logical data process. It ensures
that if one component of a process fails, the whole transac:on fails
as well, leaving the database state unchanged.

● Consistency:
Consistency means that the data adheres to one of the validity
guidelines. In basic terms, the transac:on never exits the ledger un:l
it has completed its state.

● Concurrency:
Concurrency management is the primary objec:ve of isola:on.

Page 3 of 12
iNeuron Intelligence Pvt Ltd

● Durability:
It refers to the fact that aTer a transac:on has been commiXed, it
can con:nue regardless of what happens in the interim. Example: a
power outage, a fire, or some other kind of malfunc:on.

5. In SQL, what is a view?

A view is a graphical table that holds a subset of a table's results.


There are no views at first because it takes up less room to store.
Data from one or more tables may be merged in a view, depending
on the rela:onship. In SQL Server, views are used to implement
authen:ca:on mechanisms. A database view is a searchable object
that can be searched with the same query as the table.

6. In SQL, what is a subquery?

A subquery is a query specified within another query to extract


details or informa:on from the database. The outer query in a
subquery is referred to as the key query. At the same :me, the inner
query is referred to as the subquery. You have first to run subqueries,
and the subquery's answer is then moved over to the main query.
One can embed this within every query, like SELECT, UPDATE, and
OTHER. Some reference operators, such as >, or =, may be used in a
subquery.

Page 4 of 12
iNeuron Intelligence Pvt Ltd

7. What is the dis:nc:on between SQL and PL/SQL programming


languages?

● SQL, or Structured Query Language, is a programming language for


interac:ng with rela:onal databases. It allows you to build and
manipulate databases. PL/SQL, on the other hand, is a SQL dialect
that is used to extend SQL's func:onality. Oracle Corpora:on created
it in the early 1990s. SQL incorporates procedural func:ons from
programming languages.

● A single query is executed in SQL, while a whole block of code is


executed in PL/SQL.

● On the first side, SQL acts as a source of data that we need to view,
while PL/SQL acts as a medium for displaying SQL data.

● PL/SQL statements can be embedded in SQL, but one can’t embed


SQL statements in PL/SQL since SQL does not accept any
programming languages or keywords.

8. What are the differences between aggregate and scalar func:ons?

Aggregate func:ons produce a single value aTer evalua:ng a


sta:s:cal equa:on. These equa:ons are made using data from a
table's columns. E.g., max() and count() are measured with numeric
in mind.

Page 5 of 12
iNeuron Intelligence Pvt Ltd

Based on the input value, scalar func:ons return a single value.


UCASE() and NOW(), for example, are determined with string in view.

9. What is the differen:a:on between locking, blocking, and


deadlocking?

When a link requires access to a piece of data in a database, it locks it


for a certain use such that no other transac:on may access it.

Blocking happens when a transac:on aXempts to achieve an


incompa:ble lock on an asset that another transac:on has already
locked. If the blocking transac:on breaks the safety, the blocked
transac:on stays blocked.

Deadlocking happens when two or more transac:ons lock a resource,


and each transac:on demands a lock on the resource that is already
locked by another transac:on. Since each transac:on is wai:ng for
the other to unlock the lock, neither will go on.

10. In SQL, what is ETL?

ETL is an acronym for Extract, Transform, and Load. We will have to


start by extrac:ng data from sources, which is a three-step opera:on.
When we combine data from various sources, we are leT with raw
data. One can translate this unstructured data into a more
manageable format in the second process. Finally, we'd have to feed

Page 6 of 12
iNeuron Intelligence Pvt Ltd

this clean data into soTware that would assist us in uncovering


insights.

11. In SQL, what is a schema?

There are several different en::es in our network, such as tables,


stored procedures, features, database members, etc. A schema will
be used to make sense of how many of these various bodies
communicate. As a result, a schema may be thought of as the logical
associa:on between all of the database's various en::es.

● This helps in a variety of respects un:l we have a good view of the


schema:
● We may choose which users have access to which database tables.
● We may change or introduce new rela:onships between the
database's various en::es.

Overall, you might think of a schema as a database's blueprint,


providing a full descrip:on of how various objects communicate with
one another and which users have access to which en::es.

12. In SQL, what is a unique key?

In SQL, a restric:on is known as a unique key. But, before we look at


what a primary key is, let's take a look at what a restric:on is in SQL.
Constraints are laws that are applied to data columns in a table.
These are used to restrict the types of informa:on that may be

Page 7 of 12
iNeuron Intelligence Pvt Ltd

entered into a chart. Constraints may be applied at the column or


table stage.

Unique Key:

When we assign a column the restric:on of a unique key, we're


saying that the column can't have any repeat values in it. To put it
another way, any of the documents in this column must be unique.

13. In SQL, what is the difference between a clustered index and a


non-clustered index?

In SQL, there are two types of indexes: clustered indexes and non
clustered indexes. From the standpoint of SQL results, the
discrepancies between these two indexes are cri:cal.

● There can only be one clustered index in each table, but there can
be several non-clustered indexes. (Around 250)

● A clustered index determines the physical storage of data in the


table. Data is stored in a clustered index, and similar data is stored
together, making data retrieval simple.

● Non-clustered indexes save only the details and direct you to the
data stored in clustered data, while clustered indexes store both the
data informa:on and the data itself.

● Reading from a clustered index from the same table is much easier
than reading from a non-clustered index.

Page 8 of 12
iNeuron Intelligence Pvt Ltd

● Non-clustered indexes have a layout independent from the data


row and sort and store data rows in the table or view based on their
main value, while clustered indexes sort and store data rows in the
table on their fundamental value.

14. What are some of the benefits and drawbacks of using a stored
procedure?

Benefits:

● A Stored Procedure can be used as modular programming, which


implies that it can be created once, stored, and called mul:ple :mes
as required. It allows for quicker implementa:on.

● It also decreases network demand while also improving data


protec:on.

Drawbacks:

The biggest drawback to a Stored Procedure is that it can only be


performed in the archive, which consumes addi:onal memory on the
database system.

Page 9 of 12
iNeuron Intelligence Pvt Ltd

15. In SQL, what is a "TRIGGER"?

When an insert, change or remove order is executed against a


par:cular table, a trigger enables you to run a batch of SQL code. A
TRIGGER is a series of ac:vi:es done if commands like insert, update,
or delete are provided by queries.

As these commands are issued to the machine, the trigger is said to


be ac:ve.

Triggers are a form of stored procedure specified to run automa:cally


in the background or aTer data changes.

The CREATE TRIGGER argument is used to create triggers.

16. What are the differences between local and global variables?

● Variables at the local level:


These variables may be used outside of the func:on or just reside
within it. Every other feature does not use or apply to these
variables.

● Variables at a global level:


These are the variables that can be accessed at any :me during the
program. When that feature is named, you can’t create any global
variables.

Page 10 of 12
iNeuron Intelligence Pvt Ltd

17. What is the difference between the operators’ BETWEEN and IN?

To represent rows centred on a set of values, use the BETWEEN


operator. Numbers, documents, and dates may all be used as values.
The BETWEEN operator returns the total number of values that exist
within a given set.

The IN condi:on operator is used to look for values inside a given


range of values. When there are several values to choose from, the
IN operator is used.

18. What is a Data warehouse, and how does it work?

A data warehouse is a central archive of data that has been compiled


from various sources of data. This data is then consolidated,
converted, and rendered usable for online analysis and mining. Data
Marts are a category of data used in warehouses.

19. What is SQL injec:on, and how does it work?

SQL injec:on is a hacking tac:c that black-hat hackers oTen use to


extract data from tables or databases. For example, if you go to a
website and enter the username and password, the intruder can
place malicious code on the server to get the username and
password straight from the database. If your database includes
sensi:ve data, it's always a good idea to protect it from SQL injec:on
aXacks.

Page 11 of 12
iNeuron Intelligence Pvt Ltd

20. In SQL, how can you insert several rows?

We begin by entering the keywords INSERT INTO, followed by the


name of the table into which the values will be inserted. We'll follow
that up with a descrip:on of the columns we'll need to apply values.
ATer that, we'll include the VALUES keyword and then the list of
values.

Page 12 of 12
iNeuron Intelligence Pvt Ltd

1. In SQL, how can you copy a table?

To copy data from one table to another, we may use the SELECT INTO
statement. We may either copy any of the data or only a few unique
columns.

2. Do similar items such as constraints, indices, columns, norm,


views, and filtered procedures get dropped when we drop a table?

Yes, SQL Server drops all associated items from a database, such as
constraints, indices, columns, defaults, and so on. However, since
views and sorted processes remain outside the chart, lowering the
table would not exclude them.

3. Is it possible to disable a trigger? If so, how do you go about doing


it?

Yes, we can disable a single database trigger with the command


"DISABLE TRIGGER triggerName ON>". We may also use the
command “DISABLE Trigger ALL ON ALL SERVER” to disable all
triggers.

Page 2 of 10
iNeuron Intelligence Pvt Ltd

4. What is a Livelock, exactly?

A livelock is one in which a request for an exclusive lock is


consistently rejected due to the interference of several compeYng for
mutual locks. When read transacYons build a table or page, a live
lock exists.

5. Is it possible to join a table by itself?

When you choose to build a result set that connects records in a


table with other records in the same table, you will connect to join
them together.

6. ExplanaYon of the Equi join.

Equi join is a category that describes whether two or more tables are
connected using the equal to operator. Only the state equal to(=)
between the columns in the table needs to be focused on.

7. What exactly is ISAM?

ISAM is an acronym for Indexed SequenYal Access Method. IBM


created it to store and extract data from tape-based secondary
storage structures.

Page 3 of 10
iNeuron Intelligence Pvt Ltd

8. What is White Box Database TesYng?

Database consistency and ACID properYes are examples of white box


tesYng. Logical perspecYves and database cause Decision Coverage,
CondiYon Coverage, and Statement Coverage are three types of
coverage—referenYal consistency rules for database tables, data
models, and database schemas.

9. What are the various kinds of SQL sandboxes?

There are three kinds of SQL sandboxes:

1. Safe Access Sandbox:


In this sefng, a user can execute SQL operaYons such as generaYng
stored procedures, triggers, and so on, but they cannot access
memory or build data.

2. Sandbox for External Access:


Users can access data without requiring the ability to control
memory allocaYon.

3. Unsafe Access Sandbox:


It is a set of untrusted codes that enable a user to access memory.

Page 4 of 10
iNeuron Intelligence Pvt Ltd

10. What is Database Black Box TesYng, and how does it work?

This test entails the following steps: 1. Data Mapping 2. Retrieval and
storage of data 3. Use Black Box research methods, including
Equivalence ParYYoning and Boundary Value Analysis (BVA).

11. Describe the Right Outer Join

When the user requires all the records from the Right table (Second
table) and equivalent or matching records from the First or Lel table,
this is helpful. The documents that aren't paired are referred to as
null records.

12. In SQL, what is a cursor?

In SQL, cursors are used to hold database tables. Cursors are divided
into two categories:

● Cursor Implicit
● Cursor Explicit

Cursor Implicit:

These implied cursors are the default cursors that are generated
automaYcally. The user cannot create an implied cursor.

Page 5 of 10
iNeuron Intelligence Pvt Ltd

Cursor Explicit:

User-defined cursors are known as explicit cursors.

13. How can I use SQL Server to construct a stored procedure?

You might be familiar with the idea of FuncYons if you've dealt with
other languages. Stored procedures in SQL are similar to funcYons in
other programming languages. It implies that we can save a SQL
statement as a saved procedure, which you can call anyYme.

We begin by entering the keywords CREATE PROCEDURE, followed by


the name of the stored procedure. You use the AS keyword, followed
by the SQL query used as a stored protocol. Finally, the GO keyword
is used.

14. What purpose does a foreign key constraint serve?

The foreign key constraint is a set of laws or constraints that


guarantee that the values in the child and parent tables fit.
Technically, this ensures that the foreign key constraint would ensure
the database's referenYal validity.

Page 6 of 10
iNeuron Intelligence Pvt Ltd

15. Define and demonstrate how to use an inner join.

SQL joins are used to create relaYonships with items in your


database. As a consequence, a join produces a result collecYon that
contains fields from two or more tables.

For instance, suppose one table contains informaYon about the


customer ID and fields relevant to the transacYons a customer has
created. In contrast, the other contains informaYon about the
customer ID and their private informaYon, such as first and last
names and email addresses. Thus, an inner join enables you to
generate an output that contains details from both tables but only
for the consumer IDs that fit in the two tables naturally, whether the
consumer ID area is configured to be a matching column.

16. What are the various database management system types?

Four disYnct forms of database management systems exist:

● It is a tree-like framework in which data is organized in a


hierarchical format. The parent may have several children in this
database, but each child should have a single parent.

● The network database is shown as a graph of many-to-many


relaYonships. Children could have several nodes and children in this
database.

Page 7 of 10
iNeuron Intelligence Pvt Ltd

● A table describes a relaYonal database. Columns and rows contain


values that are connected. Since it is so easy to use, it is the most
commonly used database.

● Object-oriented database:
This database stores data values and funcYons as items and both of
these objects are linked in various ways.

17. What is the difference between the commands DELETE and


TRUNCATE?

DELETE: This query is used to delete or erase a table or set of tables


from the database.

TRUNCATE: This declaraYon permanently deletes all data contained


inside a table.

The following table summarises the differences between the DELETE


and TRUNCATE commands:

● TRUNCATE is a DDL operaYon, while DELETE is a DML operaYon.


● TRUNCATE does not allow for true execuYon and triggers, while
DELETE allows for true execuYon and triggers.
● TRUNCATE can fail if main internaYonal restricYons reference a
table. Therefore, if we have a foreign key, we must execute the
DELETE instrucYon.

Page 8 of 10
iNeuron Intelligence Pvt Ltd

18. What are some of the most olen encountered SQL clauses for
SELECT queries?

SQL contains several SELECT statement clauses. The below are some
of the more olen used clauses:

● FROM: The FROM clause specifies which tables and views can be
used to analyze results. The tables and views specified in the
quesYon must exist at the moment when it is raised.

● WHERE: The WHERE clause specifies the criteria that would be


used to narrow the results table's material. We may use sub-selects
to search for fundamental relaYonships or relaYonships between a
column and a sequence of columns.

● GROUP BY: This clause is someYmes used in aggregate funcYons to


generate a single output row for each range of specific values in a
collecYon of columns or phrases.

● ORDER BY: The ORDER BY clause enables one to specify which


columns should be used to filter the table's results.

● HAVING: When an aggregate feature is used, the HAVING clause


filters the GROUP BY clause's results.

19. What are the different kinds of SQL views?

Views are divided into four categories of SQL. They have the
following:

Page 9 of 10
iNeuron Intelligence Pvt Ltd

● SimplisYc view:
A simplisYc view is built on a single table and does not have a GROUP
BY clause or any other funcYons.

● Complex view:
A complex view is constructed from several tables and contains a
GROUP BY clause in addiYon to funcYons.

● Inline view: A view constructed from a subquery in the FROM


clause; it acts as a temporary table and simplifies a complex query.

● Materialized view: A materialized view saves both the meaning and


the data. It creates data replicas by storing them physically.

20. What is the concept of a stored procedure? Explain.

A stored process is a fragment of SQL code that has been planned


that can be preserved and reused. In other words, a stored process is
a funcYon that consists of several SQL statements used to access the
database system. We may combine several SQL statements into a
stored method and execute it whenever and wherever it is required.

A stored procedure can be used to implement modular


programming, such that it can be created once, stored, and called
numerous Ymes as required. AddiYonally, this enables quicker
execuYon as opposed to running several queries.

Page 10 of 10
iNeuron Intelligence Pvt Ltd

1. Dis'nguish between OLTP and OLAP.

OLTP: This acronym stands for Online Transac'on Processing, and it


refers to a class of so@ware applica'ons that effec'vely facilitate
transac'on-based programs. One of the most cri'cal characteris'cs
of an OLTP framework is the ability to maintain consistency. The OLTP
method o@en uses decentralized prepara'on to avoid single points of
failure. This system is typically intended for a vast number of end-
users to conduct brief transac'ons. Addi'onally, queries in such
databases are generally basic, provide a quick response 'me, and
return a small number of records compared to other databases. As a
result, the amount of transac'ons per second serves as a useful
metric for such programs.

OLAP: OLAP is an acronym for Online Analy'cal Processing. It refers


to a class of so@ware systems characterized by a rela'vely low
volume of online transac'ons. The reliability of OLAP systems is
strongly dependent on response 'me. As a result, such frameworks
are o@en used for data mining and the maintenance of aggregated
historical data, and they are o@en integrated into mul'-dimensional
schemas.

2. What is the ideal way to use a cursor?

A database cursor is a control that lets one move along the rows of a
database. It can be thought of as a reference to a specific row within
the collec'on of rows. Cursors come in handy when doing database

Page 2 of 11
iNeuron Intelligence Pvt Ltd

opera'ons like extrac'on, addi'on, and removal. Here's how we


should bring it to use:

● DECLARE a cursor a@er every variable declara'on. The cursor


declara'on must always be consistent with the SELECT argument.
● Un'l fetching rows from the result array, OPEN statements must be
called to ini'alize the result collec'on.
● Use the FETCH statement to catch and move to the next row in the
result range.
● Use the CLOSE term to deac'vate the cursor.
● Finally, use the DEALLOCATE clause to remove the cursor defini'on
and clear all related proper'es.

3. What does the Intersect operator do?

The Intersect operator joins two select statements together,


returning only documents that are common to each of them. So, if
we have Table A and Table B over here and then use the Intersect
operator on these two tables, we'll just get documents that are
common to the select statements of these two tables.

4. What is the aim of the lock escala'on?

As SQL Server performs a transac'on, the lock manager can lock


database items to maintain database integrity. On the other hand,
the lock manager uses 96 bytes of memory for each locked en'ty it
manages. When dealing with many rows, this situa'on will
necessitate a large amount of memory to lock the rows. SQL Server

Page 3 of 11
iNeuron Intelligence Pvt Ltd

employs a method known as lock escala'on to reduce memory


usage. As row or page locks reach a certain threshold, the lock
escala'on func'on transforms row or page locks to table locks,
reducing memory consump'on.

5. What is the best way to convert between Unix and MySQL


'mestamps?

UNIX TIMESTAMP’s command translates MySQL 'mestamps to Unix


'mestamps, and the command FROM UNIXTIME converts Unix
'mestamps to MySQL 'mestamps.

6. What kinds of Colla'on Sensi'vity are there?

● Case sensi'vity: A and an are treated differently due to case


sensi'vity.

● Accent sensi'vity: the lecers a and á are given different treatment.

● Kana sensi'vity: Hiragana and Katakana, two Japanese kana


characters, are treated differently.

● Width sensi'vity: A single-byte (half-width) and a double-byte (full-


width) representa'on of the same character are treated differently.

Page 4 of 11
iNeuron Intelligence Pvt Ltd

7. What is the meaning of a NULL value?

A field with a NULL value is the same as one that has no value. A
NULL value is not the same as a zero value or an area of spaces. A
NULL value indicates that a field was le@ unused during record
crea'on. Assume that a table field is op'onal. And if you insert a
record without a value for the op'onal field, the field will be saved
with a NULL value.

8. What SQL are operators available?

SQL Operator is a reserved term used in the WHERE clause of a SQL


declara'on to execute opera'ons like arithme'c and comparisons. In
a SQL statement, these are used to define requirements.

Operators are divided into three categories:

● Arithme'c Operators
● Comparison Operators
● Logical Operators

9. Define the statement SELECT INTO.

The SELECT INTO statement is used to copy data from one table to
another. The old table's column names and forms would be carried
over to the current table. The AS clause may be used to construct
new column 'tles.

Page 5 of 11
iNeuron Intelligence Pvt Ltd

10. What is the difference between a Where clause and a Having


clause?

The Where clause is used to retrieve data from a database that


meets specific criteria. In contrast, the Having clause is used in
conjunc'on with the ‘GROUP BY' feature to retrieve data that meets
specific criteria defined by the Aggregate func'ons. If the Where
clause isn't compa'ble with Aggregate features, the Having clause
works.

11. In SQL, what are aggregate func'ons?

SQL aggregate func'ons evaluate a single value from the values in a


column and return it. The below are some of SQL's aggregate
func'ons:

● AVG()- This func'on returns the average value.

● COUNT()- Returns the number of rows in a table.

● MAX()- This func'on returns the highest value.

● MIN()- The smallest value is returned by the MIN() algorithm.

● ROUND()- This method rounds a number to the required number of


decimals.

● SUM()- This method returns the sum of two numbers.

Page 6 of 11
iNeuron Intelligence Pvt Ltd

12. In SQL, what are string func'ons?

String manipula'on is the primary use of SQL string func'ons. The


following are some of the most commonly used SQL string func'ons:

● LEN()- This func'on returns the length of a text field's length.


● LOWER()- This func'on lowers the case of character data.
● UPPER()- This func'on transforms data to upper case.
● SUBSTRING()- It extracts characters from a text sector using
SUBSTRING().
● LTRIM()- This is a func'on that removes all whitespace from the
start of a string.
● RTRIM()- This is a func'on that removes all whitespace from the
end of a string.
● CONCAT()- The concatenate method joins together several
character strings.
● REPLACE()- Replaces a string's text.

13. What is the concept of colla'on?

The expression "colla'on" refers to a collec'on of regula'ons that


specify how character data is sorted and compared. Character data is
filtered using regula'ons that determine case sensi'vity, character
width, accent marks, and kana character types, as well as choices for
determining case sensi'vity, character width, accent marks, and kana
character types.

Page 7 of 11
iNeuron Intelligence Pvt Ltd

14. What is the dis'nc'on between the NVL, IFNULL, and ISNULL
func'ons?

All three func'ons are iden'cal in their ac'vity. These func'ons are
used to subs'tute a value for a NULL value. Oracle developers use
NVL, MySQL developers use IFNULL, and SQL Server developers use
ISNULL.

15. What is the dis'nc'on between GUI and Database Tes'ng?

● User interface research, also known as front-end tes'ng, is a form


of GUI tes'ng. Back-end research, also known as data tes'ng, is a
form of database tes'ng.

● GUI Tes'ng is concerned about all testable items available for user
engagement, such as menus, forms, and so on. Database tes'ng
encompasses all testable items that are typically shielded from the
individual.

● The GUI tester does not need to be familiar with Structured Query
Language. Database Tes'ng necessitates the knowledge of
Structured Query Language.

16. What's the difference between a clustered table and a heap


table? What is the best way to tell whether the table is a heap table?

A heap table is when the data rows inside each data page are not
contained in any specific order. Furthermore, since the data page

Page 8 of 11
iNeuron Intelligence Pvt Ltd

series is not linked in a linked list, there is no specific order to


manage it. This is acributed to the lack of a clustered index in the
heap table.

A clustered table has a predefined clustered index on one or more


columns that determines the storage order of rows within data pages
and the order of pages within the table depending on the clustered
index key.

By querying the sys.par''ons system object, which has one row for
each par''on with index id equal to 0, the heap table can be
iden'fied. You may also use the sys.indexes system object to get
informa'on about the heap table indexes. For example, the id of that
index is 0, and its type is HEAP.

17. What exactly is the "Forwarding Pointers issue," and how can it
be resolved?

Forwarding Pointers are introduced into the heap as data


modifica'on opera'ons are done on heap table data sec'ons,
poin'ng to the new posi'on of the transferred data. Due to accessing
the old/original posi'on vs the current loca'on defined by the
forwarding pointers to get a certain value, these forwarding pointers
will trigger performance errors across 'me.

With SQL Server 2008, they introduced a new approach for dealing
with the forwarding pointers performance problem: the ALTER TABLE
REBUILD order, which rebuilds the heap table.

Page 9 of 11
iNeuron Intelligence Pvt Ltd

18. Describe the configura'on of a SQL Server Index that allows you
to navigate the table's data more quickly.

A SQL Server index is built in the form of a B-Tree layout. It consists of


8K pages, each of which is referred to as an index node. The B-Tree
layout gives the SQL Server Engine a quick way to pass between table
rows based on an index key that determines whether to traverse le@
or right, allowing it to extract the requested values without searching
any of the underlying table rows. You can imagine the possible
performance impact that scanning a huge database table might
cause.

The index's B-Tree structure is divided into three levels:

● SQL Server starts its data quest from the Root Level, which is the
top node that includes a single index page.

● The Leaf level is the lowest level of nodes in the tree that holds the
data pages we're searching for, with the number of leaf pages being
determined by the amount of data in the index.

● Finally, there is the Intermediate Level, which is one or more steps


between the root and the leaf levels and contains the main index
values and references to the next intermediate level or leaf data
pages. The index’s data storage capacity determines the number of
intermediate levels.

Page 10 of 11
iNeuron Intelligence Pvt Ltd

19. What is Index in SQL?

With the help of Indexes, informa'on retrieval from the database


happens faster and with greater efficiency. Thus, indexes improve
performance. There are three types of indexes:

Clustered: Used for reordering tables and searching informa'on with


key values.
Non-clustered: Used for maintaining the order of the tables.
Unique: They ban fields from having duplicate values.
There can be many non-clustered indexes in a table, however, there
can be only one clustered index.

20. What is a Synonym in SQL?


As the name suggests, a synonym is used to give different names to
the same object in the database. In the case of object-renaming or
object schema-change, exis'ng applica'ons can con'nue to use
older names because of synonyms. A synonym must only reference
an object and not another synonym. Addi'onally, synonyms can also
be used to reference objects in different databases or servers, by
using 3 or 4 part object names. There can be many names for a single
database object as long as all the names directly refer to the same
database object.

You must ensure that you know answers to such SQL interview
ques'ons as answering them correctly will give you the much-
needed confidence for the more difficult ones.

Page 11 of 11
iNeuron Intelligence Pvt Ltd

1. Men'on some advantages of Synonyms.

Below are some advantages of using Synonyms:

Synonyms create a layer of abstrac'on for the specific object


For objects, with complex 3 or 4 part names, residing on the same
server, Synonyms can give a simpler alias
Offers the flexibility to change object loca'on without having to
change the exis'ng code
When the name of an object is changed or dropped, Synonym offers
backward compa'bility for older applica'ons
Synonyms are also useful in front-end query tools such as Access
linked tables and spreadsheets if there is a direct link to these tables.

2. Are there any disadvantages to using Synonyms?

Yes, there are some disadvantages.

Synonyms are only loosely linked to the referenced object and thus,
can be deleted without warning when being used to reference a
different database object
Inside chaining cannot take place, meaning that the synonym of a
synonym cannot be created
One cannot create a table with the same Synonym name
The checking for the object for which the Synonym is created
happens at run'me and not at the 'me of crea'on. This means if
there is an error, such as a spelling error, it will only show up at
run'me crea'ng a problem in accessing the object

Page 2 of 9
iNeuron Intelligence Pvt Ltd

Synonyms cannot be referenced in DDL statements


For SQL interview ques'ons that ask you to talk about the
advantages or disadvantages of a certain component or tool, ensure
that you list as many as you can. Also, you can make your answer to
such an SQL interview ques'on meaty by adding personal anecdotes
about some of the advantages or disadvantages.

3.Are NULL values equal to zero?

No. NULL values show an absence of characters, whereas zero is a


numerical value. NULL values occur when a character is unavailable
or not known. NULL values should also not be confused with blank
space because a blank space is not supposed to have any data
aXached to it, whereas a NULL value shows a data record without
any value assigned to it.

4. What are Scalar subqueries and Correlated subqueries?

A Scalar subquery is when a query returns just one row and one
column of data. A Correlated subquery occurs when a query cannot
process without informa'on from an outer query. In such cases, table
aliases define the scope of the argument and the subquery is
parameterized by an outer query. Thus, there is a correla'on
between the inner and outer queries. As a result, back and forth

Page 3 of 9
iNeuron Intelligence Pvt Ltd

execu'on takes place where a single row of results from the outer
query passes parameters to the inner query.

5. What is the difference between NVL and NVL2 func'ons?

The func'on NVL (exp1, exp2) is a conversion func'on that changes


exp1 into the target exp2 under the condi'on that exp1 is NULL. The
data type of exp1 is the same as that of a return value. The func'on
NVL2 (exp1, exp2, exp3), on the other hand, is a checking func'on,
which determines whether exp1 is null or not. When exp1 is not null,
exp2 is returned as the result. When exp1 is null, exp3 is returned as
the result.

6. What do you mean by ‘auto increment’?

With the auto-increment command, one can generate unique


numbers when new records are added to a table. This func'on is
especially useful when one wants to automa'cally generate the
primary key field values upon inser'ng new records. This command
comes in handy on several plaaorms. The auto-increment command
for the SQL servers is “iden'ty”.

7. What is the main use of ‘recursive stored procedure’?

The main use of the recursive stored procedure is to make the code
calls 'll the 'me certain boundary condi'ons are reached. This helps

Page 4 of 9
iNeuron Intelligence Pvt Ltd

programmers enhance produc'vity by using the same code mul'ple


'mes.

An SQL interview ques'on like this one shows that even though some
of the advanced concepts may be easy to understand, they may be
difficult to recount when suddenly faced with the ques'on. Thus,
when you prepare for SQL interview ques'ons, ensure to revise all
types of concepts.

8. Describe ‘datawarehouse’ in SQL.

A ‘datawarehouse’ is a system used for analyzing and repor'ng data.


It is very similar to a physical warehouse where inventory is stored
and assessed before being sent to a customer. Here, data is stored,
analyzed, and reported. A datawarehouse func'ons as a central
repository of data integrated from different areas and sources and
makes this data available for use.

9. What is DBMS?

DBMS is an abbrevia'on for Database Management System for


crea'ng and managing databases. There are two types of databases:

Rela'onal Database Management Systems (RDBMS) - Data is stored


in tables.

Page 5 of 9
iNeuron Intelligence Pvt Ltd

Non-Rela'onal Database Management Systems - Mostly referred to


as NoSQL, stores data in non-tabular format.

10. What is the difference between SQL and MySQL?

Structured Query Language is u'lized for handling and modifying


data in rela'onal databases. With SQL, you can generate and alter
databases, tables, and other related objects, alongside execu'ng
various data opera'ons, including record inser'on, updates, and
dele'ons.

MySQL, on the other hand, is a specific rela'onal database


management system (RDBMS) that uses SQL as its primary language
for managing data. MySQL is an open-source RDBMS that is widely
used for web applica'ons,

11. List the type of SQL statements or subsets.

Below are the popular subsets used in SQL:

DDL (Data Defini'on Language) - It is used to define and structure


tables. Users can CREATE, ALTER, and DELETE the database tables.
DCL (Data Control Language) - Administrators use it to give users
privileges to GRANT or REVOKE permissions to the database.

Page 6 of 9
iNeuron Intelligence Pvt Ltd

DML (Data Manipula'on Language) - It allows users to either


UPDATE, INSERT, RETRIEVE, or DELETE informa'on from the
database.

12. Define what joins are in SQL.

Joins is a statement used to join two or more rows based on their


rela'onship. There are four types of Join statements:

Lep Join
Right Join
Inner Join
Full Join

13.What is a Primary Key?

A primary key is used to iden'fy unique rows or tables in a database.


Primary keys must always contain unique values. Null or duplicate
values are not considered primary keys.

14. What is a Foreign Key?

A foreign key is used to link two or more tables together. Its values
match with a primary key from a different table. Foreign keys are like
references between tables.

15.What is a unique key?

Page 7 of 9
iNeuron Intelligence Pvt Ltd

A unique key ensures a table has a unique value not found or


contained in other rows or columns. Unlike the primary key, the
unique key may have mul'ple columns. You can create a unique key
using the keyword "UNIQUE" when defining the table.

16.Create an employee table example.


Below is how to create an employee table:

Image 15-05-23 at 10.29 PM_11zon.webp

17.What is a SELECT statement used for?

SELECT is a DML command used for fetching one or more tables. It


queries for informa'on which usually returns a set of results.

18. Name the clauses used in the SELECT statement.

WHERE - filters the rows according to their criteria

ORDER BY - Sorts the tables/rows according to the ASC clause


(ascending order) or DESC clause (descending order)

GROUP BY - groups data from different tables that have similar rows
in the database

19. What are CHAR and VARCHAR?

Page 8 of 9
iNeuron Intelligence Pvt Ltd

CHAR is a fixed-length string character, whereas VARCHAR is a


variable-length string data structure. VARCHAR is preferred over
CHAR because it is more space-efficient when storing strings with
variable lengths.

20.List the types of rela'onships found in SQL.

One-to-one rela'onship - This rela'onship exists between two tables


when a single row in one table corresponds to a single row in another
table. This rela'onship is usually established using a foreign key
constraint.

One-to-Many/Many-to-One - This rela'onship exists between two


tables when a single row in one table corresponds to mul'ple rows in
another table. This rela'onship is also established using a foreign key
constraint.

Many-to-Many - This rela'onship exists between two tables when


mul'ple rows in one table correspond to mul'ple rows in another
table. This rela'onship is usually implemented using an intermediate
table that contains foreign keys to the two tables being related.

Page 9 of 9
iNeuron Intelligence Pvt Ltd

1. What is the difference between TRUNCATE and DELETE?

The truncate command is used when you want to delete all rows and
values from a table. It is a DDL type of command which is faster.
While the DELETE command is used when you want to delete a
specific row in a table. It is a DML command type and less efficient
than the truncate statement.

2. What is a cursor?

A cursor is a temporary memory allocated by the server when


performing any DML queries. They are used to store Database Tables.
Basically a cursor in sql is an object in database code that allows
processes to process rows one by one. While in other programming
languages sets of data is processed individually through a loop, in
SQL, data is processed in a set through a cursor.

Two types of cursors are Implicit cursors and Explicit cursors.

Implicit Cursors: They are Default Cursors of SQL SERVER. Allocated


when the user performs DML operaSons.

Explicit Cursors: They are created by users in need. They are used for
Fetching data from Tables in Row-By-Row Manner.

Page 2 of 8
iNeuron Intelligence Pvt Ltd

3. Define normalizaSon.

NormalizaSon is a method of breaking down larger, complex data


into smaller tables. It helps in filtering unnecessary, redundant data
and leaves only unique values.

4. What is ETL?

ETL is an acronym for Extract, Transform, and Load. It is a process


where you extract data from different sources, transform the data
quality, and finally load it into the database.

5. What is the difference between Local and Global variables?

Local variables are used inside a funcSon and can’t be reused by


other funcSons, whereas global variables can be accessed and used
throughout the program.

6. What is a subquery?

A subquery is a query that is found in another query. Usually referred


to as an inner query, its output is typically used by another query.

7. What is ACID?

Page 3 of 8
iNeuron Intelligence Pvt Ltd

ACID in SQL refers to a set of properSes that guarantee the reliable


and consistent processing of database transacSons. It is an acronym
where each le_er stands for one of the properSes:

Atomicity: Ensures that a transacSon is either fully completed or not


executed at all. If any part of a transacSon fails, the enSre transacSon
is rolled back, and the database remains unchanged.

Consistency: Guarantees that the database transiSons from one


consistent state to another upon the compleSon of a transacSon. All
data must adhere to predefined rules and constraints.

IsolaSon: Provides a degree of separaSon between concurrent


transacSons, ensuring that they do not interfere with one other. It
helps maintain data integrity by controlling the visibility of changes
made by one transacSon to another.

Durability: Guarantees that aaer a transacSon has been commi_ed,


the modificaSons made to the database become permanent, even if
a system failure or crash occurs.

ACID properSes are vital in maintaining data integrity and


consistency in relaSonal database management systems (RDBMS)
and ensuring the robustness of transacSons.

8. Define stored procedure.

A stored procedure is a funcSon that contains a group of query


statements that can be reused. They are stored inside a named

Page 4 of 8
iNeuron Intelligence Pvt Ltd

object in the database and can be executed anySme they are


required.

9. What are triggers in SQL?

Triggers are special stored procedures that run when there's an event
in the database server, such as changing data in a table. A trigger is
different from a regular stored procedure as it cannot be directly
called like a regular stored procedure.

10. Define an ER.

An EnSty RelaSonship (ER) diagram is a visual representaSon of the


relaSonship tables found in the database. It displays the table
structures and primary and foreign keys.

11. When are Triggers used?

Triggers in SQL are used to automaScally enforce business rules or


maintain data integrity by execuSng predefined acSons in response
to specific database events, such as INSERT, UPDATE, or DELETE.
Common use cases include data validaSon, data audiSng, and
maintaining referenSal integrity or complex relaSonships between
tables.

Page 5 of 8
iNeuron Intelligence Pvt Ltd

12. What are Sparse Columns?

Sparse columns are columns that provide opSmized storage for null
values. They reduce space that is usually taken up by null values and
can be defined by using CREATE or ALTER statements.

13. Define Check Constraints.

Check constraints are used for checking and ensuring that values in a
table follow domain integrity. Users can apply Check constraints to
single and mulSple columns.

14. What is CollaSon?

In SQL, collaSon refers to a set of rules that govern the proper


ordering, comparison, and representaSon of characters in a
parScular character set or encoding. CollaSon influences how text
data in a database is sorted, searched, and compared. It typically
accounts for various linguisSc consideraSons such as case sensiSvity,
accent sensiSvity, and specific language-based convenSons.

15. Write a SQL query for the salespeople and customers who live in
the same city.

Page 6 of 8
iNeuron Intelligence Pvt Ltd

To write a SQL query that shows salespeople and customers who live
in the same city, you need to have informaSon about both
salespeople and customers. Here's an example SQL query assuming
you have two tables: salespeople and customers.

In this query, we're selecSng the salesperson name, customer name,


and city from two tables (salespeople and customers) using an INNER
JOIN to connect them based on the condiSon that the city in the
salespeople table equals the city in the customers table.

16. Write a SQL query to find orders where the order amount exists
between 1000 and 5000.

To find orders with an order amount between 1000 and 5000, you
can use the following SQL query:

In this query, replace "orders" with the actual name of your orders
table, and "order_amount" with the appropriate column name
represenSng the order amount in your table. This query will return all
rows where the order amount falls between 1000 and 5000,
inclusive.

Page 7 of 8
iNeuron Intelligence Pvt Ltd

17. What is a Filtered Index?

A filtered index is a non-clustered index that comes with opSmized


disk restore. It is created when a column has few values for queries.
The purpose of a filtered index is to opSmize query performance by
reducing the size of the index and the number of index pages that
need to be read. It helps in improving performance, storage
reducSon, and index maintenance.

18. What is a Clause?

A clause is one of the SQL query statements that filters or customizes


data for a query. It allows users to limit the results by providing a
condiSonal statement to the query. It is typically used when a large
amount of data is in the database.

19. What is a Case FuncSon?

A case funcSon is a SQL logic that uses the if-then-else statements. It


evaluates the condiSons of a table and returns mulSple result
expressions.

20. Define a VIEW.

A view is a virtual table containing values in one or mulSple tables.


Views restrict data by selecSng only required values to make queries
easy.

Page 8 of 8
iNeuron Intelligence Pvt Ltd

1. What is a SCHEMA?

A schema in SQL is a collec9on of database objects, including tables,


indexes, sequences, and other schema objects. It defines how data is
organized in a rela9onal database system. It is used to manage
database objects and control access to them by different users.

2. Differen9ate between HAVING and WHERE clauses.

These condi9ons are used for searching values except that the
HAVING clause is used with the SELECT statement accompanied by
the GROUP BY clause. The HAVING clause is used in combina9on with
the GROUP BY clause to filter the data based on aggregate values,
while the WHERE clause is used to filter the data based on individual
values.

3. Define what is meant by CTE.

In SQL, a CTE (Common Table Expression) is a temporary result set,


o[en used to simplify complex queries by breaking them into smaller,
more manageable pieces. A CTE is created using the WITH clause and
is available only within the context of the query that follows it.

4. What are SQL operators?

Page 2 of 8
iNeuron Intelligence Pvt Ltd

Operators are special characters or words that perform specific


opera9ons. They are used with the WHERE clause to filter data in
most cases.

5. What is CDC?

CDC means change data capture. It records the recent ac9vi9es made
by the INSERT, DELETE, and UPDATE statements made to the tables. It
is basically a process of iden9fying and capturing changes made to
data in the database and returning those changes in real 9me. This
capture of changes from transac9ons in a source database and
transferring them to the target, all in real-9me, keeps the system in
sync. This allows for reliable data copying and zero-down9me cloud
migra9ons.

6. Define Auto Increment.

“AUTO INCREMENT” is a clause used to generate unique values


whenever a new record is created and inserted into a table. It means
that every 9me a new row is inserted into the table, the database
system automa9cally generates a new value for that column.

7. What is a COALESCE?

COALESCE is a func9on that takes a set of inputs and returns the first
non-null values. It is used to handle null values in a query's result set.

Page 3 of 8
iNeuron Intelligence Pvt Ltd

8. What is Data Integrity?

Data integrity maintains security measures to the database by


implemen9ng rules and processes during the design phase. It helps
with consistency and accuracy in the database.

9. Classify views.

Views can be classified into four categories:

Simple View - This is based on a single table and does not have a
GROUP BY clause or other features.

Complex View - This is built from several tables and includes a


GROUP BY clause and func9ons.

Inline View - This is constructed using a subquery in the FROM clause,


crea9ng a temporary table that streamlines complex queries.

Materialized View- This saves both the defini9on and the details. It
builds data replicas by physically preserving them.

10. What is a SQL Injec9on?

SQL injec9on is a flaw in a code that allows akackers to take control


of back-end processes and access, retrieve, and delete sensi9ve data
stored in databases. This strategy is widely u9lized using data-driven
apps to get access to sensi9ve data and execute administra9ve tasks
on databases.

Page 4 of 8
iNeuron Intelligence Pvt Ltd

11. Explain UNION operator.

In SQL, the UNION operator is used to combine the result sets of two
or more SELECT statements into a single result set. The resul9ng set
consists of unified records from both queries, and any duplicate rows
are eliminated. The UNION operator requires that the SELECT
statements being combined have the same number of columns and
that the data types of the corresponding columns are compa9ble.

12. What is the purpose of INTERSECT operator?

An INTERSECT operator combines two or more SELECT statements


and returns only the values common from the SELECT statements.
For example, we have table1 and table2; when we apply INTERSECT
to the query statement, only the common values are returned from
the SELECT statements.

13. Differen9ate the operators BETWEEN and IN.

BETWEEN operator is used for represen9ng rows based on specific


values. It then returns the total number of values found between two
specified values. While IN operator is used to search for values within
a given range of values. We apply the In operator if there is more
than one value to define the range.

Page 5 of 8
iNeuron Intelligence Pvt Ltd

14. What is white box tes9ng?

White box tes9ng is a method for dealing with internal database


structures where users can hide specifica9on details. The methods
involve the following:

Elimina9ng internal errors


Checks the consistency of the database
Performs tes9ng for func9ons such as triggers, views, and basic
queries.

15. Explain black box tes9ng.

Black box tes9ng is a method that tests the interface of the database.
It verifies incoming data, mapping details, and data used for query
func9ons. Here the tester provides the input and watches the output
generated by the system.

The black box tes9ng involves tes9ng the database by trea9ng it as a


"black box," focusing on its external behavior and func9onality,
without any knowledge of its internal structure, design, or code. The
tester provides input to the database through its interfaces (such as
SQL queries, stored procedures, or API calls), and observes the
output generated by the database in response to that input.

It enables us to find how the system behaves to expected and


unexpected user ac9ons, response 9me, reliability issues, etc. Learn
more about Black Box Tes9ng and White Box Tes9ng.

Page 6 of 8
iNeuron Intelligence Pvt Ltd

16. Define a TABLESAMPLE.

A TABLESAMPLE is a SQL statement that extracts random data using


the FROM condi9on from a TABLE. It is done when the user doesn’t
need the en9re dataset but only a specific table por9on.

17. Explain Database mirroring.

Database mirroring is a disaster recovery technique used in SQL


Server to provide redundancy and failover capabili9es for cri9cal
databases. It involves maintaining two copies of a database, known
as the principal database and the mirror database, on two separate
servers. Database mirroring provides a highly reliable and robust
solu9on for cri9cal databases, with the ability to maintain high
availability, reduce down9me, and provide a quick recovery in case of
a failure.

18. What is the database engine used for?

The database engine is the underlying so[ware mechanism used for


storing, processing, and securing data. It processes queries, grants
access, and op9mizes transac9ons in the database engine.

Page 7 of 8
iNeuron Intelligence Pvt Ltd

19. Define PL/SQL.

Procedural Language for SQL is an extension that allows users to


write code in a procedural language. The code can be run in the same
SQL server and has features such as high security, scalability, and
flexibility.

20. What does the WITH TIES statement do?

The WITH TIES statement is used in SQL queries to include addi9onal


rows that have the same values as the last row in the result set. It is
typically used in conjunc9on with the TOP or LIMIT statement and
the ORDER BY clause to return addi9onal rows beyond the specified
limit.

Page 8 of 8
iNeuron Intelligence Pvt Ltd

1. Where do you use the DISTINCT statement?


The DISTINCT condi:on is accompanied by the SELECT statement to
remove all duplicate records and return unique values. It is used to
eliminate duplicate results returned from a SELECT statement.

2. What is the MERGE statement used for?

The MERGE statement in SQL is used to perform a combina:on of


INSERT, UPDATE, and DELETE opera:ons on a target table based on
the data present in a source table. It is also known as UPSERT
opera:on, which means to update the exis:ng record if it exists,
otherwise insert a new record.

3. What is an ALIAS?

An ALIAS command is a name given to a table. It is used with the


WHERE statement when users need to iden:fy a par:cular table.
They are oRen used to increase the readability of the column names.
An alias exists only for the :me the query exists and is created with
the AS keyword.

Alias Syntax for column

SELECT column_name AS alias_name FROM table_name;

Alias syntax for table

Page 2 of 9
iNeuron Intelligence Pvt Ltd

SELECT column_name(s) FROM table_name AS alias_name;

4. What does the REPLACE func:on do?

The REPLACE func:on is used to replace exis:ng characters in all


instances. The func:on searches the original string, iden:fies all
instances of the substring to be replaced and then replaces them
with the specified replacement substring.

5. What is the difference between UNION and UNION ALL? Provide


examples.

UNION combines the result of two SELECT statements by removing


duplicate records and returning a sorted result set.

UNION ALL also combines the result of two SELECT statements, but it
does not remove duplicates and does not sort the result set. It is
faster due to less processing overhead.

6. What does STUFF() do?

The STUFF() func:on deletes a string sec:on and inserts another part
into a string star:ng from a specified posi:on.

Syntax:

Page 3 of 9
iNeuron Intelligence Pvt Ltd

STUFF (source_string, start, length, add_string)

Where:-

source_string: This is the original string to be modified.


start: It is the star:ng index from which the given length of characters
are deleted, and a new sequence of characters will be added.
length: The number of characters to be deleted from the star:ng
index in the main string.
add_string: The new set of characters (string) to be inserted in place
of deleted characters from the star:ng index

7. Differen:ate between RENAME and ALIAS.

RENAME changes the name of a column or table, while ALIAS gives


an addi:onal name to an exis:ng object. RENAME is permanent,
whereas ALIAS is a temporary name.

8. How would you op:mize a slow-performing SQL query? Discuss


key steps and factors to consider.

To op:mize a slow-performing SQL query, consider the following


steps:

Examine the execu:on plan, iden:fying poten:al bodlenecks.


Use efficient JOIN opera:ons (e.g., INNER JOIN, OUTER JOIN) for
quicker results.
Op:mize SELECT statement, retrieving only necessary columns.

Page 4 of 9
iNeuron Intelligence Pvt Ltd

Use appropriate indexes on frequently searched columns.


Implement pagina:on, limi:ng the returned records using OFFSET
and FETCH or LIMIT.
Filter data as early as possible with WHERE clauses to reduce the
query's scope.
Avoid using subqueries when possible, op:ng for JOINs or CTEs.
Use aggregate func:ons and GROUP BY effec:vely.
Op:mize the database schema and normalize tables.

9. What is an Index-Seek opera:on, and when does the query


op:mizer choose to perform this opera:on?

Index-Seek is a faster and more efficient way to search for records in


a table. It is used when the query op:mizer chooses to navigate the
index's B-tree structure directly to find the specific records, rather
than scanning the en:re table/index. It is performed when an
appropriate index exists and the query matches the index condi:ons
(e.g., WHERE clause with indexed columns).

10. What is a deadlock in SQL, and how can you prevent them?

A deadlock occurs when two or more transac:ons are wai:ng


indefinitely for each other to release resources such as locks on rows
or tables. To prevent deadlocks:

Page 5 of 9
iNeuron Intelligence Pvt Ltd

Access objects in a consistent order, reducing the chances of cyclic


dependencies.
Reduce lock :me, ensuring minimal :me between acquiring and
releasing locks.
Apply appropriate isola:on levels to limit the locking scope
Use transac:ons with a smaller scope and avoid running large, long-
running transac:ons.
Implement a deadlock detec:on and handling mechanism, such as
:meouts or retry logic.

11. What is a live lock?

A live lock is a situa:on where two or more processes are ac:vely


trying to make progress but are blocked and unable to proceed. In
live lock, the processes are not blocked on resources but are ac:vely
trying to complete the tasks causing them to interfere with each
other. It is difficult to detect and resolve Live locks because the
system does not crash or give an error message.

12. When do you use COMMIT?

COMMIT is used when a transac:on happens, and the changes are


permanently recorded in the database. Once you use COMMIT, you
can't revert the changes unless you perform another transac:on to
reverse them.

13. Write a query that shows a non-equi join.

Page 6 of 9
iNeuron Intelligence Pvt Ltd

A non-equi join is a method of joining two or more tables without an


equal condi:on. Operators such as <>,!=,<,>,BETWEEN are used.
!=,<,>,Between. See below:

14. Write a query showing the use of equi join.

Equi joins two or more tables using the equal sign operator (=).

15. What is the difference between COMMIT and ROLLBACK?

COMMIT is a statement executed to save the changes made to a


database. It ensures that the changes made within a transac:on are
permanent and cannot be rolled back. On the other hand, a
ROLLBACK statement is executed to revert all the changes made on
the current transac:on to the previous state of the database.

16. What is the difference between GETDATE and SYSDATETIME.

GETDATE func:on returns the date and :me of a loca:on. While on


the other hand, the SYSDATETIME func:on returns the date and :me
with a precision of 7 digits aRer the decimal point.

Page 7 of 9
iNeuron Intelligence Pvt Ltd

17. What is the difference between a temporary table and a table


variable in SQL Server?

Temporary Table: A temporary table is created using CREATE TABLE


statement with a prefix #, and it is stored in the tempdb system
database. Temporary tables support indexing, sta:s:cs, and can have
constraints. There are two types of temporary tables: local (visible
only to the session that created it) and global (accessible to all
sessions).

Table Variable: A table variable is declared using DECLARE statement


with @ prefix, and it is also stored in the tempdb system database.
Table variables don't require explicit dropping, have no sta:s:cs,
limited constraints, and are scoped to the batch or stored procedure
in which they are declared.

18.What is the use of the SET NOCOUNT func:on?

SET NOCOUNT func:on is a func:on that helps to stop the message


that indicates how many rows are being affected while execu:ng a T-
SQL statement or stored procedure.

19.Define isola:on in SQL transac:ons.

In SQL transac:ons, isola:on refers to the degree to which a


transac:on is separated from other transac:ons taking place
concurrently within a database management system (DBMS). It is one
of the four key proper:es of database transac:ons - known as ACID

Page 8 of 9
iNeuron Intelligence Pvt Ltd

(Atomicity, Consistency, Isola:on, Durability). Isola:on levels


determine the extent to which changes made by one transac:on are
visible to other simultaneous transac:ons, and each level provides
different performance and side effects.

20. What is the use of a Graph Database?

The main advantage of using graph databases is their ability to


efficiently handle interconnected data, making them suitable for use
cases where rela:onships between en::es are deep, complex, or
frequently changing. They excel at tasks such as performing complex
graph analysis, traversing hierarchical rela:onships, or finding
paderns in connected data.

Page 9 of 9
iNeuron Intelligence Pvt Ltd

1. Write a query where you create a table from another without


duplica8ng the values.

This will create a new table with the same structure as the old table
but without the values from the previous table.

2. What is a covering index, and when should you use one?

A covering index is a non-clustered index that includes all the


columns required to sa8sfy a par8cular query, elimina8ng the need
for an addi8onal key lookup in the base table. It can significantly
improve query performance by reducing I/O opera8ons, especially
when the included columns are frequently accessed or filtered in the
query.

3. Define a Term
Some basic SQL interview ques8ons are about defining a term in SQL.
The interviewer may ask you to explain some technical concepts,
explain the differences between two concepts, or explain how a
concept works.

Following are some of the terms you should be familiar with to


answer these SQL interview ques8ons successfully:

Primary Key, Foreign Key, and Unique Key


RDBMS vs. DBMS
Constraints
Cursors
Normaliza8on vs. Denormaliza8on

Page 2 of 7
iNeuron Intelligence Pvt Ltd

Index
Triggers
Clustered vs. Non-Clustered Index

4. What is the difference between a primary key and a foreign key in


SQL?
Answer: A primary key in SQL is a column or a set of columns that
uniquely iden8fies each row in a table, while a foreign key in SQL is a
column or a set of columns that refers to the primary key of another
table.

5. What is a database trigger in SQL?


Answer: A database trigger in SQL is a set of SQL statements that are
automa8cally executed in response to a specific event, such as an
INSERT, UPDATE, or DELETE statement, at the database level.

6. What is a recursive common table expression (CTE) in SQL?


Answer: A recursive common table expression (CTE) in SQL is a way
to define a temporary result set that can reference itself in a
recursive manner, allowing you to perform complex queries that
involve hierarchical or recursive data structures.

7. What is the difference between a subquery and a join in SQL?


Answer: A subquery is a query that is nested inside another query
and is used to retrieve data to be used in the main query. A join is
used to combine rows from two or more tables based on a related
column between them. The main difference between the two is that
a subquery returns a result set to the main query, while a join
combines two or more tables based on a common column or set of
columns.

Page 3 of 7
iNeuron Intelligence Pvt Ltd

8. What is a correlated subquery in SQL?


Answer: A correlated subquery in SQL is a subquery that refers to a
column from the outer query. The subquery uses the value from the
outer query to filter the result set of the subquery. This type of
subquery can be used to perform calcula8ons on each row of a table
based on data from related tables.

9. What is a scalar subquery in SQL?


Answer: A scalar subquery in SQL is a subquery that returns a single
value. This type of subquery can be used in an expression, such as a
SELECT statement or a WHERE clause. The result of a scalar subquery
can be used in a comparison, calcula8on, or other opera8on.

10. What is a lateral join in SQL?


Answer: A lateral join in SQL is a join that allows you to reference a
table that appears earlier in the FROM clause. This type of join is
useful for queries that involve nested queries or complex
calcula8ons. The lateral join keyword in SQL is LATERAL.

11. What is a self-join in SQL?


Answer: A self-join in SQL is a join that is performed between two
instances of the same table. This type of join is used when you want
to compare data within the same table, such as when you want to
compare sales data for a given salesperson with sales data for all
salespeople. To perform a self-join, you use table aliases to
differen8ate between the two instances of the table.

Page 4 of 7
iNeuron Intelligence Pvt Ltd

12. Who generally uses SQL?

SQL is generally used by people who deal with data and databases on
a daily basis. Database management Administrators, data analysts,
and developers make use of SQL to deal with data.
Why is SQL a popular choice among developers?
SQL is quite a popular choice among Developers as it is easy to use,
and the syntax is quite easy to understand and apply. It also enables
developers and data analysts the required flexibility and scalability.
It is also easily available, and the func8ons can be efficiently carried
out on vast stores of data.

13. What are the uses of SQL?

There are different uses of SQL, such as:


· It helps in crea8ng, managing, and dele8ng tables.
· It performs the basic opera8onal func8ons such as search, filter,
sort, create, drop, and alter in the most efficient way possible.
· It provides developers the flexibility to manipulate any table in
the database.

14. What is a “Keyword” in SQL?

Keywords, as the name indicates, are words that enable one to find
similar words in the database or the SQL table.

Page 5 of 7
iNeuron Intelligence Pvt Ltd

For instance, the keyword “employee” will find or sort out similar
words in the datasheet.
If you want to find the employee with the name “Mahesh,” the
keyword will help you to iden8fy the names of the employees with
the name Mahesh within a few seconds.

15. What is the difference between a having clause and a where


clause in SQL?
Answer: A where clause in SQL is used to filter rows before grouping
them, while a having clause is used to filter groups ajer grouping
them.

16. What is the difference between a correlated subquery and a non-


correlated subquery in SQL?
Answer: A correlated subquery in SQL is a subquery that uses values
from the outer query, while a non-correlated subquery is a subquery
that can be executed independently of the outer query.

17. What is a common table expression (CTE) in SQL?


Answer: A common table expression (CTE) in SQL is a temporary
result set that is defined within a SELECT, INSERT, UPDATE, or DELETE
statement.

18. What is the difference between a scalar func8on and a table


func8on in SQL?
Answer: A scalar func8on in SQL returns a single value, while a table
func8on in SQL returns a table.

Page 6 of 7
iNeuron Intelligence Pvt Ltd

19. What is a window func8on in SQL?


Answer: A window func8on in SQL is a func8on that operates on a
set of rows, called a window, and returns a value for each row.

20. What is the difference between a correlated and a non-correlated


subquery in SQL?
Answer: A correlated subquery in SQL is a subquery that references
one or more columns from the outer query, while a non-correlated
subquery is a subquery that can be executed independently of the
outer query.

21. What is a common table expression (CTE) in SQL?


Answer: A common table expression (CTE) in SQL is a temporary
result set that is defined within a SELECT, INSERT, UPDATE, or DELETE
statement.

22. What is the difference between a scalar func8on and a table


func8on in SQL?
Answer: A scalar func8on in SQL returns a single value, while a table
func8on in SQL returns a table.

Page 7 of 7
iNeuron Intelligence Pvt Ltd

Q1. What are the different subsets of SQL?

Ans-

• Data Defini;on Language (DDL) – It allows you to perform various


opera;ons on the database such as CREATE, ALTER, and DELETE
objects.
• Data Manipula;on Language (DML) – It allows you to access
and manipulate data. It helps you to insert, update, delete and
retrieve data from the database.
• Data Control Language (DCL) – It allows you to control access to
the database. Example – Grant, Revoke access permissions.

Q2. What do you mean by DBMS? What are its different types?

Ans- A Database Management System (DBMS) is a soTware


applica;on that interacts with the user, applica;ons, and the database
itself to capture and analyze data. A database is a structured collec;on
of data.

A DBMS allows a user to interact with the database. The data stored in
the database can be modified, retrieved and deleted and can be of any
type like strings, numbers, images, etc.

There are two types of DBMS:

• Rela;onal Database Management System: The data is stored in


rela;ons (tables). Example – MySQL.
• Non-Rela;onal Database Management System: There is no
concept of rela;ons, tuples and aXributes. Example – MongoDB

Page 2 of 11
iNeuron Intelligence Pvt Ltd

Q3. What is a Self-Join?

Ans- A self-join is a type of join that can be used to connect two


tables. As a result, it is a unary rela;onship. Each row of the table is
aXached to itself and all other rows of the same table in a self-join.
As a result, a self-join is mostly used to combine and compare rows
from the same database table.

Q4. What is the SELECT statement?

Ans- A SELECT command gets zero or more rows from one or more
database tables or views. The most frequent data manipula;on
language (DML) command is SELECT in most applica;ons. SELECT
queries define a result set, but not how to calculate it, because SQL is
a declara;ve programming language.

Q5. What are some common clauses used with SELECT query in SQL?

Ans- The following are some frequent SQL clauses used in


conjunc;on with a SELECT query:

WHERE clause: In SQL, the WHERE clause is used to filter records that
are required depending on certain criteria.
ORDER BY clause: The ORDER BY clause in SQL is used to sort data in
ascending (ASC) or descending (DESC) order depending on specified
field(s) (DESC).
GROUP BY clause: GROUP BY clause in SQL is used to group entries
with iden;cal data and may be used with aggrega;on methods to
obtain summarised database results.
HAVING clause in SQL is used to filter records in combina;on with
Page 3 of 11
iNeuron Intelligence Pvt Ltd

the GROUP BY clause. It is different from WHERE, since the WHERE


clause cannot filter aggregated records.

Q6. What is UNION, MINUS and INTERSECT commands?

Ans- The UNION operator is used to combine the results of two


tables while also removing duplicate entries.

The MINUS operator is used to return rows from the first query but
not from the second query.

The INTERSECT operator is used to combine the results of both


queries into a single row.
Before running either of the above SQL statements, certain
requirements must be sa;sfied –
Within the clause, each SELECT query must have the same amount of
columns.
The data types in the columns must also be comparable.
In each SELECT statement, the columns must be in the same order.

Q7. What is Cursor? How to use a Cursor?

Ans- ATer any variable declara;on, DECLARE a cursor. A SELECT


Statement must always be coupled with the cursor defini;on.

Page 4 of 11
iNeuron Intelligence Pvt Ltd

To start the result set, move the cursor over it. Before obtaining rows
from the result set, the OPEN statement must be executed.

To retrieve and go to the next row in the result set, use the FETCH
command.

To disable the cursor, use the CLOSE command.

Finally, use the DEALLOCATE command to remove the cursor


defini;on and free up the resources connected with it.

Q8. List the different types of rela;onships in SQL.

Ans- There are different types of rela;ons in the database:

One-to-One – This is a connec;on between two tables in which each


record in one table corresponds to the maximum of one record in the
other.

One-to-Many and Many-to-One – This is the most frequent


connec;on, in which a record in one table is linked to several records
in another.

Many-to-Many – This is used when defining a rela;onship that


requires several instances on each sides.

Self-Referencing RelaAonships – When a table has to declare a


connec;on with itself, this is the method to employ.

Q9. What is OLTP?

Page 5 of 11
iNeuron Intelligence Pvt Ltd

Ans- OLTP, or online transac;onal processing, allows huge groups of


people to execute massive amounts of database transac;ons in real
;me, usually via the internet. A database transac;on occurs when
data in a database is changed, inserted, deleted, or queried.

Q10. What are the differences between OLTP and OLAP?

Ans- OLTP stands for online transac;on processing, whereas OLAP


stands for online analy;cal processing. OLTP is an online database
modifica;on system, whereas OLAP is an online database query
response system.

Q11. How to create empty tables with the same structure as another
table?

Ans- To create empty tables:


Using the INTO operator to fetch the records of one table into a new
table while seing a WHERE clause to false for all entries, it is
possible to create empty tables with the same structure. As a result,
SQL creates a new table with a duplicate structure to accept the
fetched entries, but nothing is stored into the new table since the
WHERE clause is ac;ve.

Q12. What is PostgreSQL?

Page 6 of 11
iNeuron Intelligence Pvt Ltd

Ans- In 1986, a team lead by Computer Science Professor Michael


Stonebraker created PostgreSQL under the name Postgres. It was
created to aid developers in the development of enterprise-level
applica;ons by ensuring data integrity and fault tolerance in systems.
PostgreSQL is an enterprise-level, versa;le, resilient, open-source,
object-rela;onal database management system that supports
variable workloads and concurrent users.

Q13. What are SQL comments?

Ans- SQL Comments are used to clarify por;ons of SQL statements


and to prevent SQL statements from being executed. Comments are
quite important in many programming languages. The comments are
not supported by a MicrosoT Access database. As a result, the
MicrosoT Access database is used in the examples in Mozilla Firefox
and MicrosoT Edge.
Single Line Comments: It starts with two consecu;ve hyphens (–).
Mul;-line Comments: It starts with /* and ends with */.

Q14. What is the usage of the NVL () func;on?

Ans- You may use the NVL func;on to replace null values with a
default value. The func;on returns the value of the second
parameter if the first parameter is null. If the first parameter is
anything other than null, it is leT alone.

Page 7 of 11
iNeuron Intelligence Pvt Ltd

This func;on is used in Oracle, not in SQL and MySQL. Instead of


NVL() func;on, MySQL have IFNULL() and SQL Server have ISNULL()
func;on.

Q15. Explain character-manipula;on func;ons? Explains its different


types in SQL.

Ans- Change, extract, and edit the character string using character
manipula;on rou;nes. The func;on will do its ac;on on the input
strings and return the result when one or more characters and words
are supplied into it.

The character manipula;on func;ons in SQL are as follows:

A) CONCAT (joining two or more values): This func;on is used to join


two or more values together. The second string is always appended
to the end of the first string.

B) SUBSTR: This func;on returns a segment of a string from a given


start point to a given endpoint.

C) LENGTH: This func;on returns the length of the string in numerical


form, including blank spaces.

D) INSTR: This func;on calculates the precise numeric loca;on of a


character or word in a string.

E) LPAD: For right-jus;fied values, it returns the padding of the leT-


side character value.

F) RPAD: For a leT-jus;fied value, it returns the padding of the right-


side character value.

Page 8 of 11
iNeuron Intelligence Pvt Ltd

G) TRIM: This func;on removes all defined characters from the


beginning, end, or both ends of a string. It also reduced the amount
of wasted space.

H) REPLACE: This func;on replaces all instances of a word or a


sec;on of a string (substring) with the other string value specified.

Q16. What is the difference between the RANK() and DENSE_RANK()


func;ons?

Ans- The RANK () func;on in the result set defines the rank of each
row within your ordered par;;on. If both rows have the same rank,
the next number in the ranking will be the previous rank plus a
number of duplicates. If we have three records at rank 4, for
example, the next level indicated is 7.

The DENSE_RANK () func;on assigns a dis;nct rank to each row


within a par;;on based on the provided column value, with no gaps.
It always indicates a ranking in order of precedence. This func;on will
assign the same rank to the two rows if they have the same rank,
with the next rank being the next consecu;ve number. If we have
three records at rank 4, for example, the next level indicated is 5.

Q17. What is a UNIQUE constraint?

The UNIQUE Constraint prevents iden;cal values in a column from


appearing in two records. The UNIQUE constraint guarantees that
every value in a column is unique.

Page 9 of 11
iNeuron Intelligence Pvt Ltd

Q18. What is a Self-Join?

A self-join is a type of join that can be used to connect two tables. As


a result, it is a unary rela;onship. Each row of the table is aXached to
itself and all other rows of the same table in a self-join. As a result, a
self-join is mostly used to combine and compare rows from the same
database table.

Q19. What is UNION, MINUS and INTERSECT commands?

Ans- The UNION operator is used to combine the results of two


tables while also removing duplicate entries.

The MINUS operator is used to return rows from the first query but
not from the second query.

The INTERSECT operator is used to combine the results of both


queries into a single row.
Before running either of the above SQL statements, certain
requirements must be sa;sfied –

Within the clause, each SELECT query must have the same number of
columns.

The data types in the columns must also be comparable.

In each SELECT statement, the columns must be in the same order.

Page 10 of 11
iNeuron Intelligence Pvt Ltd

Q20. List the different types of rela;onships in SQL.

Ans- There are different types of rela;ons in the database:

a) One-to-One – This is a connec;on between two tables in which


each record in one table corresponds to the maximum of one
record in the other.
b) One-to-Many and Many-to-One – This is the most frequent
connec;on, in which a record in one table is linked to several
records in another.
c) Many-to-Many – This is used when defining a rela;onship that
requires several instances on each sides.

Self-Referencing Rela;onships – When a table has to declare a


connec;on with itself, this is the method to employ.

Page 11 of 11
iNeuron Intelligence Pvt Ltd

Q1. What is SQL example?

SQL is a database query language that allows you to edit, remove,


and request data from databases. The following statements are a few
examples of SQL statements:

• SELECT
• INSERT
• UPDATE
• DELETE
• CREATE DATABASE
• ALTER DATABASE

Q2. What are basic SQL skills?

Ans- SQL skills aid data analysts in the creaPon, maintenance, and
retrieval of data from relaPonal databases, which divide data into
columns and rows. It also enables users to efficiently retrieve,
update, manipulate, insert, and alter data.

The most fundamental abiliPes that a SQL expert should possess are:

1. Database Management
2. Structuring a Database
3. CreaPng SQL clauses and statements
4. SQL System Skills like MYSQL, PostgreSQL
5. PHP experPse is useful.
6. Analyze SQL data
7. Using WAMP with SQL to create a database
8. OLAP Skills
Page 2 of 13
iNeuron Intelligence Pvt Ltd

Q3. What is schema in SQL Server?

Ans- A schema is a visual representaPon of the database that is


logical. It builds and specifies the relaPonships among the database’s
numerous enPPes. It refers to the several kinds of constraints that
may be applied to a database. It also describes the various data
kinds. It may also be used on Tables and Views.

Schemas come in a variety of shapes and sizes. Star schema and


Snowflake schema are two of the most popular. The enPPes in a star
schema are represented in a star form, whereas those in a snowflake
schema are shown in a snowflake shape.
Any database architecture is built on the foundaPon of schemas.

Q4. List the different types of relaPonships in SQL.

Ans- There are different types of relaPons in the database:


One-to-One – This is a connecPon between two tables in which each
record in one table corresponds to the maximum of one record in the
other.
One-to-Many and Many-to-One – This is the most frequent
connecPon, in which a record in one table is linked to several records
in another.
Many-to-Many – This is used when defining a relaPonship that
requires several instances on each sides.
Self-Referencing RelaPonships – When a table has to declare a
connecPon with itself, this is the method to employ.

Page 3 of 13
iNeuron Intelligence Pvt Ltd

Q5. What is schema in SQL Server?

Ans- A schema is a visual representaPon of the database that is


logical. It builds and specifies the relaPonships among the database’s
numerous enPPes. It refers to the several kinds of constraints that
may be applied to a database. It also describes the various data
kinds. It may also be used on Tables and Views.

Schemas come in a variety of shapes and sizes. Star schema and


Snowflake schema are two of the most popular. The enPPes in a star
schema are represented in a star form, whereas those in a snowflake
schema are shown in a snowflake shape.
Any database architecture is built on the foundaPon of schemas.

Q6. How to install SQL Server in Windows 11?

Ans- Install SQL Server Management Studio In Windows 11

Step 1: Click on SSMS, which will take you to the SQL Server
Management Studio page.

Step 2: Moreover, click on the SQL Server Management Studio link


and tap on Save File.

Step 3: Save this file to your local drive and go to the folder.

Step 4: The setup window will appear, and here you can choose the
locaPon where you want to save the file.
Step 5: Click on Install.

Page 4 of 13
iNeuron Intelligence Pvt Ltd

Step 6: Close the window ader the installaPon is complete.


Step 7: Furthermore, go back to your Start Menu and search for SQL
server management studio.

Step 8: Furthermore, double-click on it, and the login page will


appear once it shows up.

Step 9: You should be able to see your server name. However, if


that’s not visible, click on the drop-down arrow on the server and tap
on Browse.

Step 10: Choose your SQL server and click on Connect.

Q7. What is the case when in SQL Server?

Ans- The CASE statement is used to construct logic in which one


column’s value is determined by the values of other columns.

At least one set of WHEN and THEN commands makes up the SQL
Server CASE Statement. The condiPon to be tested is specified by the
WHEN statement. If the WHEN condiPon returns TRUE, the THEN
sentence explains what to do.

When none of the WHEN condiPons return true, the ELSE statement
is executed. The END keyword brings the CASE statement to a close.

Page 5 of 13
iNeuron Intelligence Pvt Ltd

CASE

WHEN condiPon1 THEN result1

WHEN condiPon2 THEN result2

WHEN condiPonN THEN resultN

ELSE result

END;

Q8. What is the difference between NOW() and CURRENT_DATE()?

Ans- NOW() returns a constant Pme that indicates the Pme at which
the statement began to execute. (Within a stored funcPon or trigger,
NOW() returns the Pme at which the funcPon or triggering statement
began to execute.

The simple difference between NOW() and CURRENT_DATE() is that


NOW() will fetch the current date and Pme both in format ‘YYYY-

Page 6 of 13
iNeuron Intelligence Pvt Ltd

MM_DD HH:MM:SS’ while CURRENT_DATE() will fetch the date of the


current day ‘YYYY-MM_DD’.

Let’s move to the next quesPon in this SQL Interview QuesPons.

Q9. What is BLOB and TEXT in MySQL?

Ans- BLOB stands for Binary Huge Objects and can be used to store
binary data, whereas TEXT may be used to store a large number of
strings. BLOB may be used to store binary data, which includes
images, movies, audio, and applicaPons.

BLOB values funcPon similarly to byte strings, and they lack a


character set. As a result, bytes’ numeric values are completely
dependent on comparison and sorPng.

TEXT values behave similarly to a character string or a non-binary


string. The comparison/sorPng of TEXT is completely dependent on
the character set collecPon.

Q10. How to create a stored procedure using SQL Server?

A stored procedure is a piece of prepared SQL code that you can save
and reuse again and over.
So, if you have a SQL query that you create frequently, save it as a
Page 7 of 13
iNeuron Intelligence Pvt Ltd

stored procedure and then call it to run it.


You may also supply parameters to a stored procedure so that it can
act based on the value(s) of the parameter(s) given.

Stored Procedure Syntax

CREATE PROCEDURE procedure_name

AS

sql_statement

GO;

Execute a Stored Procedure

EXEC procedure_name;

Q11. What is Database Black Box TesPng?

Black Box TesPng is a sodware tesPng approach that involves tesPng


the funcPons of sodware applicaPons without knowing the internal
code structure, implementaPon details, or internal routes. Black Box
TesPng is a type of sodware tesPng that focuses on the input and
output of sodware applicaPons and is totally driven by sodware
requirements and specificaPons. Behavioral tesPng is another name
for it.

Page 8 of 13
iNeuron Intelligence Pvt Ltd

Q12. Where MyISAM table is stored?

Prior to the introducPon of MySQL 5.5 in December 2009, MyISAM


was the default storage engine for MySQL relaPonal database
management system versions. It’s based on the older ISAM code, but
it comes with a lot of extra features. Each MyISAM table is split into
three files on disc (if it is not parPPoned). The file names start with
the table name and end with an extension that indicates the file type.
The table definiPon is stored in a.frm file, however this file is not part
of the MyISAM engine; instead, it is part of the server. The data file’s
suffix is.MYD (MYData). The index file’s extension is.MYI (MYIndex). If
you lose your index file, you may always restore it by recreaPng
indexes.

Q13. How to find the nth highest salary in SQL?

Ans- The most typical interview quesPon is to find the Nth highest
pay in a table. This work can be accomplished using the dense rank()
funcPon.

Employee table

employee_name salary

A 24000

C 34000

Page 9 of 13
iNeuron Intelligence Pvt Ltd

D 55000

E 75000

F 21000

G 40000

H 50000

SELECT * FROM(

SELECT employee_name, salary, DENSE_RANK()

OVER(ORDER BY salary DESC)r FROM Employee)

WHERE r=&n;

To find to the 2nd highest salary set n = 2

To find 3rd highest salary set n = 3 and so on.

Page 10 of 13
iNeuron Intelligence Pvt Ltd

Q14. What do you mean by table and field in SQL?

A table refers to a collecPon of data in an organised manner in form


of rows and columns. A field refers to the number of columns in a
table. For example:

Table: StudentInformaPon

Field: Stu Id, Stu Name, Stu Marks

Q15. What is the difference between CHAR and VARCHAR2 datatype


in SQL?

Both Char and Varchar2 are used for characters datatype but varchar2
is used for character strings of variable length whereas Char is used for
strings of fixed length. For example, char(10) can only store 10
characters and will not be able to store a string of any other length
whereas varchar2(10) can store any length i.e 6,8,2 in this variable.

Q16. What is a Primary key?

• A Primary key in SQL is a column (or collecPon of columns) or a


set of columns that uniquely idenPfies each row in the table.
• Uniquely idenPfies a single row in the table
• Null values not allowed

Page 11 of 13
iNeuron Intelligence Pvt Ltd

Q17. What are Constraints?

Ans- Constraints in SQL are used to specify the limit on the data type
of the table. It can be specified while creaPng or altering the table
statement. The sample of constraints are:

• NOT NULL
• CHECK
• DEFAULT
• UNIQUE
• PRIMARY KEY
• FOREIGN KEY

Q18. What is a Unique key?

Ans- Uniquely idenPfies a single row in the table.

• MulPple values allowed per table.


• Null values allowed.

Q19. What is a foreign key in SQL?

• Foreign key maintains referenPal integrity by enforcing a link


between the data in two tables.
• The foreign key in the child table references the primary key in
the parent table.
• The foreign key constraint prevents acPons that would destroy
links between the child and parent tables.

Page 12 of 13
iNeuron Intelligence Pvt Ltd

Q20. What do you mean by data integrity?

Ans- Data Integrity defines the accuracy as well as the consistency of


the data stored in a database. It also defines integrity constraints to
enforce business rules on the data when it is entered into an
applicaPon or a database.

Page 13 of 13
iNeuron Intelligence Pvt Ltd

Q1. What is the difference between clustered and non-clustered index


in SQL?

Ans- The differences between the clustered and non-clustered index


in SQL are :

1. Clustered index is used for easy retrieval of data from the


database and its faster whereas reading from non- clustered
index is relaDvely slower.
2. Clustered index alters the way records are stored in a database
as it sorts out rows by the column which is set to be clustered
index whereas in a non-clustered index, it does not alter the way
it was stored but it creates a separate object within a table which
points back to the original table rows aJer searching.

Q2. Write a SQL query to display the current date?

Ans- In SQL, there is a built-in funcDon called Get Date() which helps
to return the current Dmestamp/date.

Q3. What are EnDDes and RelaDonships?

Ans- EnDDes: A person, place, or thing in the real world about which
data can be stored in a database. Tables store data that represents one
type of enDty. For example – A bank database has a customer table to
store customer informaDon. The customer table stores this
informaDon as a set of aWributes (columns within the table) for each
customer.

RelaDonships: RelaDon or links between enDDes that have something


to do with each other. For example – The customer name is related to
the customer account number and contact informaDon, which might
Page 2 of 9
iNeuron Intelligence Pvt Ltd

be in the same table. There can also be relaDonships between separate


tables (for example, customer to accounts).

Q4. What is an Index?

Ans- An index refers to a performance tuning method of allowing


faster retrieval of records from the table. An index creates an entry for
each value and hence it will be faster to retrieve data.

Q5. Explain different types of index in SQL.

Ans- There are three types of index in SQL namely:

Unique Index:

This index does not allow the field to have duplicate values if the
column is unique indexed. If a primary key is defined, a unique index
can be applied automaDcally.

Clustered Index:

This index reorders the physical order of the table and searches based
on the basis of key values. Each table can only have one clustered
index.

Non-Clustered Index:
Non-Clustered Index does not alter the physical order of the table and
maintains a logical order of the data. Each table can have many
nonclustered indexes.

Page 3 of 9
iNeuron Intelligence Pvt Ltd

Q6. What is NormalizaDon and what are the advantages of it?

Ans- NormalizaDon in SQL is the process of organizing data to avoid


duplicaDon and redundancy. Some of the advantages are:

• BeWer Database organizaDon


• More Tables with smaller rows
• Efficient data access
• Greater Flexibility for Queries
• Quickly find the informaDon
• Easier to implement Security
• Allows easy modificaDon
• ReducDon of redundant and duplicate data
• More Compact Database
• Ensure Consistent data aJer modificaDon

Q7. What is the difference between DROP and TRUNCATE commands?

Ans- DROP command removes a table and it cannot be rolled back


from the database whereas TRUNCATE command removes all the rows
from the table.

What are the differences between OLTP and OLAP?

OLTP stands for online transaction processing, whereas


OLAP stands for online analytical processing. OLTP is an

Page 4 of 9
iNeuron Intelligence Pvt Ltd

online database modification system, whereas OLAP is an


online database query response system.

Q8. How to create empty tables with the same structure


as another table?

To create empty tables:

Using the INTO operator to fetch the records of one table


into a new table while setting a WHERE clause to false for all
entries, it is possible to create empty tables with the same
structure. As a result, SQL creates a new table with a
duplicate structure to accept the fetched entries, but
nothing is stored into the new table since the WHERE clause
is active.

Ans- There are many successive levels of normalizaDon. These are


called normal forms. Each consecuDve normal form depends on the
previous one.The first three normal forms are usually adequate.

Normal Forms are used in database tables to remove or decrease


duplicaDon. The following are the many forms:

First Normal Form:


When every aWribute in a relaDon is a single-valued aWribute, it is
said to be in first normal form. The first normal form is broken when
a relaDon has a composite or mulD-valued property.

Second Normal Form:

A relaDon is in second normal form if it meets the first normal form’s


requirements and does not contain any parDal dependencies. In 2NF,

Page 5 of 9
iNeuron Intelligence Pvt Ltd

a relaDon has no parDal dependence, which means it has no non-


prime aWribute that is dependent on any suitable subset of any table
candidate key. OJen, the problem may be solved by sefng a single
column Primary Key.

Third Normal Form:


If a relaDon meets the requirements for the second normal form and
there is no transiDve dependency, it is said to be in the third normal
form.

Q9. What is OLTP?

Ans- OLTP, or online transacDonal processing, allows huge groups of


people to execute massive amounts of database transacDons in real
Dme, usually via the internet. A database transacDon occurs when
data in a database is changed, inserted, deleted, or queried.

What are the differences between OLTP and OLAP?

OLTP stands for online transacDon processing, whereas OLAP stands


for online analyDcal processing. OLTP is an online database
modificaDon system, whereas OLAP is an online database query
response system.

Q10. How to create empty tables with the same structure as another
table?

Ans- To create empty tables:

Page 6 of 9
iNeuron Intelligence Pvt Ltd

Using the INTO operator to fetch the records of one table into a new
table while sefng a WHERE clause to false for all entries, it is
possible to create empty tables with the same structure. As a result,
SQL creates a new table with a duplicate structure to accept the
fetched entries, but nothing is stored into the new table since the
WHERE clause is acDve.

Q11. What are SQL comments?

SQL Comments are used to clarify porDons of SQL statements and to


prevent SQL statements from being executed. Comments are quite
important in many programming languages. The comments are not
supported by a MicrosoJ Access database. As a result, the MicrosoJ
Access database is used in the examples in Mozilla Firefox and
MicrosoJ Edge.
Single Line Comments: It starts with two consecuDve hyphens (–).
MulD-line Comments: It starts with /* and ends with */.

Q12. What is the difference between the RANK() and DENSE_RANK()


funcDons?

The RANK() funcDon in the result set defines the rank of each row
within your ordered parDDon. If both rows have the same rank, the
next number in the ranking will be the previous rank plus a number of
duplicates. If we have three records at rank 4, for example, the next
level indicated is 7.

Page 7 of 9
iNeuron Intelligence Pvt Ltd

13. Explain the difference between RANK and DENSE_RANK funcDons


in Oracle SQL.
RANK and DENSE_RANK both assign rankings to result rows.

With RANK, when two or more rows have the same values, they’ll be
assigned the same rank, and the subsequent rank will be skipped.

Meanwhile, DENSE_RANK provides a consecuDve ranking and


doesn’t leave gaps in ranking even when duplicate values exist.

14. What is the purpose of the UNION operator in Oracle SQL?


The UNION operator combines the results of two or more SELECT
queries into a single result set – as if it came from a single query. It
merges the rows from different queries, removes duplicate rows, and
presents a unified result.

15. Name one advantage of using indexes in a database.


Indexes improve query performance through quicker data retrieval
by reducing the need for full table scans.

16. DifferenDate between the WHERE clause and the HAVING clause
in Oracle SQL.
The WHERE clause filters rows before grouping – that is, before
they’re included in the result set. Filtering is also based on certain
condiDons.

The HAVING clause, on the other hand, filters data post-grouping –


meaning aJer aggregaDon.

Page 8 of 9
iNeuron Intelligence Pvt Ltd

17. How does the Oracle Query OpDmizer determine an execuDon


plan for a query?
It uses heurisDcs or rules of thumb and staDsDcs to decide on the
most efficient execuDon plan based on available indexes, table size,
and query complexity.

18. What is the key difference between ROW-level and STATEMENT-


level triggers in Oracle?
ROW-level triggers fire once for each affected row, therefore allowing
row-specific acDons.

STATEMENT-level triggers are executed only once for the enDre


statement. This is regardless of the number of affected rows and is
more suitable for acDons that don't depend on individual rows.

19. What do the COMMIT and ROLLBACK statements in Oracle SQL


do?
The COMMIT statement saves all the changes made in a transacDon
to the database, making them permanent. The ROLLBACK statement
undoes the changes in the transacDon and reverts the database to its
pre-transacDon state.

20. What are some advantages of using bind variables in Oracle SQL?
Bind variables improve performance through caching and reusing,
reducing the need for parsing. Bind variables also protect against SQL
injecDon aWacks, require minimal maintenance, and reduce memory
usage.

Page 9 of 9
iNeuron Intelligence Pvt Ltd

1. Differen*ate between VARCHAR and VARCHAR2 data types.


Both VARCHAR and VARCHAR2 are used to store variable-length
character strings. VARCHAR is a standard SQL data type which works
across different rela*onal database systems. Whereas, VARCHAR2 is
specific to Oracle.

VARCHAR 2 has several advantages. It is more storage efficient and,


unlike VARCHAR, it does not store trailing spaces at the end of a
string so avoids poten*al unexpected results when comparing
strings. However, VARCHAR2 might not be supported non-Oracle
database systems.

2. How would you explain database roles and privileges in Oracle SQL
security? How do you grant and revoke privileges to users and roles
in Oracle?
Database roles are named groups of related privileges. They allow for
assigning mul*ple privileges to a role and gran*ng or revoking the
role to users, simplifying security management. The GRANT
statement is used to grant, and the REVOKE statement is used to
revoke privileges.

3. Write an Oracle SQL query to find the average salary of employees


within each department.
SELECT department_id, AVG(salary) AS average_salary

FROM employees

GROUP BY department_id;

Page 2 of 11
iNeuron Intelligence Pvt Ltd

4. Write an Oracle SQL query to find employees who earn more than
their managers.
SELECT emp.*

FROM Employee emp

INNER JOIN Employee mgr ON emp.manager_id = mgr.employee_id

WHERE emp.salary > mgr.salary;

5. How would you update the status column of the orders table to set
all orders with a total amount greater than 1,000 to High Value?
UPDATE orders

SET status = 'High Value'

WHERE total_amount > 1000;

6. Write an Oracle SQL query to get the date and *me of the last 10
logins for a specific user.
SELECT login_*me

FROM UserLogins

WHERE user_id = 'specific_user_id'

ORDER BY login_*me DESC

FETCH FIRST 10 ROWS ONLY;

Page 3 of 11
iNeuron Intelligence Pvt Ltd

7. Retrieve the top five highest-rated products based on customer


reviews from the product_reviews table.
SELECT product_id, product_name, AVG(review_ra*ng) AS
average_ra*ng

FROM product_reviews

GROUP BY product_id, product_name

ORDER BY average_ra*ng DESC

FETCH FIRST 5 ROWS ONLY;

8. Calculate the total revenue generated by each customer in the last


three months.
SELECT customer_id, SUM(revenue) AS total_revenue

FROM sales

WHERE transac*on_date >= TRUNC(SYSDATE) - INTERVAL '3' MONTH

GROUP BY customer_id;

9. Calculate the percentage of total sales each product contributes to


the overall revenue.
SELECT product_id, SUM(total_amount) / (SELECT
SUM(total_amount) FROM sales) * 100 AS percentage_contribu*on

FROM sales

GROUP BY product_id;

Page 4 of 11
iNeuron Intelligence Pvt Ltd

10. Write an Oracle SQL query to find the names of employees not
assigned to any project.
SELECT employee_name

FROM employees

WHERE employee_id NOT IN (SELECT DISTINCT employee_id FROM


projects);

11. Write an Oracle SQL query to find the five most common names
in the Employee table.
SELECT name, COUNT(*) AS name_count

FROM Employee

GROUP BY name

ORDER BY name_count DESC

FETCH FIRST 5 ROWS ONLY;

12. Write an Oracle SQL query to ensure only users with the manager
role can insert rows into the performance_reviews table.
CREATE OR REPLACE TRIGGER enforce_manager_insert

BEFORE INSERT ON performance_reviews

FOR EACH ROW

DECLARE

Page 5 of 11
iNeuron Intelligence Pvt Ltd

BEGIN

IF NOT (IS_ROLE_ENABLED('manager')) THEN

RAISE_APPLICATION_ERROR(-20001, 'Only users with the


"manager" role can insert into this table.');

END IF;

END;

13. You have an Employees table with columns for employee names
and their respec*ve managers. How will you find the longest chain of
repor*ng for each employee?
WITH RECURSIVE Repor*ngChain AS (

SELECT employee_id, manager_id, employee_name, 1 AS


chain_length

FROM Employees

WHERE manager_id IS NOT NULL

UNION ALL

SELECT e.employee_id, e.manager_id, e.employee_name,


rc.chain_length + 1

Page 6 of 11
iNeuron Intelligence Pvt Ltd

FROM Employees e

INNER JOIN Repor*ngChain rc ON e.manager_id = rc.employee_id

SELECT employee_id, employee_name, MAX(chain_length) AS


longest_chain

FROM Repor*ngChain

GROUP BY employee_id, employee_name;

14. Imagine that you have a students table with the columns
student_id, student_name, and birthdate. Write an Oracle SQL query
to find each student's age (in years) as of today.
SELECT student_id, student_name,

EXTRACT(YEAR FROM SYSDATE) - EXTRACT(YEAR FROM birthdate)


AS age

FROM students;

15. In a database containing informa*on about books and authors,


write an SQL query to iden*fy the author with the most published
books.
SELECT author_id, author_name, COUNT(book_id) AS total_books

FROM Authors

Page 7 of 11
iNeuron Intelligence Pvt Ltd

JOIN Books ON Authors.author_id = Books.author_id

GROUP BY author_id, author_name

ORDER BY total_books DESC

FETCH FIRST 1 ROWS ONLY;

16. Imagine you have an Inventory table with product_id and


quan*ty columns. Write an Oracle SQL query to find the products
that have experienced an increase in quan*ty compared to the
previous month.
SELECT product_id

FROM (

SELECT product_id, quan*ty, LAG(quan*ty) OVER (ORDER BY


month) AS prev_quan*ty

FROM Inventory

WHERE quan*ty > prev_quan*ty;

17. Case Study: Sales Analysis System. The dataset contains


informa*on about sales transac*ons in a company. The "sales" table
includes the following columns:
transac*on_id: Unique iden*fier for each transac*on.

customer_id: Unique iden*fier for each customer.

Page 8 of 11
iNeuron Intelligence Pvt Ltd

product_id: Unique iden*fier for each product sold.

transac*on_date: The date when the transac*on occurred.

quan*ty: The quan*ty of the product sold in the transac*on.

unit_price: The price of one unit of the product.

You’re tasked with finding the top 5 customers who made the highest
total purchase amount in the last quarter (last three months) and
displaying their names and total purchase amounts. Write an Oracle
SQL query to retrieve this informa*on.

WITH LastQuarterSales AS (

SELECT customer_id, SUM(quan*ty * unit_price) AS


total_purchase_amount

FROM sales

WHERE transac*on_date >= TRUNC(SYSDATE) - INTERVAL '3'


MONTH

GROUP BY customer_id

SELECT c.customer_id, c.customer_name,


lqs.total_purchase_amount

Page 9 of 11
iNeuron Intelligence Pvt Ltd

FROM LastQuarterSales lqs

JOIN customers c ON lqs.customer_id = c.customer_id

ORDER BY lqs.total_purchase_amount DESC

FETCH FIRST 5 ROWS ONLY;

18. Case Study: Employee Performance Evalua*on System.


The dataset contains informa*on about employees' performance
evalua*ons in a company. The "employees" table includes the
following columns:

employee_id: Unique iden*fier for each employee.

employee_name: The name of the employee.

department: The department to which the employee belongs (e.g.,


HR, Finance, Sales).

ra*ng: The employee's performance ra*ng on a scale of 1 to 5 (5


being the highest).

years_of_experience: The number of years of experience of the


employee.

salary: The salary of the employee.

manager_id: The ID of the employee's manager.

Page 10 of 11
iNeuron Intelligence Pvt Ltd

19. Imagine you’re an HR manager and want to get an overview of


the average performance ra*ng for each department. Write an
Oracle SQL query to retrieve the department and the average
performance ra*ng for each department.
SELECT department, AVG(ra*ng) AS avg_ra*ng

FROM employees

GROUP BY department;

20. Say you’re preparing a report for the management to iden*fy


employees who have shown consistently high performance. Write an
Oracle SQL query to retrieve the names and performance ra*ngs of
employees with a ra*ng of 5 in all their performance evalua*ons.
SELECT employee_name

FROM employees

WHERE ra*ng = 5

GROUP BY employee_name

HAVING COUNT(*) = (SELECT COUNT(*) FROM employees);

Page 11 of 11
iNeuron Intelligence Pvt Ltd

1. Imagine you want to iden1fy employees who are eligible for


promo1ons based on their years of experience and current salary.
Write an Oracle SQL query to retrieve the employee ID, name,
department, and salary of employees who have more than 5 years of
experience and earn more than $95,000 per year.
SELECT employee_id, employee_name, department, salary

FROM employees

WHERE years_of_experience > 5 AND salary > 95000;

2. Consider a scenario where the company plans to give a salary raise


to employees with a performance ra1ng of 4 or 5. Write an Oracle
SQL query to update eligible employees' salaries by 8%.
UPDATE employees

SET salary = salary * 1.08

WHERE ra1ng IN (4, 5);

3. You want to create a list of managers and the number of


employees repor1ng to them. Write an Oracle SQL query to retrieve
managers’ names and the count of employees repor1ng to each
manager.
SELECT m.employee_name AS manager_name,
COUNT(e.employee_id) AS num_employees

FROM employees e

JOIN employees m ON e.manager_id = m.employee_id

Page 2 of 6
iNeuron Intelligence Pvt Ltd

GROUP BY m.employee_name;

4. What is SQL injec1on?

SQL injec1on is a code injec1on technique that implies the usage of


malicious code to access sensi1ve data that should not be displayed.

5. What is a trigger in SQL?

A trigger is a certain type of procedure running automa1cally when


some event takes place in the database servicer. For example, a DML
trigger runs when a user tries to edit certain data through a Data
Manipula1on Language event.

6. Can we disable a trigger?

Yes, it’s possible to disable a trigger. For this purpose, use “DISABLE
TRIGGER triggerName ON<>. If you need to disable all the triggers,
use DISABLE TRIGGER ALL ON ALL SERVER.

7. How to use LIKE in SQL?

We use LIKE operator in WHERE clause if we need to look for a


par1cular panern in a column. For example:

SELECT * FROM eployees WHERE first_name like ‘Steven’

Page 3 of 6
iNeuron Intelligence Pvt Ltd

8. How is a non-clustered index different from a clustered index?

A clustered index determines the order in which the data are stored
in a table. A non-clustered index, in turn, does not sort the data
inside the table. Actually, non-clustered index and table data are
stored in two separate places.

9. What is ISAM?

ISAM, also known as the Indexed Sequen1al Access Method, was


invented by IBM for storing and extrac1ng data from secondary
storage systems.

10. What is Database Black Box Tes1ng?

BlackBox tes1ng implies tes1ng interfaces and database integra1on.


It consists of data mapping, the verifica1on of the incoming data, and
the verifica1on of outgoing data from query func1ons.

11. What is the COMMIT in SQL?


The COMMIT statement is used when we need to finish the current
transac1on and make all changes in it permanent. A transac1on, in
turn, is the sequence of SQL statements seen as a single unit by the
Oracle Database.

12. What is the difference between TRUNCATE and DROP


statements?

TRUNCATE statement removes all rows from the table while the
DROP command deletes a table from a database. In both cases, the
opera1on cannot be rolled back.

Page 4 of 6
iNeuron Intelligence Pvt Ltd

13. What is a colla1on?

The term colla1on refers to a set of rules that specify how the
database engine should sort and compare the character data.

14. What is ALIAS in SQL?

We use the ALIAS command to give a column in a table or a table


itself a temporary name with the purpose of making a column
header easier to read.

15. What are the SQL constraints?

SQL constraints determine rules for the data in a table. To be more


specific, they can limit the type of data for a table to ensure its
reliability and accuracy.

16. What are Group Func1ons?

Group func1ons show results based on sets or groups of rows. For


instance, users can get sums/totals, averages, minimums, and
maximums by u1lizing group func1ons.

17. How can we execute dynamic SQL?

Dynamic SQL can be executed in three different ways. First, we can


write a query with parameters. Second, we can use the EXEC
command. Finally, we can use sp_executesql.

18. What is the First Normal Form and what are their main rules?

Page 5 of 6
iNeuron Intelligence Pvt Ltd

The first normal form is a property with two primary rules for an
organized database. The first one is to remove the iden1cal columns
for the same table. The second rule implies crea1ng a separate table
for each set of related data. The third rule says we should iden1fy
each table with a unique primary key column.

19. What are the main case manipula1on func1ons in SQL?

The primary case manipula1on func1ons are as follows:

LOWER/LCASE – converts the specific argument into lower case

UPPER/UCASE – converts the par1cular argument into lower case

INITCAP – converts the first lener of a word into uppercase while


other leners are converted into lowercase

20. What ACID proper1es ensure that the database transac1ons are
processed?

The ACID acronym defines the set of proper1es of database


transac1ons that ensures the validity of the data regardless of power
failures, errors, or other issues. These proper1es are atomicity,
consistency, isola1on, and durability.

Page 6 of 6
iNeuron Intelligence Pvt Ltd

1. What is SQL Grand Command used for?

We use Grand Command to offer users privileges to database


objects. Also, we can grant permissions to other users with the help
of this command.

2. What is the BCP and when do we use it?

The BCP or the bulk copy program is a command-line tool used for
exporKng or imporKng the data into a data file or vice versa.
AddiKonally, this uKlity can generate format files and export certain
data from a query.

3. What are the three primary closes of SQL statements?

Three main clauses that enable us to restrict and manage the data
using valid constraints are the Where clause, Union Clause, and
Order By clause.

4. What is an SQL Server?

SQL Server is a relaKonal database management system created by


MicrosoS to store and extract informaKon as requested by other
soSware apps.

5. How to install SQL Server?

The process of SQL Server installaKon looks the following way:

1. Get the latest version of the SQL Server official release there

Page 2 of 8
iNeuron Intelligence Pvt Ltd

2. Choose the type of SQL Server that needs to be installed. You can
use it on a Cloud PlaYorm or as an open-source ediKon.

3. The next step is to click on the download buZon

4. Save the .exe file on your computer and click on Open with the
right mouse buZon.

5. Click Yes to allow necessary changes and install SQL Server.

6. As soon as the SQL Server is installed, restart the system if it is


necessary and launch the SQL Server Management Studio app from
the START menu.

6. How to uninstall SQL Server?

If you use Windows 10, go to the START menu and locate the SQL
Server. Click the right mouse buZon and choose to uninstall to start
the uninstallaKon process.

7. How can you find the server name in SQL Server?

If you are looking for the server name, you need to run the query
SELECT @@version and you will be shown the name and the latest
version of the SQL Server.

8. How to restore the database in SQL Server?

First, launch the SQL Server Management Studio app. From the
window pane called Object Explorer, click the right mouse buZon on

Page 3 of 8
iNeuron Intelligence Pvt Ltd

databases and choose Restore. Your database will be automaKcally


restored.

9. What is SQL Profiler?

SQL profiler is an instrument used by system administrators for


monitoring the events in the SQL Server. With the help of this tool,
administrators capture and save data about each event of a file or
table for further analysis.

10. What is SQL Server Agent?

SQL Server Agent is a significant part of MicrosoS SQL Server used for
execuKng scheduled administraKve tasks commonly known as jobs.

11. What is the ISNULL() operator?

ISNULL() operator is a funcKon that returns a specified value if the


expression is NULL. In case the expression is NOT NULL, it is returned
by the funcKon.

12. What is replicaKon in SQL Server?

When it comes to SQL Server, replicaKon is a process that implies


copying and distribuKng the data from one database to another one
and synchronizing the data between the two databases to ensure
data integrity and consistency.

13. What is a funcKon in SQL Server?

Page 4 of 8
iNeuron Intelligence Pvt Ltd

A funcKon is a piece of pre-wriZen code executed on a SQL Server


that helps you complete a certain task regarding the viewing,
managing, and processing of the data.

14. Select the built-in funcKons provided by SQL.

SUM, MIN, MAX, MULT, AVG


SUM, MULT, DIV, MIN, AVG
SUM, MIN, MAX, NAME, AVG
COUNT, SUM, AVG, MAX, MIN
Ans: D

15.How is an RDBMS different from a DBMS?

Ans. RDBMS i.e. a RelaKonal Database Management System is like an


advanced version of a DBMS. An RDBMS differs from a DBMS in the
following ways -
● A DBMS stores data as files whereas in an RDBMS data is stored in
tabular format.
● The data across the tables can be related to each other in an
RDBMS however the data stored in a DBMS are not related to one
another.
● You cannot access different elements at the same Kme in a DBMS
however you can access mulK-elements simultaneously using an
RDBMS.
● RDBMS supports normalizaKon and distributed databases, unlike a
DBMS.

Page 5 of 8
iNeuron Intelligence Pvt Ltd

● An RDBMS deals with a relaKvely larger quanKty of data as


compared to a DBMS. Hence, it is used to deal with huge data
whereas a DBMS is used for small organizaKons to store lesser data.
● Due to the usage of keys and indexes, data redundancy is not an
issue in an RDBMS, unlike a DBMS where data redundancy is very
common.
● For large amounts of data, data fetching is slower in DBMS
however it is very fast in an RDBMS due to the relaKonal approach.
● An RDBMS has higher soSware and hardware requirements as
compared to a DBMS.

16. Explain the difference between DDL, DML, and DCL statements
Ans. DDL stands for Data DefiniKon Language, DML stands for Data
ManipulaKon Language and DCL stands for Data Control Language.
● DDL is used to define, create, modify and delete the schema of the
database or the database objects.CREATE, ALTER, and DROP are
examples of DDL commands.
● DML is used for modifying and manipulaKng database data. INSERT,
UPDATE, and DELETE are examples of DML commands.
● DCL is used to manage access to the data stored in the database.
GRANT and REVOKE are examples of DCL commands.

17. What are constraints?


Ans. The kind of data that can be entered into a table is restricted by
constraints. This guarantees the reliability and accuracy of the data in
the table. The acKon is stopped if there is a contradicKon between
the constraint and the data acKon. Both column-level or table-level
constraints are possible. Table level restricKons apply to the enKre
table, while column level constraints just affect the specified column.
In SQL, we have NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY,

Page 6 of 8
iNeuron Intelligence Pvt Ltd

CHECK, DEFAULT and CREATE INDEX constraints for regulaKng the


data that is entered into a table.

18. Explain the use of primary key and foreign key


Ans. Every row of a table in a database must have a unique
idenKficaKon, and the primary key is crucial in providing that
idenKfier. The primary key constraint is a combinaKon of not null and
unique constraints in SQL. Every row in the database is uniquely
idenKfied by a column or group of columns that act as a primary key.
On the other hand, a foreign key is uKlized to establish a connecKon
between the two tables. To maintain data integrity between two
different instances of an enKty, the foreign key's primary funcKon is
to be used. A field in a table that serves as the primary key in another
table is known as a foreign key. There are no restricKons on how we
can insert values into the primary key column. In contrast, while
entering values into the foreign key table, we must make sure that
the value is present in a main key column.There can be only one
primary key per table however there can be mulKple foreign keys in a
table.

19. What is the difference between a primary key and a unique key?
Ans. Here are some differenKaKng points between primary key and
unique key constraints -
● To uniquely idenKfy records in a database, every table might have
one or more columns acKng as a primary key. A unique key, on the
other hand, stops two rows from having idenKcal items in a column.
● In a relaKonal database, a table can have numerous unique keys,
but it can only have one primary key.
● A unique key can have NULL values, however only one NULL is
permiZed in a table, whereas a main key column cannot have NULL
values.

Page 7 of 8
iNeuron Intelligence Pvt Ltd

● Uniqueness is desirable for a primary key, but it doesn't mean that


a unique key has to be the primary key.
● While the unique key enforces unique data, the primary key
implements data integrity.

Page 8 of 8
iNeuron Intelligence Pvt Ltd

1. What is a cross join?


Ans. A cross join is a join that gives the Cartesian product of all the
rows from both the tables in the join. In other words, each row from
the first table and each row from the second table are combined. For
example - If table 1 is -
LeDers
A
B
C
And table 2 is -
Numbers
1
2
3
The cross join of both these tables will give us -
LeDers Numbers
A1
A2
A3
B1
B2
B3
C1
C2
C3

2. Which command is used to remove duplicates from the result-set


obtained by the second SELECT query from the result-set obtained by
the first SELECT query and then return the filtered results from the
first?
Ans. The disNnct command is used to remove duplicates.

Page 2 of 9
iNeuron Intelligence Pvt Ltd

3. What is a cursor?
Ans. The rows (one or more) that a SQL statement returns are stored
in a cursor. You can give a cursor a name so that a program can use it
to retrieve and handle the rows returned by the SQL statement one
at a Nme. Two different types of cursors exist - Implicit cursors and
Explicit cursors.

4. How do the clustered and non-clustered indexes differ in SQL?


Ans. An index aids in enhancing both overall performance and speed
of data retrieval. If the primary key and unique constraint are defined
on the table, the index is automaNcally constructed. Clustered and
non-clustered indexes are two different types of indexes.
A clustered index on a column is automaNcally created in SQL Server
by the primary key constraint. There can only be one clustered index
per table, as specified by the protocol. A clustered index is used,
much like a dicNonary, to define the order, sort the table, or organize
the data in alphabeNcal order.
A non-clustered index records data in a different locaNon than where
it is collected. Pointers to the locaNon of that data are contained in
the index. There can be mulNple non-clustered indexes on a table, as
specified by the protocol. It does not impact the order of the data
stored in the table.
Further, no extra space is required to store the logical structure of a
clustered index whereas extra space is required to store the logical
structure of an unclustered index.
If data retrieval is your priority then clustered index works best
whereas if updaNng data is your priority then non-clustered indexes
work best.

Page 3 of 9
iNeuron Intelligence Pvt Ltd

5. What is a view? How is it different from a table?


Ans. A view is nothing but a virtual table. The rows and columns in a
view are similar to those in a table. A view is a database object that is
built on top of another table (or view), as opposed to a table, which
holds data on its own. If data in the underlying table changes, the
display will also reflect those changes. A view may be constructed on
top of one or more tables. A view can also be defined on top of a
different view.

6. Explain the different forms of normalizaNon. What is the use of


normalizaNon?
Ans. Redundancy from a relaNon or group of relaNons is minimized
through the process of normalizaNon. InserNon, deleNon, and update
abnormaliNes could result from relaNonal redundancy. Redundancy
in database tables can be reduced with the help of normal forms. The
different forms of normalizaNon are explained as follows -
a. First Normal Form – A relaNon violates the first normal form if it
has composite or mulN-valued aDributes, or it is in the first normal
form if neither of these aDributes is present. If all of the aDributes in
a relaNon are singled valued aDributes, the connecNon is said to be in
the first normal form.
b. Second Normal Form – A relaNon must be in the first normal form
and be devoid of any parNal dependencies in order to be in the
second normal form. If a relaNon has No ParNal Dependency, which
means that no non-prime aDribute—i.e., an aDribute that is not
included in any candidate key—is dependent on any suitable subset
of any candidate key in the table, then the relaNon is in 2NF.
c. Third Normal Form – A relaNon is in the third normal form if it is
both in the second normal form and there is no transiNve
dependency for non-prime characterisNcs. If at least one of the

Page 4 of 9
iNeuron Intelligence Pvt Ltd

following applies to every non-trivial funcNon dependence X -> Y, a


relaNon is in 3NF - Super key X is used or the prime aDribute is Y.
d. Boyce-Codd Normal Form (BCNF) – If a relaNon R is in Third
Normal Form for every FD, it is said to be in BCNF. The LHS acts as the
super key. A relaNon is in the BCNF if X is a super key in every non-
trivial funcNonal dependency X -> Y

7. Explain how TRUNCATE, DELETE and DROP statements differ from


one another
Ans.
● TRUNCATE in SQL is a DDL command. It is used to eliminate every
record from a table. An exisNng table's records are deleted, but the
table itself is leg intact. The table's schema or structure is
maintained. As a DDL command, the TRUNCATE TABLE statement
cannot be undone i.e. it cannot be rolled back.
● DELETE in SQL is a DML command. It is used to remove current
records from a table that already exists. Depending on the query's
criterion, we can delete a single record or a number of records. Since
DELETE is a DML command, it can be undone i.e. it can be rolled
back.
● DROP is a DDL Command. ExisNng database objects can be deleted
using the DROP statement. You can use it to remove databases,
tables, views, triggers, and other objects. The deleNon of an object
with the DROP command cannot be undone i.e. rolled back and is
irreversible.
● Prior to deleNon, the DELETE statement checks every row. As a
result, it takes longer than the TRUNCATE command. Using
TRUNCATE instead of DELETE when deleNng all the records from a
table is recommended because it is quicker. The DROP command
eliminates the enNre schema/structure of the table from the

Page 5 of 9
iNeuron Intelligence Pvt Ltd

database, in contrast, to TRUNCATE which simply deletes the data of


the tables.

8. What are Scalar funcNons?


Ans. There are some built-in funcNons in SQL that are known as
scalar funcNons, and no maDer what input is passed to a scalar
funcNon, it will always return a single value as its output. In SQL, the
scalar funcNons treat each record separately. Scalar funcNons are
ogen used and include the following: UCASE(), LCASE(), MID(),
LENGTH(), ROUND(), NOW(), FORMAT()

9. What are aggregate funcNons in SQL?


Ans. A column's mulNple values are calculated by an aggregate
funcNon in SQL, which in turn produces a single value. The GROUP BY
and HAVING clauses in a SELECT statement frequently go hand in
hand with aggregate funcNons. Avg, count, sum, min, max, and many
other aggregate methods are available in SQL. With the excepNon of
the count funcNon, an aggregate funcNon does not take into account
NULL values while calculaNng results.

10. What are OLAP and OLTP?


Ans. Data analysis for business choices is done using a class of
sogware tools known as online analyNcal processing (OLAP). OLAP
offers a sepng where users can simultaneously access insights from
the database gathered from several database systems. Examples: An
OLAP system is any type of data warehousing system. In a three-Ner
design, online transacNon processing (OLTP) offers transacNon-
oriented applicaNons. The daily operaNons of an organizaNon are
managed by OLTP. The use of OLTP is possible for online banking,
sending text messages, and adding clothes to shopping carts.

Page 6 of 9
iNeuron Intelligence Pvt Ltd

11. What do we use for paDern matching in SQL?


Ans. We use wildcard characters for paDern matching in SQL.

12. Explain triggers in SQL


Ans. A trigger is a specific kind of stored procedure that launches
automaNcally whenever a database server event takes place. When a
user aDempts to edit data using a data manipulaNon language (DML)
event, DML triggers are acNvated. DML operaNons are statements
that INSERT, UPDATE, or DELETE data from a table or view. Whether
or whether table rows are affected, these triggers are triggered
whenever a legiNmate event occurs.

13. Is a NULL value equivalent to a blank space or zero?


Ans. No, a NULL value is not equivalent to a black space or zero. Any
value that is "unavailable, unassigned, unknown, or not applicable" is
referred to as a NULL value. Whereas, a blank space is a character
and zero is a number.

14. What is the use of the COALESCE funcNon?


Ans. The COALESCE funcNon is used to return the very first value
from a series that is NOT NULL. It evaluates the expressions in the
order and returns the first value which is not null.

15. Explain the difference between where and having clauses?


Ans. Similar to a WHERE clause, a HAVING clause only applies to
groups as a whole (i.e., to the rows in the result set that represent
groups), but a WHERE clause applies to specific rows. Both a WHERE
clause and a HAVING clause may be present in a query. If so, then -
● Individual rows in the tables are the first to get the WHERE clause's
applicaNon. The rows that meet the WHERE clause's criteria are
grouped together as a result set.

Page 7 of 9
iNeuron Intelligence Pvt Ltd

● The rows in the result set are then subjected to the HAVING clause.
The query output only contains the groups that saNsfy the HAVING
requirements.

16. Explain character manipulaNon funcNons in SQL


Ans. A funcNon that accepts one or more characters or numbers as
input and outputs a character value is known as a character
manipulaNon funcNon. A string value is returned as a result set from
basic string funcNons, which have a number of features. Here are the
SQL character funcNons:
● To lowercase all the characters in a string, use the SQL LOWER()
method.
● Using the SQL UPPER() method, all characters in a string are
changed to uppercase.
● The SQL TRIM() funcNon eliminates leading and trailing characters
from character strings, or both.
● The SQL TRANSLATE() method swaps out one string's set of
characters for another string. A single character is replaced at a Nme
using the funcNon.

17. How can we display the current date in SQL?


Query- SELECT GETDATE();

18. How can we display alternate records from a table?


Query- SELECT * FROM table_name WHERE column_name%2 = 1;

19. How can you find the second highest salary from the given
employee table?
Query- SELECT MAX(emp_salary) FROM Employee WHERE SALARY <
(SELECT MAX(emp_salary) FROM Employee);

Page 8 of 9
iNeuron Intelligence Pvt Ltd

20. How can we copy the enNre data from one table to another in
SQL?
Query- INSERT INTO new_table SELECT * FROM old_table;

Page 9 of 9
iNeuron Intelligence Pvt Ltd

1. How can we create an empty table with the same structure as


another table?
Query- CREATE TABLE new_table LIKE oldl_table;

2. What can be used to add a row in a database using SQL?

ADD
AUGMENT
INSERT
CREATE
Ans: C

3. What command will you use to remove rows from a table 'AGE'?

REMOVE FROM AGE


DROP FROM AGE
DELETE FROM AGE WHERE
UPDATE FROM AGE
Ans: C

4. What does the SQL WHERE clause do?

Limits the column data that are returned


Limits the row data that are returned
Both a and b
None of the above
Ans: B

5. What is the purpose of SQL?

To define data structures

Page 2 of 5
iNeuron Intelligence Pvt Ltd

To specify the syntax of DDL


To specify the syntax of DML
All of the above
Ans: D

6. The wildcard in a WHERE clause is used when___________

A right match is required in a SELECT statement


A right match is possible in a CREATE statement
A right match is not possible in a SELECT statement
None of the above
Ans: C

7. Define a view?

A virtual table that can be accessed with SQL commands


A base table that can be accessed with SQL commands
Both a and b
None of the above
Ans: a

8. What command will you use to eliminate a table from a database?

ELIMINATE TABLE CUSTOMER;


DROP TABLE CUSTOMER;
DELETE TABLE CUSTOMER;
APPRISE TABLE CUSTOMER;
Ans: b

Page 3 of 5
iNeuron Intelligence Pvt Ltd

9. What does an ON UPDATE CASCADE ensure?

Standardizaaon
Data Integrity
Both a and b
None of the above
Ans: B

10. What does SQL data definiaon commands make up?

DDL
DML
DQL
DCL
Ans: A

11. Choose the valid SQL for an Index?

CREATE INDEX ID;


ALTER INDEX ID;
ADD INDEX ID;
DELETE INDEX ID;
Ans: A

12. Which SQL keyword(s) is used with wildcards?

IN and NOT IN
NOT IN only
LIKE only
IN only
Ans: C

Page 4 of 5
iNeuron Intelligence Pvt Ltd

13. Choose the correct order of keywords for SQL SELECT statements

WHERE, SELECT, FROM


SELECT, FROM, WHERE
SELECT, WHERE, FROM
FROM, WHERE, SELECT
Ans: b

14. What is a subquery in an SQL SELECT statement enclosed in?

brackets []
braces {}
parenthesis ()
none of the above
Ans: C

15. What is the result of a SQL SELECT statement?

report
form
table
file
Ans: c

Page 5 of 5
Page | 1
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

Q1. What is MySQL?

MySQL is a Relational Database Management System (RDMS) such as SQL


Server, Informix, etc., and uses SQL as the standard database language. It is
open-source software backed by Oracle and used to deploy cloud-native
applications using an opensource database.

Q2. What is a Database?

It is the structured form of data stored in a well-organized manner that can be


accessed and manipulated in different ways. The database is based on the
collection of schemas, tables, queries, and views. In order to interact with the
database, different database management systems are used. MySQL is used in
WordPress and gives you the option to create a MySQL database and its User
with the help of a control panel (cPanel).

Q3. Can you explain tables and fields?

The table is the set of organized data stored in columns and rows. Each
database table has a specified number of columns known as fields and several
rows which are called records. For example:

Table: Student
Field: Std ID, Std Name, Date of Birth
Data: 23012, William, 10/11/1989

Q4. What is the primary key?

The primary key is the combination of fields based on implicit NOT NULL
constraint that is used to specify a row uniquely. A table can have only one
primary key that can never be the NULL.

Page | 2
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

Q5. What is a unique key?

The unique key is the group of one or more fields or columns that uniquely
identifies the database record. The unique key is the same as a primary key
but it accepts the null value.

Q6. What is a foreign key?

The foreign key is used to link two tables together and it is a field that refers
to the primary key of another table.

Q7. What is a join?

As the name indicates, join is the name of combining columns from one or
several tables by using common values to each. Whenever the joins are used,
the keys play a vital role.

Q8. What is normalization?


Normalization is the process of organizing fields into a related table for
increasing integrity and removing redundancy in order to improve the
performance of the query. The main aim of the normalization is to add, delete,
or modify the fields that can be made in a single table.

Q9. What is Denormalization.

It is a technique in which data from higher to lower normal forms accessed


and it also used to add redundant data to one or more tables.

Page | 3
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q10. What are the types of join and explain each?

Depending on the relationship between tables, join has the following types:

Inner Join
It returns rows when there is at least one match of rows between the tables.

Right Join
It returns the common rows between the tables and all rows of the Right-hand
side table. In other words, it returns all the rows from the right-hand side table
even there is no matches in the left-hand side table.

Left Join
It returns the common rows between the tables and all rows of the left-hand
side table. In other words, it returns all the rows from the left-hand side table
even there are no matches in the right-hand side table.

Full Join
As the name indicates, full join returns rows when there are matching rows in
any one of the tables. It combines the results of both left and right table
records and it can return very large result-sets.

Q11. What is a View?


The view is a virtual table that consists of the subset of data contained in a
table and takes less space to store. It can have data from multiple tables
depending on the relationship.

Q12. What is an Index?

The index is the method of creating an entry for each value in order to retrieve
the records from the table faster. It is a valuable performance tuning method
used for faster retrievals.

Page | 4
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q13. What are all the different normalizations?

Following are the different normalization forms:

First Normal Form (1NF):


It is the process of removing all the duplicate columns from the table and
ensuring that each cell contains only one piece of information. In the first
normal form, there are only atomic values without any repeating groups.

Second Normal Form (2NF):


A relation is in 2NF if it satisfies the first normal form and does not contain
any partial dependency. Moreover, make sure the non-key attributes are fully
functional dependent on the primary key.

Third Normal Form (3NF):


Remove the columns that are not dependent on primary key constraints and
make sure it meets all the requirements of the second normal form.

Fourth Normal Form (4NF):


It should not have multi-valued dependencies and meet all the requirements of
the third normal form.

It depends on the interviewers they can only ask a single form of


normalization or all in their SQL interview questions.

Q14. What is a Cursor?


Cursor is known as the control of the database that enables traversal over the
rows in the table. It is very useful tool for different operations such as
retrieval, addition, and removal of database records. You can view the cursor
as a pointer to one row in a set of rows.

Page | 5
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q15. What are all the different types of indexes?

There are three types of indexes:

Unique Index

The unique index ensures the index key column has unique values and it
applies automatically if the primary key is defined. In case, the unique index
has multiple columns then the combination of values in these columns should
be unique.

Clustered Index

Clustered index reorders the physical order of a table and searches based on
its key values. Keep in mind, each table can have only one clustered index.

Non-Clustered Index

Non-Clustered Index does not alter the physical order but maintains a logical
order of table data. Each table in the non-clustered index can have 999
indexes.

Q16. What is a database relationship and what are they?

The database relationship is the connection between the tables of any


particular database. Following are the main types of relationships:

One to One Relationship


One to Many Relationship
Many to One Relationship
Self-Referencing Relationship
Page | 6
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

Q17. What is a query?


The database query is the name of getting information back from the database
with the help of coding. We can get expected results from the database
without wasting our valuable time because the query gives us output within a
short-time period.

Q18. What is subquery?


As the name indicates, it is also a query but used in another query. The outer
query is known as the main query and the inner query is called a subquery.
The subquery will be executed first and pass the results to the main query
then the output of both queries will be displayed.

Q19. Enlist the name of different subsets of SQL?


There are four subsets of SQL:

DDL (Data Definition Language)


DML (Data Manipulation Language)
DCL (Data Control Language)
TCL (Transaction Control Language)

Q20. Explain DDL with its examples?


As the name indicates, Data Definition Language (DDL) is used to define the
structure of data, table, schema, and modify it. For example:

CREATE: is used to create tables, databases, schema, etc.


DROP: is used to drop/remove tables and other database objects.
ALTER: is used to alter or change the definition of database objects.
TRUNCATE: is used to remove tables, procedures, and other database
objects.
ADD COLUMN: is used to add any column to table schema.
DROP COLUMN: is used to drop a column from any database table
Page | 7
structure

Page | 8
Page | 1
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q1. Explain DML with its examples?

DML (Data Manipulation Language) is a computer programming language is


used for the addition (insertion), deletion and modification of data in the
database. For example:

SELECT INTO: is used to select data from one table and insert into another
table.
INSERT: is used to insert data or records into a table.
DELETE: is used to delete records from any database table.
UPDATE: is used to update the values of different records in the database

Q2. Explain TCL with its examples?

TCL (Transaction Control Language) is a set of commands used to perform a


specific task on objects in a single unit of execution. In simple words, TCL
commands deal with transactions in a database. For example:

COMMIT: is used to commit transactions. Once a commit is made it cannot


be rolled back, so the previous image of the database cannot be retrieved
before running this transaction.
ROLLBACK: is used to revert the steps in transactions if an error arises.
SAVEPOINT: is used to set the savepoint in the transaction to which steps
can be rolled back.
SET TRANSACTION: is used to set characteristics of the transaction.

Q3. Write a SQL query to display the current date?


Following SQL query is used to return the database system date and time:
SELECT GETDATE();

This type of short queries are asked in the SQL interview questions so that
they can understand about the candidate’s knowledge and hands-on
experience.

Page | 2
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q4. What is a stored procedure?

It is a subroutine available to applications that need to access a relational


database management system (RDBMS). These procedures are stored in the
data dictionary and only executed in the database which is considered a big
disadvantage because it occupies more memory in the database server.
Moreover, it provides security and functionality to those users who are unable
to access data directly, so they can be granted access via stored procedures.

Q5. What is a trigger?

A database trigger is a code or program that helps to maintain the integrity of


the database. It automatically executes the response to particular events on a
table in the database.

For example, when a new employee is added to the employee database, new
records should be created in the related tables like Salary, Attendance, and
Bonus tables.

Q6. What is the difference between DELETE and TRUNCATE commands?

TRUNCATE command removes all the table rows permanently that can
never be rolled back. DELETE command is also used to remove the rows
from the table but commit and rollback can be performed after the deletion.
Moreover, the WHERE clause is also used as conditional parameters.

Q7. What is the main difference between local and global variables?

As the name indicates, the local variables can be used inside the function but
global ones are used throughout the program. Local variables are only limited
to the function and cannot be referred or used with other functions.

Page | 3
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q8. What is the main difference between local and global variables?

As the name indicates, the local variables can be used inside the function but
global ones are used throughout the program. Local variables are only limited
to the function and cannot be referred or used with other functions.

Q9. What is a constraint and what are the common SQL constraints?

SQL constraint is used to specify the rules for data in a table and can be
specified while creating or altering the table statement.

The following are the most widely used constraints:

NOT NULL
CHECK
DEFAULT
UNIQUE
PRIMARY KEY
FOREIGN KEY

Q10. What is Data Integrity?

Data integrity is the overall accuracy, completeness, and consistency of data


stored in a database. For example, in order to maintain data integrity, the
numeric columns/sells should not accept alphabetic data.

Q11. What is Auto Increment?

Auto increment allows the users to create a unique number to be generated


whenever a new record is inserted into the table. It helps to keep the primary
key unique for each row or record. If you are using Oracle then AUTO
INCREMENT keyword should be used otherwise use the IDENTITY
keyword in the case of the SQL Server.

Page | 4
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

Q12. What is the difference between the Cluster and Non-Cluster Index?

The clustered index defines the order in which data is physically stored in a
database table and used for easy retrieval by altering the way that the records
are stored.

The non-clustered index improves the speed of data retrieval from database
tables but stores data separately from the data rows. It makes a copy of
selected columns of data with the links to the associated table.
Q13. What is Datawarehouse?

It is the name of a central repository of data from multiple information


sources for analytics and business intelligence activities. Datawarehouse has
an enterprise-wide depth and based on its subsets called data marts which are
oriented to a specific business line or team.

Q14. What is Self-Join?

A self-join SQL query is used to compare to itself and values in a column are
compared with other values in the same column in the same database table
Q15. What is Cross-Join?
Cross-join is used to generate a paired combination of each row of table A
with each row of table B. If the WHERE clause is used in cross join then the
SQL query will work like an INNER JOIN.

Q16. What is user-defined functions?


Like functions in programming languages, SQL user-defined functions are
routines or functions that accept parameters, perform an action, such as a
complex calculation, and return the output of that particular action as a value.
There is no need to write the same logic several times because the function
can be called whenever needed.

Page | 5
iNeuron Intelligence Pvt Ltd
Q17. What are all types of user-defined functions?
Following are the user-defined functions:

Scalar Functions that return the unit or single-valued results


Inline Table-valued functions that return table as a return
Multi statement valued functions that return table as a return

Q18. What is collation?

Collation provides a set of rules that determine how character data can be
sorted and compared in a database. It also provides the case and accent
sensitivity properties. Collation is used to compare A and other language
characters with the help of ASCII value.

Q19. What are all different types of collation sensitivity?

Following are the different types of collation sensitivity:

Case Sensitivity (A & a, B & b or any other uppercase and lowercase letters)
Accent Sensitivity
Kana Sensitivity (Japanese Kana characters)
Width Sensitivity (Single byte character (half-width) & same character
represented as a double-byte character)

Q20. What are the pros and cons of Stored Procedure?


The stored procedure is based on modular programming that means create
once, store and call several times whenever you need it. It supports faster
execution and reduces the network traffic for optimum performance.

The main disadvantage of stored procedure is that it executed only in the


database and utilized more memory.

Page | 6
Page | 1
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

Q1. What are the pros and cons of Stored Procedure?

The stored procedure is based on modular programming that means create


once, store and call several times whenever you need it. It supports faster
execution and reduces the network traffic for optimum performance.
The main disadvantage of stored procedure is that it executed only in the
database and utilized more memory.

Q2. What is Online Transaction Processing (OLTP)?

As the name indicates, Online Transaction Processing (OLTP) is used to


manage transaction-based applications that can be used for data entry,
retrieval, and processing. It makes data management simple and efficient that
is the reason why bank transactions are using OLTP. You can view an insight
into the working of an OLTP system.
Q3. Define COMMIT.

COMMIT command is used to save all the transactions to the database since
the last COMMIT or ROLLBACK command where a transaction is a unit of
work performed against any database.

Here is the syntax of COMMIT command:


COMMIT;

Consider an example of the deletion of those records which have age = 25 and
then COMMIT the changes in the database.

SQL> DELETE FROM CUSTOMERS

WHERE AGE = 25;

SQL> COMMIT;
Page | 2
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q4. What is CLAUSE?

SQL clause is used to filter some rows from the whole set of records with the
help of different conditional statements. For example, WHERE and HAVING
conditions.

Q5. What is the difference between null, zero and blank space?

Null is neither same as zero nor blank space because it represents a value that
is unavailable, unknown, or not applicable at the moment. Whereas zero is a
number and blank space belongs to characters.

Q6. What is a recursive stored procedure?

It is the same as stored procedures but it calls by itself until it reaches any
boundary condition. So, it is the main reason why programmers use recursive
stored procedures to repeat their code any number of times.

Q7. What is Union, minus and Intersect commands?

Union operator is used to combining the results of two tables and removes the
duplicate rows. Minus is used to return matching records of the first and
second queries and other rows from the first query but not by the second one.
The Intersect operator is used to return the common rows returned by the two
select statements.

Q8. What is an ALIAS command?


ALIAS name can be given to a column or table and referred in WHERE
clause to identify the column or table. Alias column syntax:

SELECT column_name AS alias_name

FROM table_name;
Page | 3
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q9. What are aggregate and scalar functions?

The aggregate function performs mathematical calculations against a


collection of values and returns a single summarizing value. The scalar
function returns a single value based on the input value.

10. How can you create an empty table from an existing table?
With the help of the following command, we can create an empty table from
an existing table with the same structure with no rows copied:

Select * into copytable from student where 1=2

Q11. How to fetch common records from two tables?


Common records can be achieved by the following command:

Select studID from student INTERSECT Select StudID from Exam

Q12. How to fetch alternate records from a table?


Records can be fetched for both Odd and Even row numbers with the
following commands:

For even numbers:

Select studentId from (Select rownum, studentId from student) where


mod(rowno,2)=0

For odd numbers:

Select studentId from (Select rownum, studentId from student) where


mod(rowno,2)=1

Page | 4
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q13. How to select unique records from a table?

Apply the following SQL query to select unique records from any table:

Select DISTINCT StudentID, StudentName from Student

Q14. What is the command used to fetch first 4 characters of the string?

Following are the ways to fetch the first 4 characters of the string:

Select SUBSTRING(StudentName,1,4) as studentname from student


Select LEFT(Studentname,4) as studentname from student

Q15. What is a composite primary key?

The primary key that is created on more than one column is known as composite
primary key.

Q16. Which operator is used in query for pattern matching?

LIKE operator is used for pattern matching.

% (percent sign) Matches zero or more characters and _ (Underscore) is used for
matching exactly one character. For example:

Select * from Student where studentname like ‘m%’


Select * from Student where studentname like ‘meh_’
What do you mean by ROWID?
ROWID is an 18-character long pseudo column attached with each row of a
database table.

Page | 5
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

Q17. What are GROUP functions and give some examples?

Group functions are mathematical functions used to work on the set of rows
and return one result per group. AVG, COUNT, SUM, VARIANCE, MAX,
MIN are most commonly used Group functions.

Q18. What are Entities and Relationships?

The entity is the name of real-world objects either tangible or intangible and it is
the key element of relational databases. For a database entity, workflow and tables
are optional but properties are necessary. For example: In the database of any
institute, students, professors, workers, departments and projects can be known as
entities. Each entity has associated properties that offer it an identity.

The relationship is the name of links or relations between entities that have
something to do with each other. For example, the employee table should be
associated with the salary table in the company’s database.

Q19. What are GROUP functions and give some examples?

Group functions are mathematical functions used to work on the set of rows
and return one result per group. AVG, COUNT, SUM, VARIANCE, MAX,
MIN are most commonly used Group functions.
Q20. What is the MERGE statement?

MERGE statement is used to combine insert, delete and update operations


into one statement. It is also used to synchronize two tables and make the
changes in one table based on values matched from another.

Page | 6
Page | 1
iNeuron Intelligence Pvt Ltd

SQL (DESC & PRACTICAL) :

1. What is Database?
Ans. A database is an organized collection of structured information, or data,
typically stored electronically in a computer system. A database is usually
controlled by a database management system (DBMS).

2. What is SQL?
Ans. SQL is a structured query language. It is a standard language for
accessing and manipulating databases.

3. What are SQL commands?

Ans. There are five types of SQL Commands-

DDL(Data Definition Language),


DML(Data Manipulation Language),
DQL(Data Query Language),
TCL(Transaction Control Language),
DCL(Data Control Language).

4. What is the use of UPDATE statement


Ans. UPDATE statement is used when we want to update or change any
record. It must be used with WHERE clause if you want to change only one
record otherwise it would update the whole record

5. What is primary key?


Ans. Primary key constraint uniquely identifies each record in a table.
Primary keys must contain UNIQUE values, and cannot contain NULL
values. A table can have only one primary key.

Page | 2
iNeuron Intelligence Pvt Ltd

6. Difference between primary key and foreign key?

Ans. A primary key is a unique identifier for each record in a table whereas a
foreign key establishes a relationship between tables by referencing the
primary key of another table.

7. Difference between primary and unique key?

Ans. a primary key is a key that uniquely identifies each record in a table but
cannot store NULL values. In contrast, a unique key prevents duplicate values
in a column and can store NULL values.

8. What is char () in sql?


Ans. char() is a datatype which stores character data in a fixed length field.

9. what is the difference between char() and varchar()

Ans. char() stores character of fixed length and the maximum length currently
is 255 bytes whereas varchar() is used when the sizes of the column data
entries vary considerably. varchar() columns can be up to 65,535 bytes.

10. What is the main difference between update and alter commands in sql?

Ans. The main difference between the two is that the ALTER command adds,
deletes, modifies, renames the attributes of the relation, and the UPDATE
command modifies the values of the records in the relations.

11. What are the main components of insert statement?

Ans. There are three main components to an insert statement:


 The name of the table into which to add the data
 The names of the columns in the table to be populated
 The values with which to populate the columns

Page | 3
iNeuron Intelligence Pvt Ltd

12. Suppose you have a table named person how would you enter record in
this table?
Ans.

13. What is the difference between group by and order by?

Ans. A GROUP BY statement sorts data by grouping it based on column(s)


you specify in the query and is used with aggregate functions. An ORDER
BY allows you to organize result sets alphabetically or numerically and in
ascending or descending order.

14. what is the difference between drop, delete and truncate?

Ans. The DROP Command drops the complete table from the database.
The DELETE command deletes one or more existing records from the table
in the database.
The TRUNCATE Command deletes all the rows from the existing table,
leaving the row with the column names.

15. Suppose you have a table named language and you only want to retrieve
name column from it how will you proceed.
Ans.

Page | 4
iNeuron Intelligence Pvt Ltd

16. Write a query to retrieve unique values from the table flim_actor and sort it.

Ans.

17) how you would find all customers with the last name “Smith”:

Ans.

Page | 5
iNeuron Intelligence Pvt Ltd

__________________________________________________________________

18) What is the use of where clause.

Ans. The WHERE clause is used to filter records. It is used to extract only those
records that fulfill a specified condition.

19) Difference between where and having clause?

Ans. The main difference between WHERE and HAVING clause is that the
WHERE clause allows you to filter data from specific rows (individual rows) from
a table based on certain conditions. Whereas the HAVING clause allows you to
filter data from a group of rows in a query based on conditions involving aggregate
values.

20) Write a query to create a virtual table.

Ans.

Page | 6
Page | 1
iNeuron Intelligence Pvt Ltd

1) why do we define alias in sql?

Ans. when multiple tables are joined in a single query, you need a way to
identify which table you are referring to when you reference columns in
the select, where, group by, having, and order by clauses. So, by defining
alias we can refer to the table easily with a shortcut name.

2) Write a query to retrieve the records from film table whose rating is g and
are available for more than 7.

Ans.

3) What is the AND and OR commands?

Ans. The AND and OR operators are used to filter records based on more
than one condition: The AND operator displays a record if all the conditions
separated by AND are TRUE. The OR operator displays a record if any of the
conditions separated by OR is TRUE.
4) What is the order of execution in sql?

Ans. 1. From
2. Where
3. Groupby
4. Having
5. Select
6. Order by
7. Limit
Page | 2
iNeuron Intelligence Pvt Ltd

5) How can you use both AND & OR commands at the same time?

Ans. You should use parentheses to group conditions together. The next query
specifies that only those films that are rated G and are available for 7 or more
days, or are rated PG-13 and are available 3 or fewer days, be included in the
result set:

6) Retrieve the actor ID, first name, and last name for all actors. Sort by last
name and then by first name.

Ans.

7) Retrieve the actor ID, first name, and last name for all actors whose last
name equals 'WILLIAMS' or 'DAVIS'.

Ans.

Page | 3
iNeuron Intelligence Pvt Ltd
______________________________________________________________
8) Write a query against the rental table that returns the IDs of the customers
who rented a film on July 5, 2005 (use the rental.rental_date column, and you
can use the date() function to ignore the time component). Include a single
row for each distinct customer ID.

Ans.

9) What is the use of NOT operator in sql?

Ans. NOT is a logical operator in SQL that you can put before any
conditional statement to select rows for which that statement is false.

10) What is the use of between operator.

Ans. When you have both an upper and lower limit for your range, you may
choose to use a single condition that utilizes the between operator rather than
using two separate conditions.

11) Write a query where amount is in the range of 10 to 11.99.

Ans.

Page | 4
iNeuron Intelligence Pvt Ltd
______________________________________________________________

12) Write a query where whose last name falls in between FA and FR:

Ans.

13) What is the use of IN operator.

Ans. With the in operator, you can write a single condition no matter how
many expressions are in the set.

14) What are tables and fields?

Ans. In a table, there are rows and columns, with rows referred to as records
and columns referred to as fields.

15) Write a query for retrieving all the customers whose last_name starts with
‘Q’ or ‘Y

Ans.

Page | 5
iNeuron Intelligence Pvt Ltd
______________________________________________________________

16) Write a query for customer_id <> 5 AND (amount > 8 OR


date(payment_date) = '2005-08-23')?

Ans.

17) Write a query for customer_id = 5 AND NOT (amount > 6 OR


date(payment_date) = '2005-06-19')

Ans.

18) Construct a query that retrieves all rows from the payments table where
the amount is either 1.98, 7.98, or 9.98
Ans.

Page | 6
iNeuron Intelligence Pvt Ltd
______________________________________________________________

19) Construct a query that finds all customers whose last name contains
an A in the second position and a W anywhere after the A.

Ans.

20) What is join clause?

Ans. Join clause is used to combine two or more rows based on common
columns.
41) How many types of Joins are there?
Ans. 1. Inner Join
2. Left join
3. Right join
4. Full outer join
5. Self join

Page | 7
Page | 1
iNeuron Intelligence Pvt Ltd
______________________________________________________________

1) What is a Measure in Power Bi?


Ans. A measure is defined as a calculation based on column values in a table or across
multiple tables.

2) What is a power query?


Ans. Power Query is the data connectivity and data preparation technology that enables
end users to seamlessly import and reshape data.

3) How Group by helps in Power query?


Ans. The Group By feature in Power BI summarizes data based on one or more
aggregate functions.

4) What is Merge query?


Ans. helps to join two tables based on common columns.

5) What is Append query?


Ans. append query helps when you need to add new records to an existing table by using
data from other sources.

6) What is Conditional column?


Ans. Columns that are added to your tables based on specific conditions.

7) What is a Manage Parameter?


Ans. Manage Parameters in Power BI are used to dynamically adjust values in queries,
allowing users to easily modify inputs, such as filter conditions or data source
connections, without editing the underlying query code.

Page | 2
iNeuron Intelligence Pvt Ltd
______________________________________________________________

08) Is there any difference between Choose Column & Remove column? If yes, what is
it?
Ans. Both do the same work but in different way, choose column will show a dialogue
box in which you can select which columns to keep in the query and on the other hand
remove column removes the column which ever are selected and throw them out.

09) What is the use of Pivot column and unpivot column?


Ans. Pivot column: Restructures data by converting unique values into columns.
Unpivot column: Reshapes data by transforming columns into rows.

10) What does Parse command do?


Ans. Converts a text column into a different data type.

11) What is the use of Number Column Function?


Ans. Generates a series of numbers based on specified parameters, often used for
creating indices.

12) How does add columns from example work?


Ans. Allows users to add new columns by providing examples, enabling Power BI to
infer transformations.

13) What is one to one relationship?


Ans. Each record in the first table corresponds to exactly one record in the second, and
vice versa.

14) What is one to many relationships?


Ans. Each record in the first table can relate to multiple records in the second, but each
record in the second table relates to only one record in the first.

Page | 3
iNeuron Intelligence Pvt Ltd
______________________________________________________________

15) What is a Slicer?


Ans. A visual filter that allows users to interactively filter data in reports.

16) What is the use of Drill through


Ans. Allows users to navigate from a summary report to a detailed report for specific
data points.

17) Difference between card and multi row card?


Ans. A card shows a single value, while a multi-row card displays multiple values in a
column format

18) What is KPI?


Ans. KPI (Key Performance Indicator) is a measurable value that demonstrates how
effectively a company is achieving key business objectives.

19) Difference between Table and Matrix?


Ans. A table displays data in a grid, while a matrix allows for row and column grouping,
providing a more flexible structure.

20) What is the query property?


Ans. In Power BI, the "Query" property refers to the applied steps and transformations
performed on the data in Power Query Editor.

Page | 4
Page | 1
iNeuron Intelligence Pvt Ltd
_______________________________________________________________________

1) What is aggregation?
Ans. Aggregation is the process of summarizing and combining data, often using functions like
SUM, AVG, COUNT, etc.

2) What exactly Dax is?


Ans. DAX (Data Analysis Expressions) is a formula language used in Power BI for creating
custom calculations and aggregations in data models.

3) Why Dax cant modify individual points in space or cell like Excel?
Ans. Dax can't modify individual points because it operates at an aggregated level, working
with sets of data rather than individual cells like Excel.

4) What is a calculated columns?


Ans. Calculated columns are custom columns in a table created using DAX formulas based on
other columns' values.

5) What is a calculated Tables?


Ans. Calculated tables are created using DAX expressions to define a table by specifying its
columns and values based on other tables.

6) What is the Difference between Sum and Sumx?


Ans. SUM is an aggregation function for a single column, while SUMX is an iterator function
that operates on a table, applying an expression to each row and then aggregating.

7) How does Power BI handle data refreshes, and what considerations should be taken into
account?
Ans. Power BI handles data refreshes by fetching updated data from the data source;
considerations include data source type, refresh frequency, and credentials for data source
access.

Page | 2
iNeuron Intelligence Pvt Ltd
_______________________________________________________________________

8) How can you handle missing values in Power Query?


Ans. To handle missing values in Power Query, you can use functions like "Fill Down,"
"Replace Values," or "Remove Rows" based on your data cleaning requirements.

9) Describe the difference between "Remove Rows" and "Filter Rows" in Power Query.
Ans. Remove Rows" deletes entire rows based on specified criteria, while "Filter Rows" retains
rows but hides them from view in the current query

10) Explain the concept of data types in Power Query.


Ans. Data types in Power Query specify the kind of data contained in a column, such as text,
number, date, etc., and influence data transformations and operations.

11) How can you split a column into multiple columns in Power Query?
Ans. You can split a column into multiple columns in Power Query using the "Split Column"
option, specifying a delimiter or a fixed number of characters.

12) What is the purpose of the "CALCULATE" function in DAX?


Ans. The "CALCULATE" function in DAX is used to modify or override the context in which a
calculation is made, allowing for more complex and dynamic calculations.

13) How do you use the "FILTER" function in DAX to apply conditions?
Ans. The "FILTER" function in DAX is used to apply conditions and filter data based on
specified criteria.

14) How can you create custom tooltips in Power BI?


Ans. Custom tooltips in Power BI can be created by defining a measure and using it in the
Tooltip field for a visual.

Page | 3
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________

15) Describe the process of creating a custom theme in Power BI.


Ans. To create a custom theme in Power BI, you can define JSON code with specific color
schemes and
formatting preferences and apply it in the "Switch Theme" option.

16) Explain the differences between one-to-one, one-to-many, and many-to-many relationships
in Power BI
Ans. One-to-one relationships link each row in one table to a single row in another, one-to-
many relationships link each row in one table to multiple rows in another, and many-to-many
relationships involve intermediary tables connecting multiple rows between two tables

17) What are the common steps involved in data cleaning using Power Query?
Ans. Common steps in data cleaning using Power Query include removing duplicates, handling
missing values, transforming data types, and filtering rows.

18) What is the "New Table" feature in Power BI, and how can you use it in data modeling?
Ans. "New Table" in Power BI is a feature for creating calculated tables using DAX
expressions, enhancing data modeling by introducing new derived tables.

19) What is the difference between Power BI Reports and Dashboards?


Ans. Power BI Reports are multi-page documents containing visualizations, while Dashboards
are single-page collections of visualizations and reports for concise data presentation.

20) When would you use a line chart instead of a bar chart?
Ans. Use a line chart to display trends over time, showing continuous data points, whereas a bar
chart is suitable for comparing distinct categories.

Page | 4
Page | 1
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

1) What is a Ribbon Chart and when would you use it?


Ans. A Ribbon Chart in Power BI is a stacked area chart that visualizes data distribution
over time, useful for showing the proportion of categories within a whole.

2) What are the benefits of Combo Charts ?

Ans. When you have a line chart and a column chart with the same X axis.
To compare multiple measures with different value ranges.
To illustrate the correlation between two measures in one visual.
To check whether one measure meets the target which is defined by another
measure.
To conserve canvas space.

3) How Donut Chart and Pie Chart are similar?


Ans. Doughnut charts are similar to pie charts. They show the relationship of parts to a
whole. The only difference is that the center is blank and allows space for a label or icon.

Page | 2
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Question Based on Scenario:
4) Your data source includes text data. How can you use Power Query to clean and transform
this unstructured data for analysis?

Ans. Step 1: Connect to Data Source:


Step 2: Load Data into Power Query:
Step 3: Text-to-Columns:
If your text data contains structured information separated by delimiters (commas, tabs, etc.),
you can use the "Split Column" feature to split it into separate columns.
Step 4: Remove Unnecessary Columns:
If there are columns that are not needed for analysis, remove them.
Step 5: Remove Duplicates:
If there are duplicate rows, use the "Remove Duplicates" feature to clean the data.
Step 6: Trim and Clean Text:
Use functions like Text.Trim() and Text.Clean() to remove leading/trailing spaces and clean up
special characters.
Step 7: Transform Case:
Use functions like Text.Upper(), Text.Lower() to standardize the case of text.
Step 8: Replace Values:
Use Replace Values to replace specific text values with others.
Step 9: Conditional Columns:
Use conditional columns to create new columns based on specific conditions within the text
data.
Step 10: Split Columns Based on Patterns:
If your text data follows a pattern, use the "Split Column by Delimiter" or "Split Column by
Number of Characters" feature.
Step 11: Custom Columns:
Use the "Add Column" tab to create custom columns with calculated expressions to derive
insights from the text data.
Step 12: Data Type Formatting:
Ensure that columns have the correct data types for analysis (e.g., Date, Text, Whole Number).
Step 13: Preview Data:
Regularly preview the data to ensure that the transformations are achieving the desired results.
Step 14: Close and Apply:
Once you're satisfied with the transformations, click "Close & Apply" to apply the changes and
load the cleaned data into your Power BI model.

Page | 3
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

Question Based on Dax Formula :

5) How would you write Dax formula for revenue generated for table named sales_book
?
Ans. Revenue = Sum (‘sales_book’[Total Sales])

6) How would you write Dax formula for average sales generated in the last month?
Ans. Average_Sales = AVERAGE(‘sales_book’[Sales])

7) Write Dax formula for sum of sales?


Ans. Revenue = Sum(‘sales_book’ [Total Sales])

8) Write a Dax formula for creating a measure showing the sum of profit?
Ans. TotalProfit = SUMX (Sales, Sales [Profit])

9) Write a Dax formula for creating a measure showing loss?


Ans. Loss = [Revenue] - [Cost]

10) You're working with sales data from multiple regions. How would you create a report that
displays a trend analysis?

Ans. Step 1: Import data.


Step 2: Data Transformation and modelling
Step 3: Create Relationship
Step 4: Design Reports
Step 5: Analyze trends.
Step 6: Customs & Refine
Step 7: Dashboard Creation
Step 8: Share

Page | 4
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
11) A client requires a geographic analysis of their sales data. How would you visualize
this data using maps and location-based insights?

Ans. Utilize the "Map" visual to show sales data by location. Incorporate geographic
data, such as country or city names, and use color intensity or size of data points to
represent sales values. Leverage the "Filled Map" or "Shape Map" for regional insights.
Apply filters or slicers for interactivity, allowing users to focus on specific regions or
time frames.

12) What observation we can get from the above line chart ?

Ans. The above line Chart represents This year and Last year sales by Fiscal month and
the conclusion we can get from it is around July month this year we saw a dip in sales
whereas previous year sales shows rise in the same month.
Also this year sales shows major ups and downs.
Page | 5
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

13) What are Capacities in Power Bi?

a) Set of resources b) Data Tab


c) Workspace d) model
Ans. a) Set of resources

14) What is a Semantic model in Power Bi?

a) Workspace b) Data Model


c) Database d) Data Element
Ans. b) Data model

15) What is a Data model in Power Bi?

a) logical representation of how data is structured and related within the tool
b) Data structure
c) Database d) Data Element
Ans. a) logical representation of how data is structured and related within the tool

16) What is a Star Schema in Power Bi?

a) Data Modelling Method b) Relation between tables


c) Data Structure d) Data Element
Ans. a) Data Modelling Method

17) What is a Fact Table in Power Bi?

a) Table containing rows and Column b) Relation between tables


c) Table containing specific events, measurements d) Table containing additional events

Ans. c) Table containing specific events, measurements additional events

Page | 6
iNeuron Intelligence Pvt Ltd
18) What is a Dimension Table in Power Bi?

a) Table containing rows and Column b) Relation between tables


c) Table containing specific events, measurements d) Table containing

19) What is Primary Key?

a) whose values uniquely identify a row in the table b) Relation between


tables

c) whose values corresponds to a value of primary key d) Whose value is distinct


column

Ans. a) whose values uniquely identify a row in the table

20) What is Alternative Key?

a) whose values uniquely identify a row in the table b) Relation between tables

c) whose values corresponds to a value of primary key d) Whose value is distinct


column

Ans. c) whose values corresponds to a value of primary key

Page | 7
Page | 1
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

1) What are the major part of Visualization pane?


a) Fields b) Formats
c) Analytics d) All of the above
Ans. d) All of the above

11) What is Power BI primarily used for?


a. Video Editing b. Data Analysis and Visualization
c. Web Development d. Word Processing
Ans. b) Data Analysis and Visualization

2) Which component in Power BI is used for creating visualizations?


a. Power Query b. Power Pivot
c. Power View d. Power Map
Ans. c) Power View

3) Which language is used for creating calculated columns and measures in Power
BI?
a. Python b. R
c. DAX d. SQL
Ans. c) DAX

4) In Power BI Desktop, what is the purpose of the "Data" view?


a. To create visualizations b. To edit queries
c. To view and modify data model d. To manage report layout
Ans. c) To view and modify data model

5) Which view in Power BI Desktop allows you to create relationships between


tables?
a. Report view b. Data view
c. Relationship view d. Model view
Ans. d) Model view

6) Which visualization type in Power BI is used to display hierarchical data?


a. Table b. Pie Chart
c. Tree map d. Line Chart
Ans. c) Tree map

Page | 2
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

7) Which visualization type in Power BI is used to display trends over time?


a. Pie Chart b. Line Chart
c. Scatter Plot d. Gauge
Ans. b) Line Chart

8) What is the purpose of the "Format" pane in Power BI Desktop?


a. To define relationships between tables b. To create calculated columns
c. To format and customize visualizations d. To edit data model
relationships
Ans. c) To format and customize visualizations

9) In Power BI, what is the difference between a report and a dashboard?


a.A report is a single page, and a dashboard is a collection of visualizations and reports.
b. A report is a collection of visualizations and reports, and a dashboard is a single page.
c. A report and a dashboard are the same thing.
d. A report is used in Power BI Desktop, and a dashboard is used in Power BI Service.

Ans. a) A report is a single page, and a dashboard is a collection of visualizations and


reports.

10) What is the purpose of Power BI Q&A?


a. To create calculated columns
b. To define relationships between tables
c. To ask natural language questions and get visualizations as answers
d. To edit report layout
Ans. c) To ask natural language questions and get visualizations as answers

11) How does Power BI Q&A understand natural language queries?


a. By using keyword matching b. By using a predefined set of questions
c. By using machine learning algorithms d. By analyzing data models
Ans. c) By using machine learning algorithms

Page | 3
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________

12) What is the difference between calculated columns and measures in DAX?
a). Calculated columns are used for aggregations, and measures are used for
calculations.
b). Calculated columns are created in the data model, and measures are created
in the report.
c). Calculated columns are stored in the data model, and measures are calculated on
the fly.
d). Calculated columns are created in Power Query, and measures are created in
DAX.
Ans. c) Calculated columns are stored in the data model, and measures are
calculated on the fly.

13) Which key is known as a ‘surrogate’


a. Alternative key b. Reference Key
c. Primary Key d. Secondary Key
Ans. c) Primary Key

14) Which type of relationship in Power BI allows for only one matching row
on either side of the relationship?
a. One-to-One b. One-to-Many
c. Many-to-One d. Many-to-Many
Ans. a) One-to-One
15) Which DAX function is used to create relationships between tables in
Power BI?
a. RELATED()
b. RELATEDTABLE()
c. CONCATENATE()
d. VLOOKUP()
Ans. a) RELATED()

Page | 4
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
16) Which of the following is true about calculated columns in Power BI?
a. They are created on the fly during visualization.
b. They are stored in the data model.
c. They are used only for aggregations.
d. They are created using Power Query.
Ans. b) They are stored in the data model

17) What does the "Manage Relationships" window in Power BI allow you to
do?
a. Create calculated columns b. Define relationships between tables
c. Create measures d. Import data from external sources
Ans. b) Define relationships between tables

18) What does the "New Table" feature in Power BI allow you to do?
a. Create calculated columns b. Create calculated tables
c. Create relationships between tables d. Import data from external sources
Ans. b) Create calculated tables

19) Which visualization type is suitable for showing the distribution of a single
numeric variable?
a. Pie Chart b. Line Chart
c. Histogram d. Treemap
Ans. c) Histogram

20) In Power BI, what is the purpose of the "Card" visualization?


a. To display a single value b. To show trends over time
c. To compare multiple categories d. To represent hierarchical data
Ans. a) To display a single value

Page | 5
iN
er

1
ur
on
.a
i
​ 1. What is the primary purpose of using a table in Power BI?
● A. Displaying visualizations

i
● B. Showing detailed data in tabular format

.a
● C. Creating pie charts
● D. None of the above
on
● Answer: B. Showing detailed data in tabular format
​ 2. In Power BI, what is the main difference between a table and a matrix?
● A. Tables are for numeric data, matrices for text data
● B. Tables allow drill-down, matrices do not
ur
● C. Matrices allow data grouping, tables do not
● D. There is no difference
● Answer: C. Matrices allow data grouping, tables do not
​ 3. How can you format text in a table in Power BI?
er

● A. Only bold and italic options


● B. Font color, size, and style options
● C. Underlining text
iN

● D. No text formatting options


● Answer: B. Font color, size, and style options
​ 4. What is the purpose of the "Drill Down" feature in a matrix in Power BI?
● A. To hide specific rows or columns
● B. To reveal more detailed data
● C. To change the matrix color scheme
● D. Both A and C
● Answer: B. To reveal more detailed data
​ 5. How can you add subtotals and grand totals to a matrix in Power BI?
● A. By using the "Group" feature
● B. Automatically added by default
● C. By using the "Subtotals" option in the matrix settings
● D. Subtotals and grand totals cannot be added

2
● Answer: C. By using the "Subtotals" option in the matrix settings
​ 6. Explain the concept of "Row Grouping" in a matrix in Power BI.

i
● A. It arranges data based on column values

.a
● B. It organizes data hierarchically based on rows
● C. It filters out specific rows
on
● D. It colors specific rows for emphasis
● Answer: B. It organizes data hierarchically based on rows
​ 7. How can you customize the appearance of a table or matrix using
conditional formatting in Power BI?
ur
● A. By changing the font style based on data values
● B. By applying color scales to cells
● C. By adding data bars to cells
● D. All of the above
er

● Answer: D. All of the above


​ 8. What is the default aggregation method for numeric data in a table or
matrix in Power BI?
iN

● A. Average
● B. Sum
● C. Count
● D. Maximum
● Answer: B. Sum
​ 9. In Power BI, how can you add a calculated column to a table?
● A. Using DAX (Data Analysis Expressions)
● B. Dragging and dropping a field
● C. Right-clicking and selecting "Add Calculated Column"
● D. Calculated columns cannot be added in Power BI
● Answer: A. Using DAX (Data Analysis Expressions)
​ 10. What is the purpose of the "Expand/Collapse" feature in a matrix in Power
BI?

3
● A. To merge adjacent cells
● B. To hide or reveal nested rows or columns

i
● C. To switch between table and matrix views

.a
● D. Both A and C
● Answer: B. To hide or reveal nested rows or columns

on
11. How can you sort data in a table or matrix in descending order based on a
specific column in Power BI?
● A. By right-clicking the column header and selecting "Sort Descending"
● B. By using the "Sort Ascending" button in the ribbon
ur
● C. By applying a filter to the column
● D. Sorting in descending order is not possible
● Answer: A. By right-clicking the column header and selecting "Sort
Descending"
er

​ 12. Explain the difference between a calculated column and a measure in


Power BI.
● A. Calculated columns are static, measures are dynamic
iN

● B. Measures are used for aggregations, calculated columns for


individual row calculations
● C. Both A and B
● D. There is no difference
● Answer: C. Both A and B
​ 13. How can you create a hierarchy in a matrix in Power BI, and what benefits
does it offer?
● A. By grouping columns, offering drill-down capabilities
● B. By sorting data alphabetically
● C. Hierarchy creation is not possible in Power BI matrices
● D. By using conditional formatting
● Answer: A. By grouping columns, offering drill-down capabilities

4
​ 14. What is the purpose of the "Subtotal" row in a matrix in Power BI, and how
is it different from the "Grand Total"?

i
● A. Subtotal shows the total for each group, Grand Total shows the

.a
overall total
● B. Subtotal and Grand Total are the same
on
● C. Subtotal and Grand Total cannot be added to a matrix
● D. Subtotal and Grand Total show the same values but in different
styles
● Answer: A. Subtotal shows the total for each group, Grand Total shows
ur
the overall total
​ 15. How can you hide specific columns in a table or matrix in Power BI
without removing them from the dataset?
● A. By right-clicking the column and selecting "Hide"
er

● B. By using the "Column Settings" in the field well


● C. Both A and B
● D. Columns cannot be hidden in Power BI
iN

● Answer: C. Both A and B


​ 16. Explain the concept of "Drillthrough" in Power BI and how it can be used in
tables and matrices.
● A. Drillthrough allows users to explore more detailed data by clicking
on a cell
● B. Drillthrough is only applicable to tables, not matrices
● C. Drillthrough is a visualization type in Power BI
● D. Both A and B
● Answer: A. Drillthrough allows users to explore more detailed data by
clicking on a cell
​ 17. How can you dynamically change the columns displayed in a matrix based
on user input or selections in Power BI?
● A. Using the "Show Items with no data" option

5
● B. By applying row-level security
● C. By utilizing the "Drill Up" feature

i
D. Using the "Show Columns" feature in the matrix settings

.a

● Answer: D. Using the "Show Columns" feature in the matrix settings
on
ur
er
iN

6
iN
er

1
ur
on
.a
i
​ 1. What type of chart is a Donut Chart?
● A. Bar Chart
● B. Pie Chart

i
● C. Line Chart

.a
● D. Donut Chart
● Answer: B. Pie Chart

on
2. What does the central hole in a Donut Chart represent?
● A. Data Labels
● B. Blank Space
● C. Subcategory
ur
● D. Highlighted Area
● Answer: B. Blank Space
​ 3. How can you add a Donut Chart to your Power BI report?
● A. Insert Image
er

● B. Add Visualizations
● C. Create Table
● D. Apply Theme
iN

● Answer: B. Add Visualizations


​ 4. In a Donut Chart, what does the outer ring represent?
● A. Overall Total
● B. Subcategory Total
● C. Relative Percentage
● D. Data Labels
● Answer: A. Overall Total
​ 5. What is the primary advantage of using a Donut Chart over a Pie Chart?
● A. Better Color Options
● B. Improved Readability
● C. Highlighting Trends
● D. Displaying Exact Values
● Answer: B. Improved Readability

2
​ 6. How can you customize the colors of segments in a Donut Chart?
● A. By Default Theme
● B. Format Options

i
● C. Color Palette

.a
● D. Data Labels
● Answer: B. Format Options

on
7. What is the purpose of the central hole in a Donut Chart design?
● A. Aesthetic Appeal
● B. Improved Visualization
● C. Highlighting Specific Data
ur
● D. Creating Subcategories
● Answer: A. Aesthetic Appeal
​ 8. How can you enable data labels in a Donut Chart?
● A. By Default
er

● B. Format Options
● C. Data Labels Section
● D. Apply Theme
iN

● Answer: C. Data Labels Section


​ 9. When is it appropriate to use a Donut Chart in data representation?
● A. Displaying Exact Values
● B. Comparing Data Proportions
● C. Showing Time Series Data
● D. Representing Hierarchical Data
● Answer: B. Comparing Data Proportions
​ 10. Which of the following charts is similar to a Donut Chart but without the
central hole?
● A. Bar Chart
● B. Line Chart
● C. Gauge Chart
● D. Area Chart

3
● Answer: C. Gauge Chart
​ 11. In Power BI, where can you find the option to add a Donut Chart to your
report?

i
● A. Visualization Pane

.a
● B. Query Editor
● C. Data Model
on
● D. Format Options
● Answer: A. Visualization Pane
​ 12. What is the primary purpose of a Donut Chart?
● A. Analyzing Trends
ur
● B. Comparing Values
● C. Showing Hierarchical Data
● D. Visualizing Part-to-Whole Relationships
● Answer: D. Visualizing Part-to-Whole Relationships
er

​ 13. In a Donut Chart, what does the angle of a segment represent?


● A. Absolute Value
● B. Relative Percentage
iN

● C. Subcategory Total
● D. Overall Total
● Answer: B. Relative Percentage
​ 14. Can you display the percentage values directly on the segments of a
Donut Chart?
● A. Yes, always
● B. No, it's not possible
● C. Yes, but only in certain versions of Power BI
● D. Yes, but requires a specific customization
● Answer: C. Yes, but only in certain versions of Power BI
​ 15. What is the main limitation of a Donut Chart?
● A. Limited Color Options
● B. Less Readability

4
● C. Inability to Show Exact Values
● D. Difficulty in Customization
● Answer: C. Inability to Show Exact Values

i
​ 16. How can you create a multi-level Donut Chart in Power BI?

.a
● A. By Using Custom Visualizations
● B. It's not possible
on
● C. Through Advanced Formatting Options
● D. Using DAX Formulas
● Answer: A. By Using Custom Visualizations
​ 17. What role does data sorting play in enhancing the effectiveness of a Donut
ur
Chart?
● A. No Impact
● B. Improved Readability
● C. Changes Color Scheme
er

● D. Influences Animation
● Answer: B. Improved Readability
​ 18. In Power BI, can you create an animated Donut Chart?
iN

● A. Yes, with built-in animation options


● B. No, Power BI doesn't support animation in charts
● C. Yes, but only with external plugins
● D. Yes, but requires coding skills
● Answer: B. No, Power BI doesn't support animation in charts

5
iNeuron Intelligence Pvt Ltd
Tableau MCQ :

1. Which of the following file types can Tableau work with?


a) .xls
b) .csv
c) .txt
d) All of the above
Ans. d) All of the above

2. In Tableau, what is a "Dashboard"?

a) A type of database
b) A collection of worksheets arranged on a single screen
c) A data source
d) A filter
Ans. b) A collection of worksheets arranged on a single screen

3. What is a "Dimension" in Tableau?

a) A measure of data
b) A qualitative attribute or categorical field
c) A filter condition
d) A calculated field
Ans. b) A qualitative attribute or categorical field

4. How can you create a calculated field that concatenates two string
fields in Tableau?
a. Use the CONCATENATE() function
b. Use the + operator
c. Use the STRCAT() function
d. All of the above
Answer: d) All of above
iNeuron Intelligence Pvt Ltd

5. What is the purpose of the "Show Me" menu in Tableau?


a) To display the user's profile
b) To show available data sources
c) To change the chart type of the selected view
d) To access Tableau settings
Ans. c) To change the chart type of the selected view

6. What does the term "Aggregation" mean in Tableau?

a) A type of chart
b) A method of combining multiple charts
c) Summarizing and displaying data
d) Sorting data alphabetically
Ans. c) Summarizing and displaying data

7. How can you create a calculated field in Tableau?


a) By dragging and dropping a field into the calculated fields area
b) By right-clicking on a field and selecting "Create Calculated Field"
c) By using a separate application
d) Both a and b
Ans. d) Both a and b

8. What is the role of the "Marks" card in Tableau?


a) To show the data types of field
b) To display a summary of the data source
c) To control the level of detail in the view
d) To create a calculated field
Ans. c) To control the level of detail in the view
iNeuron Intelligence Pvt Ltd
9. Which of the following is true about the "Dual-Axis" feature in
Tableau?

a) It creates a copy of the chart on the same axis


b) It combines two charts into one
c) It allows for the use of two different data sources
d) It adjusts the scale of two charts on separate axes
Ans. d) It adjusts the scale of two charts on separate axes

10. What is the purpose of the "Data Interpreter" in Tableau?

a) To interpret programming code


b) To clean and transform data
c) To analyze dashboard performance
d) To create calculated fields
Ans. b) To clean and transform data

11. How can you create a Tableau extract?

a) By copying and pasting data from Excel


b) By importing a CSV file
c) By connecting to a data source and selecting "Extract"
d) Both a and b
Ans. c) By connecting to a data source and selecting "Extract”.

12. What is the default aggregation for a measure in Tableau?

a) COUNT
b) SUM
c) AVG
d) MIN
Ans. b) SUM
iNeuron Intelligence Pvt Ltd

13. How can you sort data in Tableau?


a) By right-clicking on a field and selecting "Sort"
b) By dragging and dropping a field into the "Sort" shelf
c) By using the "Sort" option in the toolbar
d) All of the above
Ans. d) All of the above

14. Which of the following is a map-related chart type in Tableau?


a. Bar chart
b. Line chart
c. Scatter plot
d. Symbol map
Ans. d) Symbol Map

15. What is the purpose of the "Tableau Public" version?


a. It is a free version of Tableau for personal use
b. It is a version designed for large enterprises
c. It is a version that can only connect to cloud data sources
d. It is a version with advanced features not available in the standard
version
Ans. a) It is a free version of Tableau for personal use

16. What are different joins in tableau?


a. Inner
b. Left
c. Right
d. All the above
Ans. d) All of the above
iNeuron Intelligence Pvt Ltd

17. In which colour does Discrete is shown in tableau?


a. Red b. Blue
c. Green d. Yellow
Ans. b) Blue

18. What Will the Following Function Return?


Left (3, “Tableau”)
Choose the correct answer:
a) Tab
b) Eau
c) Error
d) None of the above
Ans. c) Error

19. Which type of chart in Tableau is best suited for showing the
distribution of a single continuous variable?
a Bar chart
b. Pie chart
c. Scatter plot
d. Histogram
Ans. d) Histogram
20. What is the role of a filter in Tableau?
a. To modify the data source
b. To exclude certain data from the view
c. To create calculated fields
d. To add new data to the
Ans. b) To exclude certain data from the view
iNeuron Intelligence Pvt Ltd
1. What is Tableau?

Ans. Tableau is a powerful data visualization tool that allows users to connect to various data sources, create
interactive dashboards, and generate insightful reports. It turns the raw data into a format that is easy to
understand. Dashboards can be used to create visualizations.

2. What are the different data connection options available in Tableau?

Ans. Tableau provides various data connection options, including Excel spreadsheets, text files, databases (such
as SQL Server, Oracle, MySQL), and web data connectors.

3. Differentiate between Tableau Desktop and Tableau Server?

Ans.
Tableau Desktop Tableau Server
Tableau Desktop is a data visualization To share the Tableau files , with the different
application that lets you analyse virtually any users across the company, we need server, this
type of structured data and produce highly is a web based application.
interactive, beautiful graphs, dashboards, and
reports in just minutes. So in Tableau Desktop I
can make the visualizations ad I can publish
these tableau file (.twbx files) on the server.

4. What are the datatypes used in Tableau?

Ans. Text values, date values, Date, and time values, Boolean , Geograohical.

5. Difference between Measure and Dimension?

Ans.
Dimension Measure
Dimensions contain qualitative values (such as Measures contain numeric, quantitative values
names, dates, or geographical data) that you can measure (such as Sales, Profit)

Example: Category, City, Country, Customer ID, Example: Profit, Quantity, Rank, Sales, Sales per
Customer Name, Order Date, Order ID Customer, Total Orders
iNeuron Intelligence Pvt Ltd
6. What is sets area of the data pane?

Ans. If the data source you are using contains at least one set, or if you have created one or more sets, they will
show up here.

7. Difference between Discrete and Continuous?

Ans.

Discrete Continuous
Discrete field creates header. Continuous field creates axes.
Discrete can be sorted Continuous cannot be sorted it follows its own
chronological order. Left being the old result
and the right side being the latest result.

8. Differentiate between Tableau Extract and Tableau Data Source.

Ans. A Tableau Extract is a snapshot of data saved in a. hyper file, while a Tableau Data Source is a live
connection to a data repository.

9. How does Tableau handle big data?

Ans. Tableau supports connecting to various big data sources like Hadoop, Amazon Redshift, and Google Big
Query.

10. What is a Tableau Dashboard?

Ans. A Tableau Dashboard is a collection of views arranged on a single canvas, allowing users to see and
compare multiple visualizations simultaneously.
iNeuron Intelligence Pvt Ltd
11. How can you filter data in Tableau?
Ans. Data can be filtered using Quick Filters, Context Filters, and Top N filters in Tableau.
12. Explain the difference between a worksheet and a dashboard.
Ans. A worksheet is a single page where visualizations are created, while a dashboard is a collection of multiple
worksheets.

13. What is the role of calculated fields in Tableau?

Calculated fields are used to create new data from existing data in Tableau, performing calculations and
transformations.
14. How can you create a calculated field in Tableau?
Ans. Calculated fields are created by using formulas involving existing fields and functions.
15. What are the different file types generated by Tableau Desktop?
Ans. Tableau Workbook (.twb) and Tableau Packaged Workbook (.twbx) are the two main file types.

16. What are the key considerations when using a line chart to visualize time-series data in Tableau? How can
you customize the appearance of the line chart to enhance its effectiveness?

Ans. When visualizing time-series data in Tableau using a line chart, it's important to set the date field on the
Columns shelf. You can customize the appearance by adjusting the line style, color, and thickness. Additionally,
using reference lines or bands can help highlight specific periods or trends

17. Describe the process of creating a stacked bar chart in Tableau. When is it appropriate to use a stacked bar
chart, and what insights can it provide?

Ans. To create a stacked bar chart in Tableau, drag the dimension you want to stack onto the Color shelf. Stacked
bar charts are useful when you want to show the total and the contribution of each category to the total. They
work well for illustrating part-to-whole relationships.

18. Explain the steps to create a combined axis bar chart in Tableau. What are the advantages of combining
multiple measures in a single bar chart?

Ans. To create a combined axis bar chart in Tableau, drag the second measure onto the same axis as the first
measure. This is useful when comparing two related measures on a common scale. For instance, you might
compare sales and profit for different product categories.

19. How can you create a chart with independent axes in Tableau? Provide an example scenario where
independent axes are necessary for accurate data representation.
Ans. In Tableau, you can create a chart with independent axes by using dual axes and then synchronizing or
desynchronizing them as needed. Independent axes are necessary when the measures being compared have
different scales, and aligning them would distort the visualization.

20. Discuss the differences between synchronized and independent axes in Tableau. When would you choose one
over the other, and what impact does it have on data interpretation?
Ans. Synchronized axes maintain the same scale, while independent axes allow each axis to have its own scale.
Synchronized axes are suitable when comparing similar measures, while independent axes are necessary when
the measures have different units or scales. The choice depends on the data context.
iNeuron Intelligence Pvt Ltd
21. When designing a bar chart in Tableau, what considerations should be taken into account for
colour selection, axis scaling, and sorting to ensure effective communication of insights?

Ans. When designing a bar chart in Tableau, consider using a consistent colour scheme for easy
interpretation. Scale the axis appropriately to avoid distortion, and sort bars by size or significance.
Carefully choose colours to emphasize key insights and maintain visual clarity.

22. What are different types of join in tableau?

Ans. Pretty similar to SQL. Hence their joins are similar too

Left Outer Join: Extract all records from left and matching records from the right table.

Right Outer Join: Extract all records from right and matching records from the left table.

Full outer Join : Extracts the record from both the left and right tables. All unmatched rows go with
the NULL values.

Inner join: Extracts the records from both tables.

23. What are groups in tableau?

Ans. Tableau Groups are a collection of multiple members in a single dimension that is combined to
form a higher category.

24. What is a Mark card in tableau?

Ans. The Marks Cards in Tableau provide some of the most powerful functionality in the program
because they allow you to modify a view’s design, visualization type, user experience, and granularity
of analysis all in one place.
iNeuron Intelligence Pvt Ltd
25. Describe the steps involved in creating a calculated field that calculates the profit margin based
on the given sales and cost data

Ans. The calculated field formula for profit margin would be: (SUM([Sales]) - SUM([Cost])) /
SUM([Sales]). This formula calculates profit margin as the ratio of profit to sales.

26. Describe the process of creating a dual-axis combination chart in Tableau. Provide an example of
a scenario where such a chart would be effective.

Ans. To create a dual-axis combination chart, drag one measure to the Rows shelf, then drag another
measure to the same shelf. Right-click on the second axis and choose "Dual-Axis." This is useful for
comparing two measures with different scales.

27. What is the role of reference lines in Tableau? How can they be added to visualizations, and what
insights can they provide?

Ans. Reference lines in Tableau are used to mark specific values on an axis. They can be added to
highlight target values or key points of interest. Reference lines can be based on constants, fields, or
distributions.

28. Explain the difference between blending and joining data in Tableau. In what situations would
you choose to blend data, and when would you prefer to join data?

Ans. Blending vs. Joining Data:

Blending is used when data comes from different data sources, and Tableau combines the data at the
visualization level. Joining is used when data comes from the same data source, and it combines the
data at the data source level.

29. Describe the steps involved in creating a dashboard in Tableau. What elements can be added to a
dashboard to enhance the overall presentation of data?

Ans. Creating a Dashboard:

To create a dashboard in Tableau, go to the "Dashboard" tab, drag sheets and objects onto the
dashboard, and arrange them as needed. You can also add containers and use dashboard actions to
enhance interactivity.
iNeuron Intelligence Pvt Ltd
30. How can you create a calculated field that calculates the running total of sales over time in
Tableau? Provide the necessary formula and steps.

Ans. Running Total Calculated Field:

The calculated field formula for a running total of sales over time would be
RUNNING_SUM(SUM([Sales])). This formula calculates the cumulative sum of sales.

31. What is the purpose of a live connection in Tableau?

a. It creates a static snapshot of the data. b. It directly links to the data source.
c. It pivots the data for analysis. d. It extracts data for offline use.

Ans. b) It directly links to the data source.

32. Which of the following is a cloud-based data source option in Tableau?

a. CSV File b. Google Sheets


c. Excel Workbook d. Text File

Ans. b) Google Sheets

33. What is the purpose of the Data Interpreter in Tableau?

a. To create visualizations b. To detect and correct data issues


c. To extract data for offline use d. To join tables from different sources

Ans. b) To detect and correct data issues

34. In Tableau, what does an extract provide that a live connection does not?

a. Offline access b. Real-time updates


c. Dynamic linking d. Data snapshot

Ans. a) Offline access

35. How can you handle null values in calculations in Tableau?

a. Remove them from the dataset b. Use the IFNULL() function


c. Ignore them in visualizations d. All of the above

Ans. b) Use the IFNULL() function


iNeuron Intelligence Pvt Ltd
36. What does the "Data Source" tab in Tableau allow you to do?

a. Create visualizations b. Modify, join, or blend data


c. Filter data in visualizations d. Export data to Excel

Ans. b) Modify, join, or blend data

37. In Tableau, what does the "Hide" feature allow you to do?

a. Exclude data from the dataset


b. Hide fields from the Data Source tab
c. Exclude data points from view without removing them
d. Hide the entire worksheet

Ans. c) Exclude data points from view without removing them

38. What is the purpose of the "Pivot" feature in Tableau?

a. To aggregate data b. To transform columns into rows


c. To filter data d. To create calculated fields
Ans. b) To transform columns into rows

39. How does Tableau handle data blending?

a. By combining data from multiple sources in a single query


b. By directly linking tables from different databases
c. By blending colors in visualizations
d. By extracting data for offline use

Ans. a) By combining data from multiple sources in a single query

40. Which function is used for renaming fields or values for better clarity in visualizations?

a. RENAME() b. ALIAS()
c. RENAME FIELD d. ALIAS FIELD

Ans. b) ALIAS()
iNeuron Intelligence Pvt Ltd
11. Can Tableau automatically recognize geographic fields for mapping?

a. No, it requires manual mapping b. Yes, using the Geographic Role feature
c. Only with live connections d. Only with extracts

Ans. b) Yes, using the Geographic Role feature

12. What is the primary advantage of using data extracts in Tableau?

a. Real-time data updates b. Offline access to data


c. Dynamic linking to the source d. Automatic data cleaning

Ans. b) Offline access to data

13. How can you refresh data in Tableau to reflect changes in the source?

a. Use the Refresh option b. Reload the workbook


c. Recreate the visualization d. All of the above

Ans. a) Use the Refresh option

14. What is the role of the "Data Interpreter" in Tableau's data connection process?

a. To interpret foreign keys b. To interpret complex SQL queries


c. To detect and correct common data issues d. To interpret geographical data

Ans. c) To detect and correct common data issues

15. Which chart type is most suitable for displaying the distribution of a single numerical variable?

a. Bar Chart b. Line Chart


c. Histogram d. Scatter Plot

Ans. c) Histogram

16. In Tableau, how can you create a bar chart?

a. Dragging the measure to Rows shelf b. Dragging the dimension to Columns shelf
c. Dragging the measure to Columns shelf d. Dragging the dimension to Rows shelf

Ans. a) Dragging the measure to Rows shelf


iNeuron Intelligence Pvt Ltd
17. What is the primary purpose of a scatter plot in Tableau?

a. Showing the distribution of a single variable b. Comparing two numerical variables


c. Displaying hierarchical data d. Representing time-series data

Ans. b) Comparing two numerical variables

18. Which chart type is effective for visualizing trends over time?

a. Bar Chart b. Scatter Plot


c. Line Chart d. Pie Chart

Ans. c) Line Chart

19. How can you add a reference line to a bar chart in Tableau?

a. Right-click on the axis and select "Add Reference Line"


b. Drag a reference line from the toolbar onto the chart
c. Use the "Analysis" menu to add a reference line
d. Reference lines cannot be added to bar charts

Ans. a) Right-click on the axis and select "Add Reference Line"

20. In Tableau, what does the "Color" shelf allow you to do?

a. Change the background color of the worksheet


b. Assign colors to data points based on a dimension or measure
c. Adjust the transparency of the entire chart
d. Add color to the axis labels

Ans. b) Assign colors to data points based on a dimension or measure

21. How can you customize the size of data points in a scatter plot in Tableau?

a. Dragging a dimension to the Size shelf


b. Adjusting the overall chart size in the Layout menu
c. Changing the data source size
d. Customizing the marks card size directly

Ans. a) Dragging a dimension to the Size shelf


iNeuron Intelligence Pvt Ltd

22. What is the purpose of the "Show Me" menu in Tableau?

a. To display hidden data in the worksheet b. To switch between different chart types
c. To show additional columns in the data source d. To create calculated fields

Ans. b) To switch between different chart types

23. How can you add data labels to individual data points in a chart?

a. Dragging the dimension to the "Label" shelf


b. Right-clicking on data points and selecting "Add Labels"
c. Adjusting the "Label" option in the "Analysis" menu
d. Data labels cannot be added to individual data points

Answer: a) Dragging the dimension to the "Label" shelf

24. What does the "Tooltip" shelf allow you to do in Tableau?

a. Add explanatory text to the chart b. Create custom tooltips for each data point
c. Adjust the size of the tooltip window d. Hide tooltips for specific data points

Ans. b) Create custom tooltips for each data point

25. How can you create a dual-axis chart in Tableau?

a. Dragging a second measure to the "Secondary" axis


b. Right-clicking on the chart and selecting "Dual-Axis"
c. Using the "Analysis" menu to add a secondary axis
d. Dual-axis charts are not supported in Tableau

Answer: b) Right-clicking on the chart and selecting "Dual-Axis"

26. What does the "Color Palette" option in Tableau allow you to customize?

a. Background color of the worksheet b. Colors assigned to dimensions or measures


c. Font color in the worksheet d. Transparency of the entire chart

Ans. b) Colors assigned to dimensions or measures


iNeuron Intelligence Pvt Ltd

27. How can you create a combo chart in Tableau?

a. Dragging multiple measures to the Columns shelf


b. Combining different chart types on the same axis
c. Using the "Combo Chart" option in the "Show Me" menu
d. Combo charts are not supported in Tableau

Ans. c) Using the "Combo Chart" option in the "Show Me" menu

28. What is the purpose of the "Size Legend" in Tableau?

a. To adjust the overall size of the chart b. To display a legend for the color scheme
c. To show the size range of data points in a scatter plot d. Size legend is not a feature in Tableau

Ans. c) To show the size range of data points in a scatter plot

29. How can you customize the axis titles in Tableau?

a. By dragging a dimension to the "Title" shelf


b. Right-clicking on the axis and selecting "Edit Title"
c. Adjusting the font size in the "Format" menu
d. All of the above

Ans. b) Right-clicking on the axis and selecting "Edit Title"

30. What is the purpose of the Tableau "Page Shelf"?

a. To add pages to a workbook b. To create animated visualizations


c. To navigate between different worksheets d. To format text in a dashboard

Ans. b) To create animated visualizations

31. How can you create a hierarchy in Tableau?

a. Drag and drop fields onto the Rows shelf


b. Right-click on a field and select "Create Hierarchy"
c. Use the "Show Me" menu
d. Apply filters to the data

Ans. b) Right-click on a field and select "Create Hierarchy"


iNeuron Intelligence Pvt Ltd

32. What is a "table calculation" in Tableau?

a. A calculation involving fields in a table b. A calculation applied to a subset of data


c. A calculation performed on a chart d. A calculation using Excel tables

Ans. c) A calculation performed on a chart

33. How can you combine data from multiple tables in Tableau?

a. Using calculated fields b. Using the "Data Blend" feature


c. Using hierarchies d. Using the "Show Me" menu

Ans. b) Using the "Data Blend" feature

34. What is the purpose of the Tableau "Marks" card?

a. To display row and column labels b. To apply filters to the data


c. To customize the appearance of marks in the view d. To create calculated fields

Ans. c) To customize the appearance of marks in the view

35. What is the role of the "Level of Detail" (LOD) expressions in Tableau?

a. To define the level of detail in a visualization b. To sort data in a chart


c. To create hierarchies d. To filter data based on conditions

Ans. a) To define the level of detail in a visualization

36. In Tableau, how can you filter data using a range?

a. Using the "Filter" shelf b. Using the "Page Shelf"


c. Using the "Show Me" menu d. Using the "Sort" feature

Ans. a) Using the "Filter" shelf


iNeuron Intelligence Pvt Ltd
37. What is the purpose of the Tableau "Quick Filter" feature?

a. To quickly apply filters based on a single click b. To create calculated fields


c. To change chart types d. To navigate between worksheets

Ans. a) To quickly apply filters based on a single click

38. How can you create a calculated field in Tableau?

a. Drag and drop a field onto the "Calculated Field" shelf


b. Right-click on a field and select "Create Calculated Field"
c. Use the "Show Me" menu
d. Apply a filter to the data

Ans. b) Right-click on a field and select "Create Calculated Field"

39. What does the "Data Interpreter" in Tableau do?

a. Translates data into multiple languages


b. Prepares data for analysis by cleaning and structuring it
c. Creates animated visualizations
d. Interprets statistical models

Ans. b) Prepares data for analysis by cleaning and structuring it

40. How can you share a Tableau workbook with someone who doesn't have Tableau installed?

a. Export as a PDF b. Export as an image


c. Use Tableau Public d. All of the above

Answer: d) All of the above

41. How can you create a dual-axis chart in Tableau?

a. Dragging a field to the "Dual-Axis" shelf b. Using the "Show Me" menu
c. Right-clicking on a chart and selecting "Dual-Axis" d. All of the above

Ans. d) All of the above


iNeuron Intelligence Pvt Ltd
42. What is the purpose of the Tableau "Story" feature?
a. To create animated visualizations
b. To combine sheets and dashboards into a narrative
c. To filter data in a chart
d. To customize chart appearance
Ans. b) To combine sheets and dashboards into a narrative

43. In Tableau, what is a dimension?


a. A measure of the data b. A numerical value
c. A categorical field d. An aggregate function
Ans. c) A categorical field

44. In Tableau, what is the purpose of the "Pages" shelf?


a. To navigate between different worksheets b. To create animated visualizations
c. To organize dashboards d. To filter data based on date
Ans. b) To create animated visualizations

45. What is the role of the Tableau "Filter" shelf?


a. To apply filters to the entire workbook
b. To quickly apply filters based on a single click
c. To create calculated fields
d. To filter data based on user input
Ans. a) To apply filters to the entire workbook

46. How can you combine data from different tables in Tableau?
a. Using the "Data Blend" feature b. Using calculated fields
c. Using hierarchies d. Using the "Show Me" menu
Ans. a) Using the "Data Blend" feature

47. How can you create a tree map in Tableau?


a. By using the "Show Me" menu b. By dragging and dropping fields onto the view
c. By applying filters to the data d. By using the "Data Blend" feature
Ans. a) By using the "Show Me" menu

48. What is the purpose of the Tableau "Table Calculation" feature?


a. To create tables in Tableau b. To perform calculations on tables
c. To create calculated fields using tables d. To perform calculations on
visualizations
Ans. d) To perform calculations on visualizations

49. What is the significance of the "Path" shelf in Tableau?


a. To create path visualizations b. To navigate between different worksheets
c. To organize dashboards d. To filter data based on date
Ans. a) To create path visualizations
iNeuron Intelligence Pvt Ltd
50. What is the purpose of the "IF" statement in Tableau calculations?
a. To filter data b. To create conditional logic
c. To sort data d. To aggregate values
Ans. b) To create conditional logic

51. How can you reference a specific field in a calculated field formula?
a. Using the field name directly b. By using the "Fields" pane
c. By typing the field alias d. By using the "Calculated Fields" pane
Ans. b) By using the "Fields" pane

52. What is the purpose of the "CASE" statement in Tableau calculations?


a. To create hierarchies b. To handle NULL values
c. To sort data d. To create calculated fields
Ans. b) To handle NULL values

53. How do you convert a date field to a string in Tableau calculations?


a. Using the "Convert" function b. By dragging the date field to the Columns shelf
c. By using the "Date Format" menu d. Using the "STR" function
Ans. d) Using the "STR" function

54: What does the "WINDOW_AVG" function do in Tableau calculations?


a. Calculates the average across the entire table
b. Calculates the average for a specific window of data
c. Sorts the data window
d. Creates a moving average
Ans. b) Calculates the average for a specific window of data

55. How can you perform a percentage-of-total calculation in Tableau?


a. Using the "Percent of Total" quick table calculation
b. By dividing values by the total using a calculated field
c. By applying a filter to the data
d. By using the "Sort" feature
Ans. b) By dividing values by the total using a calculated field

56. What is the purpose of the "WINDOW_SUM" function in Tableau?


a. Calculates the sum across the entire table
b. Calculates the sum for a specific window of data
c. Sorts the data window
d. Creates a running sum
Ans. b) Calculates the sum for a specific window of data

57. How can you round a numeric field to a specified number of decimal places in Tableau?
a. Using the "ROUND" function b. By applying a filter to the data
c. By using the "Show Me" menu d. By dragging the field to the Rows shelf
Ans. a) Using the "ROUND" function
iNeuron Intelligence Pvt Ltd

58. What does the "LOOKUP" function do in Tableau calculations?


a. Retrieves the value from a specific row in the table
b. Calculates the difference between values
c. Sorts the data window
d. Creates a moving average
Ans. a) Retrieves the value from a specific row in the table

59. How can you create a running total in Tableau?


a. By using the "RUNNING_TOTAL" function b. By dragging the field to the Rows shelf
c. By applying a filter to the data d. By using the "Show Me" menu
Ans. a) By using the "RUNNING_TOTAL" function

60. What is the purpose of the "ZN" function in Tableau calculations?


a. Converts NULL values to zero b. Calculates the z-score of a field
c. Sorts the data window d. Creates a moving average
Ans. a) Converts NULL values to zero

61. How can you concatenate two string fields in Tableau?


a. Using the "CONCAT" function
b. By dragging the fields to the Columns shelf
c. By using the "Show Me" menu
d. By applying a filter to the data
Ans. a) Using the "CONCAT" function

62. What does the "INDEX" function do in Tableau calculations?


a. Returns the index of a field b. Sorts the data window
c. Creates a moving average d. Calculates the difference between values
Ans. a) Returns the index of a field

63. How can you create a custom sort order in Tableau?


a. By using the "Sort" feature
b. By creating a hierarchy
c. By applying a filter to the data
d. By dragging and dropping fields onto the view
Ans. a) By using the "Sort" feature

64. What is the purpose of the "SCRIPT_REAL" function in Tableau calculations?


a. Executes a script in a programming language
b. Creates a calculated field using R or Python scripts
c. Sorts the data window
d. Calculates the difference between values
Ans. b) Creates a calculated field using R or Python scripts

You might also like