python training in visakhapatnam
1. How Python is able to manage memory?
All Python Objects and data structured will be stored in a private heap. The Interpreter will take off using this private heap, the programmer will not have access to use this private heap. The allocation of Python memory will be done by Python Memory Manager. Python also gives and inbuilt garbage collector. It frees all unused memory and makes available to the heap space.
2. What are the built-in data types in Python?
There are two types of built-in data types in Python
Mutable: List, Sets, Dictionaries
Immutable: Strings, Tuples, Dictionaries.
In Python, a string is aa alpha-numeric characters. In Python string is an immutable object, so strings cannot be modified once they assigned a value. Python provides many string methods like split(), join(), replace(), etc.,
4. What is a Function in Python?
In python, a Function is an object representing a block of code for reusing purpose. Python supports many built-in functions and also we can create user-defined functions.
5. What is a list in Python?
In python List is like an array in C and Java. But lists may not be homogeneous like in java. The list may contain integers, strings, and Objects. By using lists we can implement stacks and queues very easily. In the simple list is a container which can store multiple data at the same time. Lists are mutable so they can be changed after creation. A list can also contain duplicate values.
6. What is a Tuple in Python?
A tuple is also like a list but tuples are immutable and they are indexed by integers. Tuples are indicated by using parentheses, while lists are placed in [ ] brackets. Elements in tuples can be separated by commas with using or without using parentheses.
7. What are Python Sets
It is a collection of unordered data type and has no duplicate values. It is similar to sets in mathematics. Elements in Python sets can be deleted, added and can also various operations like union, difference, and intersection.
8. What is a dictionary in Python?
It is a collection of unordered, Changeable and indexed data elements. Dictionaries are written by using curly brackets and they consist of keys and values. Key and value are separated with colons and each pair must be separated with commas. Dictionaries are mutable, so they can be changed.
9. What are iterators in Python?
Iterators are used to iterate a group of elements like a list.
10. What are the generators?
Implementing iterators can be defined as generators. Generators yields expression in the function.
11. What is a module in Python?
In Python, every Python program file is a module. We can import other modules like objects and attributes.
12. What are the differences between local variables and global variables in Python?
Local variables are assigned a new value anywhere inside the function body and it is assumed to be local whereas global variables are only referenced inside a function and they are implicitly global.
13. What are the differences between Django, Pyramid, and Flask?
Pyramids are used to build large applications. They provide flexibility and helps the developer to use the right tools for the developer for developing their application. It is heavy configurable. Flask is a microframework and primarily used for a small application. We have to use external libraries and they are ready to use. Django is also used for building larger applications and it also includes an ORM.
14. Why Python is interpreted?
Python is interpreted because it runs directly runs from the source code. It first converts the source program into an intermediate language and it again translates into machine language.
15. What is Regular expression in Python?
In a programming language, a regular expression is a text string used to describe a search pattern. It is mainly used for extracting information from files, log, spreadsheets, code, and documents. A regular expression can tell a program to search specific text from the string. It can include expressions like text matching, branching, repetition, pattern-composition, etc.,
16 What is a namespace in python?
It is like a box where a variable name is mapped to the object which is placed. It is known as a namespace. When the variable is searched it will search for this box to get the corresponding object.
17. What is lambda in Python?
It is often used in an inline function to express anonymous function.
18. What is inheritance in Python?
One class(subclass) is able to access all the members(fields and methods) in the superclass(parent class) is known as inheritance. The class which is inheriting from is known as superclass and the class that is inherited is known as child class. The advantage of inheritance is code reusability. Python supports different types of inheritance.
Single-Level Inheritance: When the child class acquires the members of a single superclass is known as single-level inheritance.
Multi-level Inheritance: When a child class is inherited from a superclass and another class is inherited from the child class and the chain continues, this is known as Multi-level Inheritance.
Hierarchical Inheritance: Two or more classes can be inherited from one super class is known as hierarchical inheritance.
Multiple inheritance: a child class is inherited from more than one superclass is known as multiple inheritance.
Example : a=”Hello World”
Python support many string methods, below are some of the examples