Day1-Day75 Data Analytics Interview
Day1-Day75 Data Analytics Interview
Page | 2
iNeuron Intelligence Pvt Ltd
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
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.
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}
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.
Ans: C
Explanation: print(list1[1:8:2]) of the following will give output as
[23,2,9,75].
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?
print(min(list1))
A. c
B. C++
C. C
Ans: C
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. i only
B. i and ii only
C. iii and iv only
D. iv only
Ans- A
Page | 9
iNeuron Intelligence Pvt Ltd
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.
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.
Page 3 of 9
iNeuron Intelligence Pvt Ltd
Page 4 of 9
iNeuron Intelligence Pvt Ltd
Page 5 of 9
iNeuron Intelligence Pvt Ltd
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’>
Page 7 of 9
iNeuron Intelligence Pvt Ltd
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.
Page 9 of 9
iNeuron Intelligence Pvt Ltd
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.
Answer: b
Explana@on: eval can be used as a variable.
Page 3 of 8
iNeuron Intelligence Pvt Ltd
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.
Answer: d
Explana@on: Iden@fiers can be of any length.
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
Answer: d
Explana@on: Tuples are represented with round brackets.
Answer: b
Explana@on: Each object in Python has a unique id. The id() func@on
returns the object’s id.
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
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.
Answer: c
Explana@on: l (or L) stands for long.
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
Page 7 of 8
iNeuron Intelligence Pvt Ltd
Page 8 of 8
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
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.
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
Page 5 of 9
iNeuron Intelligence Pvt Ltd
Page 6 of 9
iNeuron Intelligence Pvt Ltd
a) list
b) dic\onary
c) array
d) tuple
Answer: a
Explana\on: List data type can store any values within it.
a) List_name[2:3]
b) List_name[-1]
c) List_name[0]
Page 7 of 9
iNeuron Intelligence Pvt Ltd
b) index
c) pop
d) Delete
Answer – c) pop
a) append
b) copy
c) reverse
d) sort
Answer- a) append
Page 8 of 9
iNeuron Intelligence Pvt Ltd
Page 9 of 9
iNeuron Intelligence Pvt Ltd
Page 2 of 8
iNeuron Intelligence Pvt Ltd
Answer: a
Explana>on: A frozen set is an immutable data type.
Page 3 of 8
iNeuron Intelligence Pvt Ltd
c) Can’t say
d) None of the men>oned
Answer: a
Explana>on: None.
Page 4 of 8
iNeuron Intelligence Pvt Ltd
Answer: a
Explana>on: None.
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
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.
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.
Page 6 of 8
iNeuron Intelligence Pvt Ltd
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
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 [].
Page 3 of 9
iNeuron Intelligence Pvt Ltd
Page 4 of 9
iNeuron Intelligence Pvt Ltd
Page 5 of 9
iNeuron Intelligence Pvt Ltd
Page 6 of 9
iNeuron Intelligence Pvt Ltd
Page 7 of 9
iNeuron Intelligence Pvt Ltd
Page 8 of 9
iNeuron Intelligence Pvt Ltd
Page 9 of 9
iNeuron Intelligence Pvt Ltd
Page 2 of 8
iNeuron Intelligence Pvt Ltd
The index of -1 refers to the last item, -2 to the second last item and
so on. For example,
Page 3 of 8
iNeuron Intelligence Pvt Ltd
c) 12_hello
d) None of these
Answer – c) 12_hello
Answer – b) True
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'
a) 0
b) 2
c) 1
d) 3
Answer – c) 1
Page 5 of 8
iNeuron Intelligence Pvt Ltd
Answer. d. Only True, False and None are capitalized and all the
others in lower case.
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.
Page 7 of 8
iNeuron Intelligence Pvt Ltd
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
Page 2 of 10
iNeuron Intelligence Pvt Ltd
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.
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.
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
num1=10
num2="20"
result=num1+int(num2)
print(result)
Ans- There are many collecRon data types which are supported by
Python-
Page 4 of 10
iNeuron Intelligence Pvt Ltd
Page 5 of 10
iNeuron Intelligence Pvt Ltd
c) complex Simplified
d) ASCII is used. Unicode is used.
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.
Page 7 of 10
iNeuron Intelligence Pvt Ltd
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.
Answer -Python has many inbuilt packages and modules. One of the
most useful modules is random. This module helps in generaRng
random numbers.
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
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.
Page 10 of 10
iNeuron Intelligence Pvt Ltd
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.
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
A. datatype ()
B. typeof()
C. type()
D. vartype()
View Answer
Ans: C
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.
A. []
B. {}
C. ()
D. set()
Ans: D
ExplanaJon: set() is used to create an empty set. So, OpJon D is
correct.
A. set
B. int
C. str
D. tuple
View Answer
Ans: A
Page 3 of 10
iNeuron Intelligence Pvt Ltd
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.
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.
Page 5 of 10
iNeuron Intelligence Pvt Ltd
Ans- B
ExplanaJon: Tuples are immutable while lists are mutable the correct
opJon with respect to Python.
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.
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).
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).
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.
Ans- C
ExplanaJon: 22
Page 8 of 10
iNeuron Intelligence Pvt Ltd
A. i only
B. i and ii only
C. iii and iv only
D. iv only
Ans- A
Page 10 of 10
iNeuron Intelligence Pvt Ltd
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.
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.
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
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.
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.
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
Ans: A
Explanation: If condition is true so pq will be the output. So, option A
is correct.
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.
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?
Ans: B
ExplanaDon: Else statement aaer loop will be executed only when
the loop condiDon becomes false. So, opDon B is correct.
A. TRUE
B. FALSE
C. Null
D. Both A and C
Page 6 of 11
iNeuron Intelligence Pvt Ltd
View Answer
Ans: B
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.
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.
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.
Ans: B
Page 8 of 11
iNeuron Intelligence Pvt Ltd
ExplanaDon: For statement always ended with colon (:). So, opDon B
is correct.
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?
Ans: B
Page 9 of 11
iNeuron Intelligence Pvt Ltd
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.
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
list1 = [3 , 2 , 5 , 6 , 0 , 7, 9]
sum = 0
Page 10 of 11
iNeuron Intelligence Pvt Ltd
sum1 = 0
if (elem % 2 == 0):
conDnue
if (elem % 3 == 0):
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
Page 2 of 11
iNeuron Intelligence Pvt Ltd
A. new
B. except
C. class
D. object
Ans: C
Page 3 of 11
iNeuron Intelligence Pvt Ltd
A. __init__
B. __init__()
C. init
D. init()
Ans: B
A. __init__()
B. self
C. both A and B
D. None of the above
Ans: B
A. delete
B. dedl
Page 4 of 11
iNeuron Intelligence Pvt Ltd
C. del
D. drop
Ans: C
A. Inheritance
B. Instance variable
C. FuncRon overloading
D. InstanRaRon
Ans: B
A. Class variable
B. Method
C. Operator overloading
D. Data member
Page 5 of 11
iNeuron Intelligence Pvt Ltd
Ans: D
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
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
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
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
A. acribute
B. object
C. argument
D. funcRon
Ans: D
Ans: B
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
Page 9 of 11
iNeuron Intelligence Pvt Ltd
Page 10 of 11
iNeuron Intelligence Pvt Ltd
Page 11 of 11
iNeuron Intelligence Pvt Ltd
print(a+b+c)
print(a+b*c+d)
print(a/b+c/d)
print(a+b*c+a/b+d)
Ans-
Page 2 of 9
iNeuron Intelligence Pvt Ltd
Equal
x=y
True if x is equal to y.
>
Greater than
x>y
<
Less than
x<y
>=
x >= y
<=
x <= y
!=
Not equal to
x != 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-
Page 4 of 9
iNeuron Intelligence Pvt Ltd
Answer. b. There are a lot of languages which have been implemented using
both compilers and interpreters, including C, Pascal, as well as python.
Answer. b. 16 October 2000. The idea of Python was conceived in the later
1980s, but it was released on a. 16 October 2000.
Answer. a. The new version of Python 3.0 was released on December 3, 2008.
Page 5 of 9
iNeuron Intelligence Pvt Ltd
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.
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.
Answer. d. Only True, False and None are capitalized and all the others in lower
case.
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
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
Answer. C. Python first searches for the local namespace, followed by the
global and finally the built-in namespace.
Page 9 of 9
iNeuron Intelligence Pvt Ltd
A. int
B. float
C. complex
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
A. Sequence Types
B. Binary Types
C. Boolean Types
D. None of the mentioned above
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.
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.
A. True
B. False
Answer: A) True
Explanation:
A. TRUE
B. FALSE
Answer: A) TRUE
Explanation:
A. Yes
B. No
Page 4 of 13
iNeuron Intelligence Pvt Ltd
Answer: A) Yes
Explanation:
A. Quotient
B. Divisor
C. Remainder
D. None of the mentioned above
Answer: C) Remainder
Explanation:
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
Explanation:
d={
<key>: <value>,
<key>: <value>,
Page 6 of 13
iNeuron Intelligence Pvt Ltd
<key>: <value>
Group
List
Dictionary
Answer: C) Dictionary
A. True
B. False
Answer: A) True
Explanation:
Page 7 of 13
iNeuron Intelligence Pvt Ltd
A. True
B. False
Answer: A) True
Explanation:
if condition:
if condition
if(condition)
Page 8 of 13
iNeuron Intelligence Pvt Ltd
Answer: A)
if condition:
A. if a<=100:
B. if (a >= 10)
C. if (a => 200)
D. None of the mentioned above
Answer: A) if a<=100:
Explanation:
Page 9 of 13
iNeuron Intelligence Pvt Ltd
A. if a<=100:
B. if (a >= 10)
C. if (a => 200)
D. None of the mentioned above
Answer: A) if a<=100:
Explanation:
Explanation:
Page 10 of 13
iNeuron Intelligence Pvt Ltd
Explanation:
a=7
if a>4: print("Greater")
Greater
Page 11 of 13
iNeuron Intelligence Pvt Ltd
Answer: A) Greater
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
x=13
else:
Both A and B
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?
if a <= 0:
b = b +1
else:
a=a+1
Both A and B
Explanation:
Page 3 of 17
iNeuron Intelligence Pvt Ltd
A. True
B. False
Answer: A) True
Explanation:
A. Alphabets
B. Numbers
C. Special symbols
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
A. load()
B. set() method
C. dump() method
D. None of the mentioned above
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.
A. set() method
B. dump() method
C. load() method
D. None of the mentioned above
Page 5 of 17
iNeuron Intelligence Pvt Ltd
Explanation:
7. The readline() is used to read the data line by line from the text
file.
A. True
B. False
Answer: A) True
Explanation:
Explanation:
Page 7 of 17
iNeuron Intelligence Pvt Ltd
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
A. if else if
B. if elif
C. if-else
D. None of the mentioned above
Answer: C) if-else
Explanation:
A. Jump
B. goto
C. compound
D. None of the mentioned above
Answer: B) goto
Page 10 of 17
iNeuron Intelligence Pvt Ltd
Explanation:
Page 11 of 17
iNeuron Intelligence Pvt Ltd
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
A. True
B. False
Answer: A) True
Explanation:
Page 12 of 17
iNeuron Intelligence Pvt Ltd
i=5
No output
Both A and B
Explanation:
Page 13 of 17
iNeuron Intelligence Pvt Ltd
a = 13
b = 15
A is greater
B is greater
Both A and B
Answer: B) B is greater
A. True
B. False
Answer: A) True
Explanation:
Page 14 of 17
iNeuron Intelligence Pvt Ltd
Explanation:
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:
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:
Page 17 of 17
iNeuron Intelligence Pvt Ltd
A. Initiate
B. Start
C. End
D. None of the mentioned above
Answer: C) End
Explanation:
2. Amongst which of the following is / are true about the while loop?
Explanation:
A. range()
B. set()
C. dictionary{}
D. None of the mentioned above
Answer: A) range()
Explanation:
for i in range(6):
print(i)
1
Page 3 of 14
iNeuron Intelligence Pvt Ltd
Answer: A)
Page 4 of 14
iNeuron Intelligence Pvt Ltd
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.
A. True
B. False
Answer: A) True
Explanation:
Page 5 of 14
iNeuron Intelligence Pvt Ltd
Explanation:
A. Write code
B. Specific task
Page 6 of 14
iNeuron Intelligence Pvt Ltd
Explanation:
def function_name(parameters):
...
Statements
...
...
Statements
Page 7 of 14
iNeuron Intelligence Pvt Ltd
...
...
Statements
...
Answer: A)
def function_name(parameters):
...
Statements
...
Explanation:
The range(6) is define as function. Loop will print the number from 0.
Page 8 of 14
iNeuron Intelligence Pvt Ltd
A. True
B. False
Answer: A) True
Explanation:
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
Explanation:
Call by value and Call by reference are the types of function calls in
Python.
def show(id,name):
Page 9 of 14
iNeuron Intelligence Pvt Ltd
show(12,"deepak")
13. Amongst which of the following is a function which does not have
any name?
Del function
Show function
Lambda function
A. Yes
Page 10 of 14
iNeuron Intelligence Pvt Ltd
B. No
Answer: A) Yes
Explanation:
A. True
B. False
Answer: A) True
Explanation:
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:
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?
Explanation:
Page 13 of 14
iNeuron Intelligence Pvt Ltd
Page 14 of 14
iNeuron Intelligence Pvt Ltd
Ans-
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.
Ans-
Page 3 of 11
iNeuron Intelligence Pvt Ltd
Ans-
Ans-
Page 4 of 11
iNeuron Intelligence Pvt Ltd
Ans-
Page 5 of 11
iNeuron Intelligence Pvt Ltd
Ans-
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
Page 7 of 11
iNeuron Intelligence Pvt Ltd
Page 8 of 11
iNeuron Intelligence Pvt Ltd
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-
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
Page 2 of 9
iNeuron Intelligence Pvt Ltd
b) Exponent
c) Mul.plica.on
d) Division
e) Addi.on
f) Subtrac.on
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
Page 3 of 9
iNeuron Intelligence Pvt Ltd
Page 4 of 9
iNeuron Intelligence Pvt Ltd
Ans-
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
Page 6 of 9
iNeuron Intelligence Pvt Ltd
Ans-
Page 7 of 9
iNeuron Intelligence Pvt Ltd
12
123
1234
Ans-
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.
Page 9 of 9
iNeuron Intelligence Pvt Ltd
Page 2 of 9
iNeuron Intelligence Pvt Ltd
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.
The amributes of a class are also called variables. There are three
access modifiers in Python for variables, namely
tup2 = (4,5,6)
Page 5 of 9
iNeuron Intelligence Pvt Ltd
Q12. How can you randomize the items of a list in place in Python?
Ans-
Page 6 of 9
iNeuron Intelligence Pvt Ltd
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.
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
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.
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
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’)
Page 9 of 9
iNeuron Intelligence Pvt Ltd
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:
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
Q5. What are nega8ve indexes and why are they used?
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 3 of 9
iNeuron Intelligence Pvt Ltd
Ans:
Page 4 of 9
iNeuron Intelligence Pvt Ltd
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.
Ans:
Page 6 of 9
iNeuron Intelligence Pvt Ltd
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’.
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:
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.
Q20. What are nega8ve indexes and why are they used?
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
Ans:
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.
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.
Ans:
Page 4 of 10
iNeuron Intelligence Pvt Ltd
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’.
Page 5 of 10
iNeuron Intelligence Pvt Ltd
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.
Page 6 of 10
iNeuron Intelligence Pvt Ltd
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.
To remove duplicate elements from the list we use the set() func;on.
unique_list = list(set(demo_list))
import os
os.remove("file_name.txt")
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
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
file_count("file.txt"))
Page 10 of 10
iNeuron Intelligence Pvt Ltd
• 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.
Q2. Whenever Python exits, why isn’t all the memory de-allocated?
Page 2 of 13
iNeuron Intelligence Pvt Ltd
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?
Page 3 of 13
iNeuron Intelligence Pvt Ltd
Nested Lists:
Numpy:
For example:
Page 5 of 13
iNeuron Intelligence Pvt Ltd
print(a(5, 6))
Page 7 of 13
iNeuron Intelligence Pvt Ltd
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
# monkeyy.py
class X:
def func(self):
Syntax:
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.
Page 10 of 13
iNeuron Intelligence Pvt Ltd
Page 11 of 13
iNeuron Intelligence Pvt Ltd
Ans-
Ans-
Page 12 of 13
iNeuron Intelligence Pvt Ltd
my_list.sort()
print (my_list)
Page 13 of 13
iNeuron Intelligence Pvt Ltd
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.
Page 3 of 5
iNeuron Intelligence Pvt Ltd
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.
Page 5 of 5
iNeuron Intelligence Pvt Ltd
Page 2 of 9
iNeuron Intelligence Pvt Ltd
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.
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:
Page 3 of 9
iNeuron Intelligence Pvt Ltd
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.
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.
Page 4 of 9
iNeuron Intelligence Pvt Ltd
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]]
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.
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.
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
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.
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]
Page 9 of 9
iNeuron Intelligence Pvt Ltd
Lists
Sets
Dic@onaries
Immutable built-in types:
Strings
Tuples
Numbers
os
sys
math
random
data @me
JSON
Page 2 of 8
iNeuron Intelligence Pvt Ltd
Page 3 of 8
iNeuron Intelligence Pvt Ltd
import array
import array as arr
from array import *
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.
Page 5 of 8
iNeuron Intelligence Pvt Ltd
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.
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.
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.
Page 8 of 8
iNeuron Intelligence Pvt Ltd
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.
Import numpy as nm
arr=nm.array([1, 6, 2, 4, 7])
Output:
[ 4 6 1]
Page 2 of 7
iNeuron Intelligence Pvt Ltd
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.
The args and kwargs iden4fiers are a conven4on, you can also use *
bob and ** billy but that would not be wise
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
import numpy as np
a = np.array ([1,2,3,4,5])
print (p)
Page 4 of 7
iNeuron Intelligence Pvt Ltd
2-dimensional
Labelled axes (rows and columns)
Size-mutable
Arithme4c opera4ons can be performed on rows and columns.
Page 5 of 7
iNeuron Intelligence Pvt Ltd
Page 6 of 7
iNeuron Intelligence Pvt Ltd
Page 7 of 7
iNeuron Intelligence Pvt Ltd
Ans-
Q2. What do you mean by DBMS? What are its different types?
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.
Page 2 of 11
iNeuron Intelligence Pvt Ltd
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?
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 MINUS operator is used to return rows from the first query but
not from the second query.
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.
Page 5 of 11
iNeuron Intelligence Pvt Ltd
Q11. How to create empty tables with the same structure as another
table?
Page 6 of 11
iNeuron Intelligence Pvt Ltd
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
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.
Page 8 of 11
iNeuron Intelligence Pvt Ltd
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 11
iNeuron Intelligence Pvt Ltd
The MINUS operator is used to return rows from the first query but
not from the second query.
Within the clause, each SELECT query must have the same number of
columns.
Page 10 of 11
iNeuron Intelligence Pvt Ltd
Page 11 of 11
iNeuron Intelligence Pvt Ltd
• SELECT
• INSERT
• UPDATE
• DELETE
• CREATE DATABASE
• ALTER DATABASE
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
Page 3 of 12
iNeuron Intelligence Pvt Ltd
Step 1: Click on SSMS, which will take you to the SQL Server
Management Studio page.
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
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
ELSE result
END;
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.
Page 6 of 12
iNeuron Intelligence Pvt Ltd
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.
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.
AS
sql_statement
Page 7 of 12
iNeuron Intelligence Pvt Ltd
GO;
EXEC procedure_name;
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
WHERE r=&n;
Table: StudentInformaPon
Page 10 of 12
iNeuron Intelligence Pvt Ltd
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.
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
Page 12 of 12
iNeuron Intelligence Pvt Ltd
Ans- In SQL, there is a built-in funcDon called Get Date() which helps
to return the current Dmestamp/date.
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
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.
Page 5 of 10
iNeuron Intelligence Pvt Ltd
Q10. How to create empty tables with the same structure as another
table?
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.
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
Ans- Any number that runs back on itself or remains the same when
reversed is a palindrome number. For example, 16461, 11 and 12321.
Page 8 of 10
iNeuron Intelligence Pvt Ltd
Page 9 of 10
iNeuron Intelligence Pvt Ltd
Page 10 of 10
iNeuron Intelligence Pvt Ltd
Page 2 of 14
iNeuron Intelligence Pvt Ltd
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
len(["hello",2, 4, 6])?
a) Error
b) 6
Page 4 of 14
iNeuron Intelligence Pvt Ltd
c) 4
d) 3
Answer: c
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
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
Page 6 of 14
iNeuron Intelligence Pvt Ltd
z=set('abc')
z.add('san')
z.update(set(['p', 'q']))
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’}
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
list1 = [1,2,3,4]
list2 = [2,4,5,6]
list3 = [2,6,7,8]
result = list()
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
>>>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
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
Page 10 of 14
iNeuron Intelligence Pvt Ltd
Answer: c
Explana3on: The else part is not executed if control breaks out of the
loop.
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
Page 11 of 14
iNeuron Intelligence Pvt Ltd
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
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
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
Page 14 of 14
iNeuron Intelligence Pvt Ltd
x = [[0], [1]]
a) 01
b) [0] [1]
c) (’01’)
d) (‘[0] [1]’,)
Answer: d
a) True
b) False
View Answer
Answer: a
Page 2 of 12
iNeuron Intelligence Pvt Ltd
4+3%5
a) 4
b) 7
c) 2
d) 0
Answer: b
for i in string:
a) m, y, , n, a, m, e, , i, s, , x,
b) m, y, , n, a, m, e, , i, s, , x
d) error
Answer: a
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
Ans-
Q7. What do you mean by DBMS? What are its different types?
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.
Page 5 of 12
iNeuron Intelligence Pvt Ltd
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?
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
The MINUS operator is used to return rows from the first query but
not from the second query.
Page 7 of 12
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.
Q16. How to create empty tables with the same structure as another
table?
Page 9 of 12
iNeuron Intelligence Pvt Ltd
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
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.
Page 11 of 12
iNeuron Intelligence Pvt Ltd
Page 12 of 12
iNeuron Intelligence Pvt Ltd
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 2 of 14
iNeuron Intelligence Pvt Ltd
The MINUS operator is used to return rows from the first query but
not from the second query.
Within the clause, each SELECT query must have the same number of
columns.
Page 3 of 14
iNeuron Intelligence Pvt Ltd
• SELECT
• INSERT
• UPDATE
• DELETE
• CREATE DATABASE
• ALTER DATABASE
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
Page 6 of 14
iNeuron Intelligence Pvt Ltd
Step 1: Click on SSMS, which will take you to the SQL Server
Management Studio page.
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.
Page 7 of 14
iNeuron Intelligence Pvt Ltd
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
ELSE result
END;
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.
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
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.
AS
sql_statement
GO;
EXEC procedure_name;
Page 10 of 14
iNeuron Intelligence Pvt Ltd
Page 11 of 14
iNeuron Intelligence Pvt Ltd
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(
Page 12 of 14
iNeuron Intelligence Pvt Ltd
WHERE r=&n;
Table: StudentInforma?on
Page 13 of 14
iNeuron Intelligence Pvt Ltd
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
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
Page 2 of 10
iNeuron Intelligence Pvt Ltd
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.
Ans- In SQL, there is a built-in func;on called Get Date() which helps
to return the current ;mestamp/date.
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.
Page 4 of 10
iNeuron Intelligence Pvt Ltd
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.
Page 5 of 10
iNeuron Intelligence Pvt Ltd
Page 6 of 10
iNeuron Intelligence Pvt Ltd
Page 7 of 10
iNeuron Intelligence Pvt Ltd
Q15. How to create empty tables with the same structure as another
table?
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
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
Ans- Any number that runs back on itself or remains the same when
reversed is a palindrome number. For example, 16461, 11 and 12321.
Page 10 of 10
iNeuron Intelligence Pvt Ltd
Page 2 of 8
iNeuron Intelligence Pvt Ltd
Page 3 of 8
iNeuron Intelligence Pvt Ltd
Page 4 of 8
iNeuron Intelligence Pvt Ltd
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
Answer
a) The absolute value of a specified number
Page 6 of 8
iNeuron Intelligence Pvt Ltd
Answer
a)True
a) Hello^3
b) Hello Hello Hello
c) Error
d) None of the above
Answer
Hello Hello Hello
Answer
a) During function creation
Page 7 of 8
iNeuron Intelligence Pvt Ltd
Table: Student
Page 8 of 8
iNeuron Intelligence Pvt Ltd
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
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.
Page 3 of 8
iNeuron Intelligence Pvt Ltd
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.
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.
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.
Page 5 of 8
iNeuron Intelligence Pvt Ltd
Page 6 of 8
iNeuron Intelligence Pvt Ltd
SELECT INTO: is used to select data from one table and insert into
another table.
Page 7 of 8
iNeuron Intelligence Pvt Ltd
Page 8 of 8
iNeuron Intelligence Pvt Ltd
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 of 7
iNeuron Intelligence Pvt Ltd
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.
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
Page 4 of 7
iNeuron Intelligence Pvt Ltd
Page 5 of 7
iNeuron Intelligence Pvt Ltd
Page 6 of 7
iNeuron Intelligence Pvt Ltd
COMMIT;
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.
FROM table_name;
Page 2 of 8
iNeuron Intelligence Pvt Ltd
Page 3 of 8
iNeuron Intelligence Pvt Ltd
Page 4 of 8
iNeuron Intelligence Pvt Ltd
Syntax:
Syntax:
Page 5 of 8
iNeuron Intelligence Pvt Ltd
LOWER(‘string’)
INITCAP: This function returns the string with the first letter in
uppercase and others in lowercase.
Syntax:
INITCAP(‘string’)
Page 6 of 8
iNeuron Intelligence Pvt Ltd
Character-Manipulative Functions
Syntax:
CONCAT(‘String1’, ‘String2’)
2. LENGTH : This function returns the total length of the input string
used.
Syntax:
LENGTH(Column|Expression)
Syntax:
SUBSTR(‘String’,start-index,length_of_extracted_string)
Syntax:
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:
Syntax:
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.
4. What is CTE?
Common Table Expression (CTE) is an expression that contains
temporary results defined in a SQL statement.
Page 2 of 10
iNeuron Intelligence Pvt Ltd
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.
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.
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.
Page 4 of 10
iNeuron Intelligence Pvt Ltd
• If-Then-Else
Page 5 of 10
iNeuron Intelligence Pvt Ltd
• While Loop
• For Loop
• GOTO
•Exception handling
Structure of PL/SQL
Page 6 of 10
iNeuron Intelligence Pvt Ltd
Page 7 of 10
iNeuron Intelligence Pvt Ltd
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.
Page 8 of 10
iNeuron Intelligence Pvt Ltd
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.
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
Page 10 of 10
iNeuron Intelligence Pvt Ltd
Page 2 of 12
iNeuron Intelligence Pvt Ltd
Page 3 of 12
iNeuron Intelligence Pvt Ltd
Page 4 of 12
iNeuron Intelligence Pvt Ltd
For example:
CREATE TABLE myTableName(id INTEGER PRIMARY KEY NOT NULL,
name VARCHAR2(50) DEFAULT 'John Doe');
Page 5 of 12
iNeuron Intelligence Pvt Ltd
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
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.
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).
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.
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.
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.
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:
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.
Page 11 of 12
iNeuron Intelligence Pvt Ltd
Page 12 of 12
iNeuron Intelligence Pvt Ltd
1. In PL/SQL, how do you add a new table row using DML operations?
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
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).
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;
Page 5 of 14
iNeuron Intelligence Pvt Ltd
Reference Output:
Page 6 of 14
iNeuron Intelligence Pvt Ltd
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'';
Output:
Page 7 of 14
iNeuron Intelligence Pvt Ltd
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.
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
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;
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
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
Page 10 of 14
iNeuron Intelligence Pvt Ltd
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.
Page 11 of 14
iNeuron Intelligence Pvt Ltd
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.
Page 12 of 14
iNeuron Intelligence Pvt Ltd
Page 13 of 14
iNeuron Intelligence Pvt Ltd
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.
Page 14 of 14
iNeuron Intelligence Pvt Ltd
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.
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.
Page 4 of 12
iNeuron Intelligence Pvt Ltd
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!
Page 5 of 12
iNeuron Intelligence Pvt Ltd
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
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
Page 9 of 12
iNeuron Intelligence Pvt Ltd
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:
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:
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:
Page 11 of 12
iNeuron Intelligence Pvt Ltd
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;
Page 12 of 12
iNeuron Intelligence Pvt Ltd
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
Page 3 of 10
iNeuron Intelligence Pvt Ltd
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:
Page 4 of 10
iNeuron Intelligence Pvt Ltd
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.
Page 5 of 10
iNeuron Intelligence Pvt Ltd
The users of electronic devices like touch screens and mobile phones
use these types of interfaces.
Page 6 of 10
iNeuron Intelligence Pvt Ltd
RDBMS
Page 7 of 10
iNeuron Intelligence Pvt Ltd
Page 8 of 10
iNeuron Intelligence Pvt Ltd
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.
Page 9 of 10
iNeuron Intelligence Pvt Ltd
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.
Page 2 of 11
iNeuron Intelligence Pvt Ltd
Page 3 of 11
iNeuron Intelligence Pvt Ltd
Page 4 of 11
iNeuron Intelligence Pvt Ltd
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
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.
● A table may have just one clustered index but may have several
non-clustered indexes.
Page 7 of 11
iNeuron Intelligence Pvt Ltd
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.
Page 8 of 11
iNeuron Intelligence Pvt Ltd
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.
Page 9 of 11
iNeuron Intelligence Pvt Ltd
Page 10 of 11
iNeuron Intelligence Pvt Ltd
20. What exactly is normalizaCon, and what are the benefits of doing
so?
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}
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.
Ans.
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.
12. Write a query that involves basic arithmetic operations on numeric columns.
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?
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
Page 2 of 12
iNeuron Intelligence Pvt Ltd
● 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.
Page 4 of 12
iNeuron Intelligence Pvt Ltd
● 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.
Page 5 of 12
iNeuron Intelligence Pvt Ltd
Page 6 of 12
iNeuron Intelligence Pvt Ltd
Page 7 of 12
iNeuron Intelligence Pvt Ltd
Unique Key:
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)
● 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
14. What are some of the benefits and drawbacks of using a stored
procedure?
Benefits:
Drawbacks:
Page 9 of 12
iNeuron Intelligence Pvt Ltd
16. What are the differences between local and global variables?
Page 10 of 12
iNeuron Intelligence Pvt Ltd
17. What is the difference between the operators’ BETWEEN and IN?
Page 11 of 12
iNeuron Intelligence Pvt Ltd
Page 12 of 12
iNeuron Intelligence Pvt Ltd
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.
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.
Page 2 of 10
iNeuron Intelligence Pvt Ltd
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.
Page 3 of 10
iNeuron Intelligence Pvt Ltd
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).
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.
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:
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.
Page 6 of 10
iNeuron Intelligence Pvt Ltd
Page 7 of 10
iNeuron Intelligence Pvt Ltd
● Object-oriented database:
This database stores data values and funcYons as items and both of
these objects are linked in various ways.
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.
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.
Page 10 of 10
iNeuron Intelligence Pvt Ltd
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
Page 3 of 11
iNeuron Intelligence Pvt Ltd
Page 4 of 11
iNeuron Intelligence Pvt Ltd
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.
● Arithme'c Operators
● Comparison Operators
● Logical Operators
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
Page 6 of 11
iNeuron Intelligence Pvt Ltd
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.
● 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.
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
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?
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.
● 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.
Page 10 of 11
iNeuron Intelligence Pvt Ltd
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
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
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.
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
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.
9. What is DBMS?
Page 5 of 9
iNeuron Intelligence Pvt Ltd
Page 6 of 9
iNeuron Intelligence Pvt Ltd
Lep Join
Right Join
Inner Join
Full Join
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.
Page 7 of 9
iNeuron Intelligence Pvt Ltd
GROUP BY - groups data from different tables that have similar rows
in the database
Page 8 of 9
iNeuron Intelligence Pvt Ltd
Page 9 of 9
iNeuron Intelligence Pvt Ltd
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?
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.
4. What is ETL?
6. What is a subquery?
7. What is ACID?
Page 3 of 8
iNeuron Intelligence Pvt Ltd
Page 4 of 8
iNeuron Intelligence Pvt Ltd
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.
Page 5 of 8
iNeuron Intelligence Pvt Ltd
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.
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.
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.
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
Page 8 of 8
iNeuron Intelligence Pvt Ltd
1. What is a SCHEMA?
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.
Page 2 of 8
iNeuron Intelligence Pvt Ltd
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.
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
9. Classify views.
Simple View - This is based on a single table and does not have a
GROUP BY clause or other features.
Materialized View- This saves both the defini9on and the details. It
builds data replicas by physically preserving them.
Page 4 of 8
iNeuron Intelligence Pvt Ltd
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.
Page 5 of 8
iNeuron Intelligence Pvt Ltd
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.
Page 6 of 8
iNeuron Intelligence Pvt Ltd
Page 7 of 8
iNeuron Intelligence Pvt Ltd
Page 8 of 8
iNeuron Intelligence Pvt Ltd
3. What is an ALIAS?
Page 2 of 9
iNeuron Intelligence Pvt Ltd
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.
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
Where:-
Page 4 of 9
iNeuron Intelligence Pvt Ltd
10. What is a deadlock in SQL, and how can you prevent them?
Page 5 of 9
iNeuron Intelligence Pvt Ltd
Page 6 of 9
iNeuron Intelligence Pvt Ltd
Equi joins two or more tables using the equal sign operator (=).
Page 7 of 9
iNeuron Intelligence Pvt Ltd
Page 8 of 9
iNeuron Intelligence Pvt Ltd
Page 9 of 9
iNeuron Intelligence Pvt Ltd
This will create a new table with the same structure as the old table
but without the values from the previous table.
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.
Page 2 of 7
iNeuron Intelligence Pvt Ltd
Index
Triggers
Clustered vs. Non-Clustered Index
Page 3 of 7
iNeuron Intelligence Pvt Ltd
Page 4 of 7
iNeuron Intelligence Pvt Ltd
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.
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.
Page 6 of 7
iNeuron Intelligence Pvt Ltd
Page 7 of 7
iNeuron Intelligence Pvt Ltd
Ans-
Q2. What do you mean by DBMS? What are its different types?
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.
Page 2 of 11
iNeuron Intelligence Pvt Ltd
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?
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 MINUS operator is used to return rows from the first query but
not from the second query.
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.
Page 5 of 11
iNeuron Intelligence Pvt Ltd
Q11. How to create empty tables with the same structure as another
table?
Page 6 of 11
iNeuron Intelligence Pvt Ltd
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
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.
Page 8 of 11
iNeuron Intelligence Pvt Ltd
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 11
iNeuron Intelligence Pvt Ltd
The MINUS operator is used to return rows from the first query but
not from the second query.
Within the clause, each SELECT query must have the same number of
columns.
Page 10 of 11
iNeuron Intelligence Pvt Ltd
Page 11 of 11
iNeuron Intelligence Pvt Ltd
• SELECT
• INSERT
• UPDATE
• DELETE
• CREATE DATABASE
• ALTER DATABASE
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
Page 3 of 13
iNeuron Intelligence Pvt Ltd
Step 1: Click on SSMS, which will take you to the SQL Server
Management Studio page.
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
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
ELSE result
END;
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.
Page 6 of 13
iNeuron Intelligence Pvt Ltd
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.
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
AS
sql_statement
GO;
EXEC procedure_name;
Page 8 of 13
iNeuron Intelligence Pvt Ltd
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(
WHERE r=&n;
Page 10 of 13
iNeuron Intelligence Pvt Ltd
Table: StudentInformaPon
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 11 of 13
iNeuron Intelligence Pvt Ltd
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 12 of 13
iNeuron Intelligence Pvt Ltd
Page 13 of 13
iNeuron Intelligence Pvt Ltd
Ans- In SQL, there is a built-in funcDon called Get Date() which helps
to return the current Dmestamp/date.
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.
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
Page 4 of 9
iNeuron Intelligence Pvt Ltd
Page 5 of 9
iNeuron Intelligence Pvt Ltd
Q10. How to create empty tables with the same structure as another
table?
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.
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
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.
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.
Page 8 of 9
iNeuron Intelligence Pvt Ltd
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
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.
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.*
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
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
Page 3 of 11
iNeuron Intelligence Pvt Ltd
FROM product_reviews
FROM sales
GROUP BY customer_id;
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
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
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
DECLARE
Page 5 of 11
iNeuron Intelligence Pvt Ltd
BEGIN
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 (
FROM Employees
UNION ALL
Page 6 of 11
iNeuron Intelligence Pvt Ltd
FROM Employees e
FROM Repor*ngChain
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,
FROM students;
FROM Authors
Page 7 of 11
iNeuron Intelligence Pvt Ltd
FROM (
FROM Inventory
Page 8 of 11
iNeuron Intelligence Pvt Ltd
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 (
FROM sales
GROUP BY customer_id
Page 9 of 11
iNeuron Intelligence Pvt Ltd
Page 10 of 11
iNeuron Intelligence Pvt Ltd
FROM employees
GROUP BY department;
FROM employees
WHERE ra*ng = 5
GROUP BY employee_name
Page 11 of 11
iNeuron Intelligence Pvt Ltd
FROM employees
FROM employees e
Page 2 of 6
iNeuron Intelligence Pvt Ltd
GROUP BY m.employee_name;
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.
Page 3 of 6
iNeuron Intelligence Pvt Ltd
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?
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
The term colla1on refers to a set of rules that specify how the
database engine should sort and compare the character data.
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.
20. What ACID proper1es ensure that the database transac1ons are
processed?
Page 6 of 6
iNeuron Intelligence Pvt Ltd
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.
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.
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.
4. Save the .exe file on your computer and click on Open with the
right mouse buZon.
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.
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.
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
SQL Server Agent is a significant part of MicrosoS SQL Server used for
execuKng scheduled administraKve tasks commonly known as jobs.
Page 4 of 8
iNeuron Intelligence Pvt Ltd
Page 5 of 8
iNeuron Intelligence Pvt Ltd
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.
Page 6 of 8
iNeuron Intelligence Pvt Ltd
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
Page 8 of 8
iNeuron Intelligence Pvt Ltd
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.
Page 3 of 9
iNeuron Intelligence Pvt Ltd
Page 4 of 9
iNeuron Intelligence Pvt Ltd
Page 5 of 9
iNeuron Intelligence Pvt Ltd
Page 6 of 9
iNeuron Intelligence Pvt Ltd
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.
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
ADD
AUGMENT
INSERT
CREATE
Ans: C
3. What command will you use to remove rows from a table 'AGE'?
Page 2 of 5
iNeuron Intelligence Pvt Ltd
7. Define a view?
Page 3 of 5
iNeuron Intelligence Pvt Ltd
Standardizaaon
Data Integrity
Both a and b
None of the above
Ans: B
DDL
DML
DQL
DCL
Ans: A
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
brackets []
braces {}
parenthesis ()
none of the above
Ans: C
report
form
table
file
Ans: c
Page 5 of 5
Page | 1
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
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
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
___________________________________________________________________________________________
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.
The foreign key is used to link two tables together and it is a field that refers
to the primary key of another table.
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.
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.
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?
Page | 5
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q15. What are all the different 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.
Page | 8
Page | 1
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q1. Explain DML with its examples?
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
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?
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.
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.
NOT NULL
CHECK
DEFAULT
UNIQUE
PRIMARY KEY
FOREIGN KEY
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?
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.
Page | 5
iNeuron Intelligence Pvt Ltd
Q17. What are all types of user-defined functions?
Following are the user-defined functions:
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.
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)
Page | 6
Page | 1
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
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.
Consider an example of the deletion of those records which have age = 25 and
then COMMIT the changes in the database.
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.
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.
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.
FROM table_name;
Page | 3
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
Q9. What are aggregate and scalar functions?
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:
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:
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:
The primary key that is created on more than one column is known as composite
primary key.
% (percent sign) Matches zero or more characters and _ (Underscore) is used for
matching exactly one character. For example:
Page | 5
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
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.
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.
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?
Page | 6
Page | 1
iNeuron Intelligence Pvt Ltd
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.
Page | 2
iNeuron Intelligence Pvt Ltd
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.
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.
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.
Page | 3
iNeuron Intelligence Pvt Ltd
12. Suppose you have a table named person how would you enter record in
this table?
Ans.
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
__________________________________________________________________
Ans. The WHERE clause is used to filter records. It is used to extract only those
records that fulfill a specified condition.
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.
Ans.
Page | 6
Page | 1
iNeuron Intelligence Pvt Ltd
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.
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.
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.
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.
Ans.
Page | 4
iNeuron Intelligence Pvt Ltd
______________________________________________________________
12) Write a query where whose last name falls in between FA and FR:
Ans.
Ans. With the in operator, you can write a single condition no matter how
many expressions are in the set.
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
______________________________________________________________
Ans.
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.
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
______________________________________________________________
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.
Page | 3
iNeuron Intelligence Pvt Ltd
______________________________________________________________
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.
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.
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
_______________________________________________________________________
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
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.
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.
Page | 3
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________
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.
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
___________________________________________________________________________________________
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.
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?
Page | 3
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
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])
8) Write a Dax formula for creating a measure showing the sum of profit?
Ans. TotalProfit = SUMX (Sales, Sales [Profit])
10) You're working with sales data from multiple regions. How would you create a report that
displays a trend analysis?
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
___________________________________________________________________________________________
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
Page | 6
iNeuron Intelligence Pvt Ltd
18) What is a Dimension Table in Power Bi?
a) whose values uniquely identify a row in the table b) Relation between tables
Page | 7
Page | 1
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
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
Page | 2
iNeuron Intelligence Pvt Ltd
___________________________________________________________________________________________
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.
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
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
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
● 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
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
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
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
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
● 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
5
iNeuron Intelligence Pvt Ltd
Tableau MCQ :
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
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
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
a) COUNT
b) SUM
c) AVG
d) MIN
Ans. b) SUM
iNeuron Intelligence Pvt Ltd
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.
Ans. Tableau provides various data connection options, including Excel spreadsheets, text files, databases (such
as SQL Server, Oracle, MySQL), and web data connectors.
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.
Ans. Text values, date values, Date, and time values, Boolean , Geograohical.
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.
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.
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.
Ans. Tableau supports connecting to various big data sources like Hadoop, Amazon Redshift, and Google Big
Query.
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.
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.
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.
Ans. Tableau Groups are a collection of multiple members in a single dimension that is combined to
form a higher category.
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?
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?
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.
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.
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.
34. In Tableau, what does an extract provide that a live connection does not?
37. In Tableau, what does the "Hide" feature allow you to do?
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
13. How can you refresh data in Tableau to reflect changes in the source?
14. What is the role of the "Data Interpreter" in Tableau's data connection process?
15. Which chart type is most suitable for displaying the distribution of a single numerical variable?
Ans. c) Histogram
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
18. Which chart type is effective for visualizing trends over time?
19. How can you add a reference line to a bar chart in Tableau?
20. In Tableau, what does the "Color" shelf allow you to do?
21. How can you customize the size of data points in a scatter plot 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
23. How can you add data labels to individual data points in a chart?
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
26. What does the "Color Palette" option in Tableau allow you to customize?
Ans. c) Using the "Combo Chart" option in the "Show Me" menu
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
33. How can you combine data from multiple tables in Tableau?
35. What is the role of the "Level of Detail" (LOD) expressions in Tableau?
40. How can you share a Tableau workbook with someone who doesn't have Tableau installed?
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
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
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
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