Python was created by Guido Van Rossum . .The language was Global variable:
released in February I991.Python got its name from a BBC Variables that are defined outside a function
comedy series from seventies- “Monty Python‟s Flying Circus”
•Python can be used to follow both Procedural approach and
Object Oriented approach of programming . It is free to use
Advantages:
•Easy to use Object oriented language •Expressive language
•Interpreted Language •Its completeness •Cross-platform
Language •Fee and Open source •Variety of Usage /
Applications What is the function of database management system ?
Following are the function of database management system: -
To organize information - To store information - To retrieve
information
• The range() function generate set of values from
lower_limit toupper_limit-1
mutable data types: list[] and dictionary
immutable datatypes : int, float,string, tuple
string functions:
capitalize(), upper() lower(), isupper(),
islower(),isdigit(),isspace(),
find(),count(),split()
list funtions:
append() , pop(), extend() , insert() ,reverse() ,sort() ,index(),
clear()
tuple functions:
max(), min(),
dictionary functions:
key(), values(), updates(), pop(), clear()
A function is a block of organized, reusable code that
is used to perform a single, related action. Functions
provide better modularity for your application and a high
degree of code reusing.
Positional arguments:
arguments passed to a function in correct positional
order
keyword arguments:
When you use keyword arguments in a function call, the Pickling is the process of converting structure to byte stream
caller identifies the arguments by the parameter name.
Default arguments:
A default argument is an argument that assumes a
default value if a value is not provided in the function call
for that argument.
Local variable:
Variables that are defined inside a function body
What is data redundancy? 1. What is a stack? Give some real-life examples. Stack is a
Data redundancy means duplication of data. data structure that provides temporary storage of data in such
(a) Relation: A relation is a two-dimensional table. It contains a way that the element stored last will be retrieved first. This
number of rows(tuples) and columns(attributes). method is also called LIFO – Last In First Out. In real life we
(b) Tuple: This is the horizontal part of the relation. One row can think of stack as a stack of copies, stack of plates, stack of
represents one record of the relation. The rows of a relation rotis etc.
are also called tuples. 2. Which function is used to push an element in stack? The
(c) Attribute: The columns of a table are also called append() function.
attributes. The column is the vertical part of the relation. 3. Which function is used to pop an element in stack?
(d) Primary key: It is a column (or columns) in a table that The pop() function
uniquely identifies each row. A primary key value is unique 4. Which data structure is used to implement stacks in
and cannot be null. There is only one primary key for a table. Python?
(e) Candidate key: It is a column (or columns) that uniquely List 5. Give applications of stack. The applications of stack are
identify rows in a table. Any of the identified candidate keys as follows: • When a program executes, stack is used to store
can be used as the table's primary key. the return address at time of function call. After the execution
(F) Alternate key: A candidate key that is not the primary key of the function is over, return address is popped from stack
is called an Alternate Key. and control is returned back to the calling function. •
(G) Foreign key: It is a column (or a set of columns) that Converting an infix expression to postfix operation and to
refers to the primary key in another table i.e. it is used as a evaluate the postfix expression. • Reversing an array,
link to a matching column in another table converting decimal number into binary number etc.
6. What do you mean by Overflow and Underflow in the
SQL means Structured Query Language. It is the set of context of stacks? Overflow: trying to insert more data when
commands that is recognized by all RDBMS. the size of the stack has reached its maximum limit.
DDL Commands 1) CREATE 2) ALTER 3) DROP Underflow: trying to delete more data when the stack is
DML Commands 1) INSERT INTO 2) DELETE 3) UPDATE Empty
1. What does IDLE stand for? What is Python IDLE?
1) import mysql.connector IDLE is an acronym of Integrated Development Environment
2) create connection and is the standard, most popular Python development
3) create cursor environment. To run a program, we basically need an editor
4) execute the query to write it, an interpreter/compiler to execute it and a
5) Extract the query debugger to catch and remove the errors. Python IDLE
provides all these tools as a bundle. It lets edit, run, browse
and debug Python Programs from a single interface and
makes it easy to write programs.
What is the difference between Interactive mode and Script
mode? Python IDLE can be used in two modes: Interactive
mode and Script mode. Python shell is an interactive
interpreter. Python editor allows us to work in script mode i.e.
we can create and edit python source file
What are tokens? Tokens- Smallest individual unit of a
program is called token. Example keywords, identifiers,
literals, operators and punctuators.
What are Keywords? They are the words used by Python
interpreter to recognize the structure of program. As these
words have specific meaning for interpreter, they cannot be
used for any other purpose. ['False', 'None', 'True', 'and', 'as',
'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else',
'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is',
'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try',
'while', 'with', 'yield']
What is the default separator and terminator in print()
function in Python? How can we change it?
By default, print uses a single space as a separator and a \n as
a terminator (appears at the end of the string). We can use
the parameters sep and end to change the separator and
terminator respectively
What are the different types of errors in a Python program?
SYNTAX ERROR: An error in the syntax of writing code that
does not conform to the syntax of the programming language
is called a syntax error.
LOGICAL ERROR: It is an error in a program's source code that
results in incorrect or unexpected result. It is a type of
runtime error that may simply produce the wrong output or
may cause a program to crash while running.
RUN TIME ERROR: A runtime error is an error that occurs
during execution of the program and causes abnormal
termination of program
What is the difference in opening a file using open() function
or using with statement?
Using with ensures that all the resources allocated to file
objects gets deallocated automatically once we stop using the
file
What is the purpose of a return statement? How can a
function return more than one value? The return statement
is used to return either a single value or multiple values from
a function. More than values are returned by a function in the
form of a tuple
. Need of functions Some of the major advantages of using
functions in a program are:
• Modularity: Functions provide modularity to a program. It is
difficult to manage large programs. Thus, a large program is
usually broken down into small units called functions. This
makes the program easy to understand, more organized and
manageable.
• Code Reusability: Functions save space and time. Sometime
a part of the program code needs to be executed repeatedly.
If this part of program code is stored in a function than we do
not need to write the same code again and again. Instead,
function can be called repeatedly. This saves time and space.
We can also store the frequently used functions in the form of
modules which can easily be imported in other programs
when needed.
• Easy debugging: It is easy to debug small units of a program
than a long program