May 25, 2019

Top 20 Python Interview Questions and Answers

 
Ques: 1. So, what is Python?
 
Answer:
 
Python is an open source programming language that is widely used as one of the most popular interpreted languages. Objects, modules, threads, exceptions, dynamic typing, very high-level dynamic data types, classes, and memory management are all included. It's easy to use, portable, expandable, interpreted, interactive, object-oriented, and has a built-in data structure. It's also open source. It's paired with a very simple syntax. Python is portable and scriptable, but it is mostly thought of as a general-purpose programming language.
 


 
Ques: 2. What are the benefits of using Python?
 
Answer:
 
  • Python is one of the most success interpreted languages. Means that, Python scripts does not need to be compiled before it is run.
  • Python is an object oriented as it allows the definition of classes along with composition and inheritance.
  • In Python, functions and classes are first-class objects. It means that they can be assigned to variables, returned from other functions and passed into functions.
  • Python is dynamically typed, means that no need to state the types of variables when you declare them. You can declare variables without error like a=10 and then a="a good programmer".
  • Python code is very quick to write. The numpy package is a good example of this, it is very quick because a lot of the number crunching in it.
  • Python has a vast area to use in web applications, automation, scientific modelling, big data applications and many more.
  • It’s also often used as inclusive code to get other languages and components to use.
 
 
Python Pandas Interview and Questions
 
 
Ques: 3. What do you know about PEP 8?
 
Answer:
 
PEP is short for Python Enhancement Proposal. It defines a set of rules that specify how to format Python code for maximum readability. It is the latest Python coding standard, a set of coding recommendations. It guides to deliver more readable Python code.
 


 
Ques: 4. How does the Conversion from number to string happens in Python?
 
Answer:
 
To convert, the number to string, in Python, use the built-in function str(). For hexadecimal or octal representation conversion, use the built-in functions hex() or oct(). And for fancy formatting, use the % operator on strings, e.g. "%04d" % 144 yields '0144' and "%.3f" % (1/3.0) yields '0.333'.
 

C++ language Interview Questions and Answers


Ques: 5. What Is Class and method in Python? How will you use them?
 
Answer:
 
A class can be based on one or more other classes, called its base class(es). It then inherits the attributes and methods of its base classes. This allows an object model to be successively refined by inheritance.  A class is the object type created by executing a class statement. Class objects are used as templates to create instance objects, which embody both the data (attributes) and code (methods) specific to a data type.
 
A method is a function on some object x that you normally call as x.role(arguments...). Methods are defined as functions inside the class definition:
class C:
def names (self, arg):
return arg*2 + self.attribute.
 


 
Ques: 6. What are the some of the core default modules available in Python?
 
Answer:
 
There are a few of the core default modules available in Python.
 
    XML – Enables XML support.
    string – Contains functions to process standard Python strings.
    traceback – Allows to extract and print stack trace details.
    email – Help to parse, handle, and generate email messages.
    sqlite3 – Provides methods to work with the SQLite database.
    logging – Adds support for log classes and methods.
 


 
Ques: 7. What Is Self in Python?
 
Answer:
 
Self is just a name for the first argument of a method. A method defined as name(self, a, b, c) should be called as x.name(a, b, c) for some instance x of the class in which the definition occurs; the called method will think it is called as name(x, a, b, c).
 


 
Ques: 8. How Do I Generate Random Numbers In Python?
 
Answer:
 
The standard module random implements a random number generator. Usage is simple:
import random
random.random()
This returns a random floating point number in the range [0, 1).
But you can also generate random numbers in Python in different ways:
· uniform(X, Y) - It returns a floating point number between the values given as X and Y.
· randint(X, Y) - This command returns a random integer between the values given as X and Y.
 


 
Ques: 9. In Python, how memory is managed?
 
Answer:
 
The memory is managed by private heap space in Python. All objects and data structures located in a private heap. The developer/coder/programmer does not have any access to the private heap and interpreter will takes care of Python private heap in memory. The Python memory manager will allocate Python heap space for Python objects. The Python core APIs give access to some tools for the programmer to code. There is an inbuilt garbage collector in Python, which recycle all the unused memory and frees the memory and makes it available to the heap space.
 
 


Ques: 10. What are the available tools to search the bugs or perform static analysis?
 
Answer:
 
PyChecker is a static analysis tool that searches the bugs in source code and gives warnings about the complexity and style of the bug. And Pylint is another tool that checks whether the module satisfies the coding standard and makes sure to write plug-ins to add a custom feature.
 


 
Ques: 11. Can you explain the rules For Local and Global Variables in Python?
 
Answer:
 
