Python Developer Reference Questions - .
Python Developer Reference Questions - .
Answer:
It is very simple and easy to learn.
It powerful, fast and secure.
It has very simple syntax.
It is powerful scripting language.
It can be run on different kind of platform like Windows, Mac, Linux, etc.
Web Application
Software Development
Business Applications
Independent Platform
Object oriented
Flexible
Structure oriented
Portable
Simple
9. What is comment?
Answer:
Python comments are statements that are not executed by the compiler.
It is not considered as a part of program.
Arithmetic operators
Relational operators
Logical operators
Assignment operators
Bit-wise operators
Membership operators
Identity operators
print('me' in 'disappointment')
# o/p: True
31. How to print the star (*) pattern without newline and space?
Answer:
print('*', end="")
32. How will you create the following pattern using Python?
Answer:
**
***
****
Output:
for i in range(1,6):
for j in range(1,i+1):
print('*',end='')
print('\n')
List
Sets
Dictionaries
Immutable:
Strings
Tuples
Numbers
e = list1.count(3)
S = "ABCD"
print(len(S))
tuple *= 2
print(tuple)
o/p:
b = (1)
print(type(b))
b = (1,)
print(type(b))
Arrays:
Homogeneous
Lists:
Heterogeneous
word = 'abcdefghij'
word[:3] + word[3:]
The output is abcdefghij. The first slice gives us abc, the next gives us defghij.
S = "ABCD"
print(S.lower())
print('SystECh'.swapcase())
o/p: sYSTecH
Break: Allows loop termination when some condition is met and the control is
transferred to the next statement.
Continue: Allows skipping some part of a loop when some specific condition is met
and the control is transferred to the beginning of the loop.
Pass: Used when you need some block of code syntactically, but you want to skip its
execution. This is basically a null operation. Nothing happens when this is executed.
NumPy
Pandas
Matplotlib
scikit-learn
73. What are some of the most commonly used built-in modules in Python?
Answer:
Python modules are the files having python code which can be functions, variables or
classes. These go by .py extension.
The most commonly available built-in modules are:
os
random
datetime
sys
math
print(X(2,4))
Private variable
Public variable
Protected variable
1. Opening of file.
5. Closing of file.
This opens the file in writing mode. You should close it once you’re done.
file.close()
import time
time.sleep(5)
print("This message will be printed after a wait of 5 seconds")
Mismatched input
1. Arithmetic Error
2. Import Error
3. Index Error
Arithmetic Error: Acts as a base class for all arithmetic exceptions. It is raised for
errors in arithmetic operations.
Import Error: Raised when you are trying to import a module which does not
present. This kind of exception occurs if you have made a typing mistake in the
module name or the module which is not present in the standard path.
Index Error: Raised when you try to refer a sequence which is out of range.
first = [1, 2, 3, 4, 5]
second = first
second.append(6)
print(first)
print(second)
o/p:
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]
os.remove(filename)
os.unlink(filename)