Python questions
Python questions
- Python is used in different domains like ML, software dev, website developing, data analysis, AI, DS,
web scraping
2. Python history?
a. ABC lang
b. C lang
c. Modula-2+
d. Algol 68
e. Icon
f. Bourne shell
- Guido Von Rossum took the features from these languages and also found solutions for the
problems existing in those languages in python.
4. Features of python:
- Domain specific language – Single purpose language or language created for serving single
purpose
Eg: HTML
- Source code converted into byte code, which needs python virtual machine to run.
7. OOP:
- Python is an object-oriented programming language – Uses classes and objects to achieve code
reusability
8. High level language: User understandable language (easy to read, write and understand).
9. Simple syntax
11. open source – can be used by anyone and can contribute too.
- Web dev
- Data analysis
- ML
- Computer vision
- IOT
- Game programming
- Web scraping
- System Automation
- Browser automation
- GUI programming
- Rapid programming
- AI
- DS
Exceptions/ disadvantages:
- Android development
- OS development
def block():
print(“statement”)
- 35 keywords in python
- Module: Keyword
>>> keyword.kwlist
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', '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']
>>> print(len(keyword.kwlist))
35
Functions: Grouping a block of code/ subpart of program separately.
- ABC company want to distribute 100 lord Ganesh idols on the eve of Vinayaka Chaviti. So
rather than making each idol manually if they that casting equipment they can easily make
the idols. This saves time and effort. This is called reusability.
- Once the idols are done people want to add different colours to their respective idol like one
wants green, the other yellow and so on. So, we can paint the extracted idol as per our wish.
In the similar fashion we can pass the arguments as per our wish and get the final output.
This gives us the dynamic functionality.
Thus, functions are responsible in attaining code reusability and organizing of the code.
How is code organizing achieved?
- There are 100 lines of code in a program. If there are few lines of code which are related. If
they are written inside a function the code looks neat and organized.
- So, while updating the program we don’t need to make changes in the entire code rather we
change the block of the code which is necessary.
- Eg: Repairing the fan – the part which is not working or which needs to be repaired/ replaced
is only treated.
Types of functions:
1. Built-in functions
1. Built-in functions: