Basics of Programming with Python
1. What
is Python?
Ø Python
is an interpreted, object oriented, high level programming language.
Ø It
was founded by Guido Van Russum in 1991
Ø Python is open and free source
2. What
are features of python?
Ø Python
is open and free source
Ø It
is high level language
Ø It
is easy to syntax and easy to code
Ø Readable
codes in Python
Ø It
is portable Language
Ø It
is an interpreted Language
3. Explain
about the PEP8.
Ø PEP8
is Python enhancement proposal. It is official document and consists of the
rules regarding to the Python language. The rules are as follows.
Ø Maximum
characters in one line limited to 79 characters.
Ø Indentation
is important while writing code. Use proper indentation.
Ø Naming
convections should be proper and easy to understand by anyone.
4. What
are namespaces in Python?
Ø Namespaces
is a system ensures that all names should be unique and proper.
Ø Ex:
If in a class there are two students name Ram. But specially when we are
talking about the Ram Sharma. It is easy to understand and Namespaces in Python
works as their surname for easy to understand.
5. How
Memory manages in Python?
Ø In
python consist of private heap in which all the objects and data structures
stored in that private heap. Python memory manager manages private heap.
Ø There
is garbage collector in python which recycles unused memory.
6. What
are Local and global variables?
Ø Local
variable:
If the variable declared
inside the function then it is only accessible inside function So it is called
Local variable.
Ø Global
Variable:
If the variable declared
outside the function and it is accessible anywhere in the projects. It is known
as Global Variable.
7. What
are the types of operators?
Ø Arithmetic
Operator:
It
is use with numeric values to perform calculations. It consists of the +, -, *,
/, %
Ex:
If a = 15 and b = 5
1. Addition
: a + b = 15 + 5 = 20
2. Subtraction:
a – b = 15 – 5 = 10
3. Multiplication:
a*b = 15*5 = 75
4. Divison:
a/b = 15/5 = 3
5. Modulus: a%b = 15%5 = 0
Ø Comparison
operator:
It
is use to compare to values. It consists of the ==, <, >, >=, <=,
Ø Assignment
operator:
It
is use to assign values, It consists of the =, +=, -=, %=, //=, <<=,
>>=
Ø Logical
operator:
It
is used to combine conditional statements
§ And:
If both the values are true then it will true
§ Or:
If one of value is true then it will true
§ Not:
Reverse the results. If the result is true, it returns false and if the result
is false, it returns true.
8. How
comments are written in python?
Ø Single
line comments: It is given by #
Ø Multiple
line comments: It is given by ‘’’’’’’This is it’’’’’’’’
9. What
are list and tuples in python?
Ø List: It is unordered and mutable collections. Implications of iterations are time consuming. It consumes more memory. We can change the values from list. We can easily add or remove elements from the list. It is given by ().
Ø Tuple: It is unordered and un-changeable collections. Implications of iterations are faster. We can’t change the values from tuples. It consumes less memory. We can’t easily add or remove elements from the tuples but only access it. It is given by [].
10. What
is Lambda in python?
It
is small function that has only one expression.
Ex:
a
= lambda b: b+10
print(a(4))
Output:
14
11. What
is Pass, Break, continue statements?
Ø Pass:
If we haven’t anything to write the we use pass statement. It do nothing.
Ø Break:
If we want to stop or terminate the loop then, we use break statement.
Ø Continue:
If we want to skip the particular condition then, the continue statement is use.
- Nikheel Joshi
- Mar, 28 2022