Python New Theory Question
Python New Theory Question
1.2 genral purpose mean - python support multiple domain like ML,AI,data science.
1.3 high level means- we dont need to declare which type of variable is that.
2. features of python?
open source- you can implement if you are not satisfied with the content .
3. application of python?
1. desktop application.
2. web application.
3. game devlopement.
4. ML
5. data science.
4. what is variable?
camel case- can be harder to read bcz lack of seperator make it difficult.
6. use of python?
1. facebook
2. google
3. instagram.
4. spotify
1. high level
2. low level ?
1. compilor
2. interpreter
its a dicision making statement . when we want to execute a block of code based on particular condition .
ex. if, elif, else.
1. local - a variable which is declare inside a function then its called local varibale.
2. global - a variable which is declare outside a function then its called global varibale.
type casting method convert variable data type into certain data type. ex.- int to float, float to int.
a[2]=3
2. slicing - its used to access one or more character from string. ex - a=[1,2,3,4,5,6]
a[0:3] = 1,2,3
there are two ways to comment 1- single line comment by hash keyword(#)
1. Increasing readability
2. Explaining the code to others
3. Understanding the code easily after a long-term
4. Including resources
5. Re-using the existing code
Python literals are a data type and can hold any value type, such as strings, numbers, and more.
1. capitalize() - its used to convert first character of string in upper case and remaining aree to a lower
case.
2. upper() - its use to convert lower into upper case.
3. lower() - its use to convert upper into lower case.
4. title() - its use to convert first character of each string in upper case.
5. swapcase() - its use to convert upper into lower and lower into upper.
6. L-strip() - its use to remove all white leading spaces from string.
7. R-strip()- its use to remove all trailing spaces from string.
8. strip() - its remove bothe side spaces from string.
9. count() - its used to count occurance of character or word in string.
10. replace()- its uses to replace a word or character in string.
11. index() - it will return an index position number from string
12. find() - it will return an index position number from string.
13. split() - its used to convert string data type into list data type.
14. join() - it will join multiple string together.
its easy and compact syntax for creating a list from a string and another list.
1. its immutabale.
2. orderd.
3. duplicates items are allowed.
4. tuple are enlosed in round brackets.
5. multiple data types.
1. list
2. tuple
1. for loops - its used when number of iteration are allready known.
2. while loops - its used when number of iterations are unknown.
1. its mutable.
2. unorderd.
3. duplicate items are not allowed.
a function whose functionality is predefined in python. then its called built in function.
python module is python file with dot py extension. ex - variable , function , class
1. write
2. read
3. append
4. delete
its the process of extracting meaningfull data or imformation from web pages.
1. Errors are problems that occur in the program due to an illegal operation performed by the user or by
the fault of a programmer, due to which stop the normal flow of the program.
1.ArithmeticError.
2.AttributeError.
3.Exception.
4.ImportError.
5.IndexError.
6.KeyError.
1. inheritance
2. polymorphisome.
3. encapsulation.
4. abstraction.
1. when one object is aquring all the properties and behaviour of super class then its called inheritance.
__types of inheritance
1. Single Inheritance – where a derived class acquires the members of a single super class.
2. Multi-level inheritance – a derived class d1 in inherited from base class base1, and d2 are inherited
from base2.
3. Hierarchical inheritance – from one base class you can inherit any number of child classes
4. Multiple inheritance – a derived class is inherited from more than one base class.
a concept that hiding all the internal details of an application and showing functionality to the user.
it allow users to add new functionality to an existing object without modifying its structure.
1. arrays are the fundamental data structure and imprtant part of the most programming language.
2. in python they are a container which are able to store multiple item of same data type.
1. bootstrap is a giant collection of handy and reusable bits of code written in html, css, javascript .
2. its also front end framework that enable devloper to build fully responsive website.
1. data structure are the container that organize and group data according to type.
2. the main data structre are 1.list 2.tuple 3.set 4.dict
The .py files are the python source code files. While the .pyc files contain the bytecode of the python files.
1. And
2. Or
3. Not
4. If
5. Elif
6. Else
7. For
8. While
9. Break
10. As
11. Def
12. Lambda
13. Pass
14. Return
15. True
16. False
17. Try
18. With
19. Assert
20. Class
21. Continue
22. Del
23. Except
24. Finally
25. From
26. Global
1. Memory management in python is managed by Python private heap space. All Python objects and
data structures are located in a private heap. The programmer does not have access to this private
heap. The python interpreter takes care of this instead.
2. The allocation 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.
3. 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.
1. Arrays and lists, in Python, have the same way of storing data. But, arrays can hold only a single data
type elements.
2. whereas lists can hold any data type elements.
Docstrings are not actually comments, but, they are documentation strings. These docstrings are within
triple quotes. They are not assigned to any variable and therefore, at times, serve the purpose of
comments as well.
methods
1 f = open('file_name.txt','w')
2 f.write('nilesh mahaadu kharat')
3 f.close()
1. The try block lets you test a block of code for errors.
2. The except block lets you handle the error.
3. The else block lets you execute code when there is no error.
1. The re module provides a set of powerful regular expression facilities, which allows you to quickly
check whether a given string matches a given pattern (using the match function), or contains such a
pattern (using the search function).
using the “self” we can access the attributes and methods of the class in Python.
by using @ symbol
Application Programming Interface, is a server that you can use to retrieve and send data to using code
The loop is executed until CTRL + C is pressed, but Python also has a break statement that we can use
directly in our code to stop this type of loop.
1. Loop control statements are used to change the flow of execution. These can be used if you wish to
skip an iteration or stop the execution.
2. The three types of loop control statements in python are break statement,
3. continue statement, and
4. pass statement.
89. How do you use the else clause with a for loop in Python?
1. Python allows the else keyword to be used with the for and while loops too.
2. The else block appears after the body of the loop.
3. The statements in the else block will be executed after all iterations are completed
1. Python Keywords are some predefined and reserved words in Python that have special meanings.
2. Keywords are used to define the syntax of the coding.
1. keywords are the reserve words which are predefined and have a special meaning in the language,
whereas
2. an identifier is a unique name assigned to a variable, function, class, etc.
3. there are three types of identifiers in python
A. public
B. private
C. protected
93. How many keywords are there in Python and what are
some of the most commonly used ones?
The del keyword is used to delete objects. In Python everything is an object, so the del keyword can also
be used to delete variables, lists, or parts of a list etc.
with statement is used in file handling to make the code cleaner and much more readable
1. Shallow Copy reflects changes made to the new/copied object in the original object.
2. Deep copy doesn't reflect changes made to the new/copied object in the original object
1. min
2. max
3. sum
4. pow
5. super
6. type
7. zip
1. class variable - a variable which is declare inside the class is called class varibale
2. instance variale- a variable whis is declare inside the function with self keyword
If you want your method to modify any attribute, you can pass its name as a string. You can then use
getattr() and setattr() to get and set the attribute.
In [ ]: 1
In [ ]: 1