Python DjangoA
Python DjangoA
Ans. In Python, generally “with” statement is used to open a file, process the data present in the
file, and also to close the file without calling a close() method. “with” statement makes the
exception handling simpler by providing cleanup activities.
processing statements
41. How can we display the contents of text file in reverse order?
(d) print(line)
Ans. Both append() and extend() methods are methods of list. These methods are used to add
elements at the end of the list.
• append(element) – adds the given element at the end of the list which has called this method.
• extend(another-list) – adds the elements of another list at the end of the list which is called the
extend method.
Ans. Implementing something using Python recursion requires less effort. The code we write using
recursion will be comparatively smaller than the code that is implemented by loops. Again, codes
that are written using recursion are easier to understand also.
Ans. A file containing Python definitions and statements is called a Python module. So naturally,
the filename is the module name which is appended with the suffix .py.
Ans. Python package is a collection of modules in directories that gives a package hierarchy. More
elaborately, Python packages are a way of structuring Python’s module by using “dotted module
names”. So A.B actually indicates that B is a sub-module which is under a package named A.
Ans. To get current directory in Python, we need to use os module. Then, we can get the location
of the current directory by using getcwd() function.
47. What is the difference between del keyword and clear() function?
Ans. The difference between del keyword and clear() function is that while del keyword removes
one element at a time, clear function removes all the elements.
48. What is primary key?
Ans. Primary key is a combination of columns that uniquely identifies a row in a relational table.
Ans. All possible combinations of columns that can possibly serve as the primary key are called
candidate keys.
Ans. A combination of columns where values are derived from primary key of some other table is
called the foreign key of the table in which it is contained.
Ans. A candidate key that is not serving as a primary key is called an alternate key.
Ans. MYSQL is an open source RDBMS that relies on SQL for processing the data in the database.
The database is available for free under the terms of General Public License (GPL).
Ans. Relational Database Management System (RDBMS) facilitates access, security and integrity of
data and eliminates data redundancy. For example, MYSQL, Oracle, Microsoft Sql Server, etc.
Ans. Drop command is used to delete tables. For example, Drop Table Orders. Delete commands
are used to delete rows of a table.
Ans. This constraint ensures that the null values are not permitted on a specified column. This
constraint can be defined at the column level and not at the table level.
Ans. It is used to count the number of values in a given column or number of rows in a table. For
example, Select count (Roll No.) from students.
Ans. We can add a record by using insert command and we can add a column through the alter
table command.
60. Give any two differences between GET and POST submission methods of HTML form.
Ans.
GET Method POST Method
All form data is encoded into the URL Form data appears within the message body of
appended to the action URL as query string the HTTP request.
parameters.
Parameters remain in browser history, hence Parameters are not saved in browser history,
cannot be used to send password- like hence can be used to send sensitive
sensitive information. information.