Variables are only referenced inside a function and are implicitly global. A local variable is assigned a new value anywhere within the function's body. The variable is implicitly local, if a variable is assigned a new value inside the function. Otherwise, you need to explicitly declare it as 'global'. If global was required for all global references, you'd be using global all the time. You'd have to declare as global every reference to a built-in function or to a component of an imported module.
 
 
Ques: 12. What do you know about The Dictionary Function in Python?
 
Answer:
 
In python, you have to associate keys with values. Key should be unique because it is useful for retrieving information in Python. A dictionary is a place where you will find and store information on address, contact details, etc. In Python, the strings will be passed as keys.
 
Keys must be separated by a colon and the pairs are separated themselves by commas. And the whole statement will be enclosed in curly brackets.
 
 
Ques: 13. Can you explain the Sharing of Global Variables Across Modules in Python?
 
Answer:
 
The canonical way to share information across modules within a single program is to create a special module (often called config or cfg). Just import the config module in all modules of your application; the module then becomes available as a global name. Because there is only one instance of each module, any changes made to the module object get reflected everywhere. For example:
 
config.py:
x = 0 # Default value of the 'x' configuration setting
mod.py:
import config
config.x = 1
main.py:
import config
import mod
print config.x
 
 
Ques: 14. Do you know about Indexing and Slicing Operation in Sequences?
 
Answer:
 
Python supports two main operations which are indexing and slicing. Tuples, lists and strings are some examples about sequence. Indexing operation allows you to fetch an item in the sequence and slicing operation allows you to retrieve an item from the list of sequence. Python starts from the beginning and if successive numbers are not specified it starts at the last. In python the start position is included but it stops before the end statement.
 
 
Question: 15. What do you mean by Raising Error Exceptions in Python?
 
Answer:
 
Programmer can raise exceptions using the raise statements in python. While using exception statement, error and exception object must be specified first. This error should be related to the derived class of the Error. We can use this to specify about the length of the user name, password field.
 
 
Ques: 16. What do you mean by a Lambda Form?
 
Answer:
 
Make_repeater is used to create a function during the run time and it is later called at run time. The lambda statement is used to create a new function which can be later used during the run time. Lambda function takes expressions only in order to return them during the run time.
 
 
Ques: 17. What do you understand by Assert Statement?
 
Answer:
 
This statement is very useful when you want to check the items in the list for true or false function. This statement should be predefined because it interacts with the user and raises an error if something goes wrong. Assert statement is used to assert whether something is true or false.
 
 
Ques: 18. What are Pickling and Unpickling in Python?
 
Answer:
 
By specifying the dump function, you can store the data into a specific file and this is known as pickling. Python has a standard module known as Pickle which enables you to store a specific object at some destination and then you can call the object back at later stage. While you are retrieving the object, this process is known as unpickling.
 
 
Ques: 19. How a Tuple is different from a List?
 
Answer:
 
A tuple is a list that is immutable. A list is mutable, means that the members of a list can be changed and altered. But a tuple is immutable, it means that the members of list cannot be changed.
Other significant difference is of the syntax. A list is defined as
 
listA = [1,2,5,8,5,3,]
listB= ["John", "Alice", "Tom"]
A tuple is defined in the following way
tupX = (1,4,2,4,6,7,8)
tupY = ("John","Alice", "Tom")
 
 
Ques: 20. Does Python allow arguments Pass by Value or Pass by Reference?
 
Answer:
 
No, there is nothing like passing of the arguments by Value or pass by reference. Instead, they are Pass by assignment. Python does not support passing arguments by value or reference.
 
The parameter which you pass is originally a reference to the object not the reference to a fixed memory location. But the reference is passed by value. Additionally, some data types like strings and tuples are immutable whereas others are mutable.
 
 
 

May 05, 2019

Top 20 Oracle RDMS Interview Questions and Answers



Ques: 1. What is an Index? Explain the different types of index.

Answer: 

An index is a performance enhancement method that allows faster retrieval of records from the table. An index creates an entry for each value thus making data retrieval faster.
While creating an index, we should remember the columns which will be used to make SQL queries and create one or more indexes on those columns.
Following are the available indexes.

a. Clustered index:

It sorts and stores the rows of data in the table or view, based on its keys. These are the columns included in the index definition. There can be only one clustered index per table because sorting of data rows can be done only in one order.

b. Non-clustered index:

It contains the non-clustered index key value and each key value entry, in turn, has a pointer to the data row. Thus a non-clustered index contains a pointer to the physical location of the record. Each table can have 999 non-clustered indexes.

c. Unique Index:

This indexing does not allow the field to have duplicate values if the column is unique indexed. It can be applied automatically when a primary key is defined.

 

Oracle Fusion Applications interview Questions and Answers


Ques: 2. What are Constraints? Explain the different Constraints available in SQL?

 Answer: 

