0% found this document useful (0 votes)
5 views

Python questions

Python is a versatile programming language used across various domains such as machine learning, web development, and data analysis, with a history dating back to its first release in 1991. It is an object-oriented, high-level language known for its simple syntax, large community support, and open-source nature, making it beginner-friendly. Python's features include support for third-party libraries, code reusability through functions, and a clear distinction between general-purpose and domain-specific languages.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python questions

Python is a versatile programming language used across various domains such as machine learning, web development, and data analysis, with a history dating back to its first release in 1991. It is an object-oriented, high-level language known for its simple syntax, large community support, and open-source nature, making it beginner-friendly. Python's features include support for third-party libraries, code reusability through functions, and a clear distinction between general-purpose and domain-specific languages.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1. Why python is versatile?

- Python is used in different domains like ML, software dev, website developing, data analysis, AI, DS,
web scraping

- Python is also good for CP.

2. Python history?

- 1st release – 1991

- Named after Monty’s python flying circus show

3. Python was inspired from?

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:

- Converting txt files to csv(spread sheet files)

- Renaming large batch files

- Tracking of stock market

- Automatic filling of online forms etc

5. General purpose programming language vs Domain specific language

- Domain specific language – Single purpose language or language created for serving single
purpose

Eg: HTML

- General purpose programming language: Used for different purposes.

6. Interpreted vs compiled language:

- Interpreted language: Line by line executions, Platform independent feature,

- 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

10. beginner friendly

11. open source – can be used by anyone and can contribute too.

12. Supports third party libraries

13. Large community support

1. Which Industries we use python?

- 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

2. Advantages of python: Same as above

3. Python code structure:

def block():

print(“statement”)

Indentation, block/ group of statements


4. Keywords: Reserved words used to perform a specific task.

Eg: def – to create a function

Class – to create class

If, elif, else – To control conditions

for, while – loop

try, except, finally, raise – Exception handling

- 35 keywords in python
- Module: Keyword

>>> import 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.

 Why do we write separately?


- When we want to write a block of code repetitively and to organize the code efficiently, we
use the block of code written in the function and use it each time when needed. Thus, it
attains code reusability.
- Write Once Use multiple times
- Function divides the code/ program into subparts and make the code look systematic and
organized.

Real life example of function:

- 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

2. User defined functions

1. Built-in functions:

You might also like