Python Questions
5.34K subscribers
1 photo
7 links
Tasks for Beginners, Interview Questions, Regular expressions, simple coding problems, Quiz etc.

Useful Resources — »»» @python_resources_iGnani
Projects for Practice — »»» @python_projects_repository
Discussion Forum — »»» @python_programmers_club
Download Telegram
#interviewQuestions : 0009

Q: What can we do using Python
Q: Applications of Python
Q: Explain some of the areas where we can use Python

As mentioned before, Python is one of the most widely used language over the web.
It is known for its general purpose nature that makes it applicable in almost each domain of software development. Python as a whole can be used in any sphere of development.

To list few of them here:
○ Databases
Python provides interfaces to all major commercial databases. There by making it useful to create tools or GUI of databases, and also to use with an application which involves interacting with data.

○ Web Applications - We can use Python to develop web applications.
- It provides libraries to handle internet protocols such as HTML and XML, JSON, Email processing, request, beautifulSoup, Feedparser etc.
- There are many well-known web Frameworks such as Django, FastAPI, Pyramid, Flask etc to design and develop web based applications.

○ Desktop GUI Programming
- Python supports GUI applications that can be installed and run locally on systems like Windows, Linux, iOS etc.
- Python provides Tk GUI library to develop user interface in python based application.
- Some other useful toolkits wxWidgets, Kivy, pyqt that are useable on several platforms. The Kivy is popular for writing multitouch applications.

○ BigData and Data Science -
- Python and Big Data is an inseparable combination when we consider a programming language for big data development phase. Being Open Source, wide community, and a huge library, its best suited for Big Data projects.
- Python has become the number 1 language in Data Science projects.
- Some important packages Pandas, Numpy, SciPy, Theano, Scikit-learn, etc provide everything that a developer needs to work on Big Data and machine learning projects.
- PySpark is also an example of its use.
- Compatible with Hadoop. As Python big data is compatible, similarly Hadoop and big data are synonymous with each other. Hence, Python has been made inherently compatible with Hadoop to work with big data. Python consists of Pydoop package which helps in accessing HDFS API and also writing Hadoop MapReduce programming. Besides that Pydoop enables MapReduce programming to solve complex big data problems with minimal effort.
- An example is IBM using python, they even have a Python SDK for Watson, and they use python extensively.
- Netflix, Spotify use extensively for their recommendation and analytics engine.

○ Console Based Application - We can use Python to develop console based applications. IPython is the best example for this.

○ Multimedia Applications - Python is awesome to perform multiple tasks and can be used to develop audio and video applications.

○ Python is can also be used to develop
- 3D CAD Applications
- Enterprise Applications
- Image Processors and editors

There are several such applications which can be developed using Python
What is the output of the following program :
`print('cd'.partition('cd'))`
Anonymous Quiz
21%
('cd')
11%
('')
30%
('', 'cd', '')
10%
('cd', '')
28%
Show me the answer.
print("""A
B
C """=="A\nB\nC\n") #What is the output?
Anonymous Quiz
24%
True
18%
False
28%
Syntax Error
11%
ABC
10%
Invalid Statement
8%
Show me the answer!
Python Questions pinned «About our channel You can find * Tasks for Beginners, * Interview Questions, * Simple coding problems, * Quiz etc. You can use our group ———»»» @python_programmers_club for discussing regarding the posts or sharing your knowledge. Our Partner Channels:…»
#answer to the question 👆is ————-»»» Dict

Q: Which is faster in performance while searching around a million records plus?

To clarify, both Set and Dict perform search quite fast due to both Set & Dict being implemented using hashtables.
However, Dict performs marginally better compared to Set, but when compared to List or tuple, the difference is huge.
x = 1.3 + 2.3
print(x == 3.6)
# what is the output? Can you explain?
Anonymous Quiz
15%
3.6
63%
True
14%
False
2%
1.3
1%
2.3
6%
Show me the answer
Which of the following functions will return an iterable object in Python 3+ ?
Anonymous Quiz
11%
len()
10%
ord()
16%
xrange()
44%
range()
8%
None of the above
11%
Show me the answer
x, y, z = 5, 10, 15
z = x <= y
#What is the value of z? Explain why
Anonymous Quiz
11%
5
18%
15
34%
True
26%
False
5%
None of the above
7%
Show me the answer
#interviewQuestions : 0010