These are the set of rules that determine or restrict the type of data that can go into a table, to maintain the accuracy and integrity of the data inside the table. Following are the most frequent used constraints, applicable to a table:

  • <NOT NULL> It restricts a column from holding a NULL value. It does not work on a table.
  • <UNIQUE> It ensures that a field or column will only have unique values. It is applicable to both column and table.
  • <PRIMARY KEY> uniquely identifies each record in a database table and it cannot contain NULL values.
  • <FOREIGN KEY> It is used to relate two tables. The FOREIGN KEY constraint is also used to restrict actions that would destroy links between tables.
  • <CHECK CONSTRAINT> It is used to restrict the value of a column between a range. It performs a check on the values, before storing them into the database. It’s like condition checking before saving data into a column.
  • <DEFAULT> It is used to insert a default value into a column.


Oracle Accounts Payables Interview Questions and Answers

 

Ques: 3. What are Triggers? What are its benefits? Can we invoke a trigger explicitly?

Answer: 

The trigger is a type of stored program, which gets fired automatically when some event occurs. We write a Trigger as a response to either of the following event:

  • A database manipulation (DML) statement (DELETE, INSERT, or UPDATE).
  • A database definition (DDL) statement (CREATE, ALTER, or DROP).
  • A database operation (SERVERERROR, LOGON, LOGOFF, STARTUP, or SHUTDOWN).
  • SQL allows defining Trigger on the table, view, schema, or database associated with the event.

Following are its benefits:

  • Generating some derived column values automatically.
  • Enforcing referential integrity.
  • Event logging and storing information on table access.
  • Auditing.
  • Synchronous replication of tables.
  • Imposing security authorizations.
  • Preventing invalid transactions.

It is not possible to invoke a trigger explicitly. It gets invoked automatically if an event gets executed on the table having an association with the trigger.


Oracle ADF Interview Questions and Answers                                 

 

Ques: 4. What is the purpose of isolation levels in SQL?

Answer: 

Transactions use an isolation level that specifies the extent to which a transaction must be isolated from any data modifications caused by other transactions. These also help in identifying which concurrency side-effects are permissible.

Please refer the below list for more clarity on the different type of levels.

i. Read Committed.

It ensures that SELECT query will use committed values of the table only. If there is any active transaction on the table in some other session, then the SELECT query will wait for any such transactions to complete. Read Committed is the default transaction isolation level.

ii Read Uncommitted.

There is a transaction to update a table. But, it is not able to reach to any of these states like complete, commit or rollback. Then these values get displayed (as Dirty Read) in SELECT query of “Read Uncommitted” isolation transaction.

iii. Repeatable Read.

This level doesn’t guarantee that reads are repeatable. But it does ensure that data won’t change for the life of the transaction once.

iv. Serializable.

It is similar to Repeatable Read level. The only difference is that it stops Phantom Read and utilizes the range lock. If the table has an index, then it secures the records based on the range defined in the WHERE clause (like where ID between 1 and 3). If a table does not have an index, then it locks complete table.

v. Snapshot.

It is similar to Serializable isolation. The difference is that Snapshot does not hold a lock on a table during the transaction. Thus allowing the table to get modified in other sessions. Snapshot isolation maintains versioning in Tempdb for old data. In case any data modification happens in other sessions then existing transaction displays the old data from Tempdb.

Oracle Access Manager Interview Questions and Answers

 

Ques: 5. How do we Tune the Queries?

Answer: 

Queries can be tuned by Checking the logic (table joins), by creating Indexes on objects in the where clause, by avoiding full table scans. Finally use the trace utility to generate the trace file, use the TK-Prof utility to generate a statistical a nalysis about the query using which appropriate actions can be taken. 


Oracle Fusion HCM Interview Questions and Answers


Ques: 6. What is the difference between BEFORE and AFTER in Database Triggers?

Answer: 

BEFORE triggers, are usually used when validation needs to take place before accepting the change. They run before any change is made to the database. Let’s say you run a database for a bank. You have a table accounts and a table transaction. If a user makes a withdrawal from his account, you would want to make sure that the user has enough credits in his account for his withdrawal. The BEFORE trigger will allow to do that and prevent the row from being inserted in transactions if the balance in accounts is not enough.


Oracle SCM Interview Questions and Answers


AFTER triggers, are usually used when information needs to be updated in a separate table due to a change. They run after changes have been made to the database (not necessarily committed). Let’s go back to our back example. After a successful transaction, you would want balance to be updated in the accounts table. An AFTER trigger will allow you to do exactly that.

 

More on Oracle:

 Oracle Financials Interview questions and Answers

Oracle Cloud Interview Questions and Answers

Oracle PL/SQL Interview Questions and Answers

Oracle SQL Interview Questions and Answers

BI Publisher Interview Questions and Answers

Oracle 10g Interview Questions and Answers