Q: What is a Namespace in Python?

A namespace is basically a system to make sure that all the names of each and every object in a Python program are unique and can be used without any conflict.

You might already know that everything in Python like strings, lists, functions, etc. is an object. Python implements namespaces as dictionaries. There is a name-to-object mapping, with the names as keys and the objects as values. Multiple namespaces can use the same name and map it to a different object. Here are a few examples of namespaces:

Local Namespace: This namespace includes local names inside a function. This namespace is created when a function is called, and it only lasts until the function returns.

Global Namespace: This namespace includes names from various imported modules that you are using in a project. It is created when the module is included in the project, and it lasts until the script ends.

Built-in Namespace: This namespace includes built-in functions and built-in exception names.
"=".join(['1', '2', '4', '8', '16'])

# What is the output. Explain Why?
Anonymous Quiz
15%
1 2 4 8 16
12%
1, 2, 4, 8, 16
44%
1=2=4=8=16
17%
1=,2=,4=,8=,16=
6%
None of the above
7%
Show me the answer
Which of the following operators has the lowest precedence?
Anonymous Quiz
28%
not
12%
and
13%
**
28%
+
18%
%
y, z = 10, 15
y *= y + z
# What is the value of y. Explain How?
Anonymous Quiz
5%
10
5%
15
15%
25
21%
115
44%
250
5%
None of the above
6%
Show me the answer
min("abCD123!")

# What is the output and WHY?
Anonymous Quiz
12%
a
5%
C
16%
1
15%
!
26%
abCD123!
16%
None of the above
11%
Show me the answer
#interviewQuestions : 0011

Q: Explain the following assignment?

x, y, z = 5, 10, 15
a = b = c = 0

a = x - z
x -= z

b = y - y + z
y -= (y + z)
print(b, y)

15 -15

Notice
the result in the here, it should be 15 and 15, but the value of y is -15.
Do you know why?
When the statements are evaluated, the statements are evaluated from left to right. But before that, anything within the braces are executed first.

So, in the first statement, since there is no curly braces, it first executes y - y and the result + z, this becomes 15
In the second statement, the expression within curly braces is executed, which is y + z, which comes to 25 and then now the expression becomes y -= 25, which is same as y = y- 25, hence the result -15.
#interviewQuestions : 0012

What is PYTHONPATH?

PYTHONPATH is an environment variable can be set, to add additional directories where python will look for modules and packages.

Whenever a module is imported, PYTHONPATH is also looked up to check for the presence of the imported modules in various directories. The interpreter uses it to determine which module to load.

For most installations, you should not set these variables since they are not needed for Python to run. Python knows where to find its standard library.

The only reason to set PYTHONPATH is to maintain directories of custom Python libraries that you do not want to install in the global default location (i.e., the site-packages directory).
#interviewQuestions : 0013

What are python modules?

Python modules are files containing Python code.

A module can define functions, classes and variables. A module can also include runnable code. Grouping related code into a module makes the code easier to understand and use.
x = [3,1,2]
What is the output of x [1:-1]? Explain Why?
Anonymous Quiz
13%
3,1,2
13%
3,1
30%
1,2
28%
1
10%
None of the above
6%
Show me the answer
Which of the following programming styles does Python support?
Anonymous Quiz
7%
Functional
9%
Procedural
30%
Object Oriented
50%
All of the above
4%
Show me the answer
print('abcefd'.replace('cd', '12'))

#What is the output of the above code?
Anonymous Quiz
28%
ab1ef2
14%
ab12ef12
4%
ab1efd
3%
abcef2
22%
abcefd
21%
None of the above
7%
Show me the answer
x = 5,000.00

#What is the value of x. Explain Why?
Anonymous Quiz
8%
5
2%
(5)
8%
(5,0.0)
22%
5000
7%
(5000)
29%
5000.00
14%
(5,000.00)
9%
Show me the answer