Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

1. Who is founder of the python? 10. In which language python is written?

Guido van Rossum is a Dutch programmer best The complete script of Python is written in the C
known as the creator of the Python programming Programming Language.
language.

11. What Does it Mean that Python is Written in C?


2. What is Python? The interpretation of Python code is made in a C
Python is a widely-used general-purpose, high-level compiler. That's why Python is sometimes also
programming language. referred to as CPython.

3. Why is Python so popular? 12. What is PYTHONPATH?


Python is one of the most popular languages It is an environment variable which is used when a
because it is considered one of the easiest and module is imported. The interpreter uses it to
understandable languages. determine which module to load.

4. How Python got its name? 13. What is Python used for?
When he began implementing Python, Guido van Python is commonly used for developing websites
Rossum was also reading the published scripts from and software, task automation, data analysis, and
“Monty Python's Flying Circus”, a BBC comedy data visualization.
series from the 1970s. Van Rossum thought he
needed a name that was short, unique, and slightly
mysterious, so he decided to call the language 14. What can you do with python?
Python. Data analysis, machine learning, web development,
automation, scripting, Software testing and
prototyping
5. Why Python is invented?
It was mainly developed for emphasis on code
readability, and its syntax allows programmers to 15. What is Python shell?
express concepts in fewer lines of code. Python shell is the interpreter that executes your
python programs, other pieces of python code or
simple commands.
6. Who is the mother of Python?
Python, sometimes written Pytho, presided at the 16. How to clear shell in python?
Delphic oracle, which existed in the cult center for We can simply use Ctrl + l to clear the screen.
its mother, Gaia, "Earth", Pytho being the place
name that was substituted for the earlier Krisa. 17. What is indentation in python?
Indentation refers to the spaces at the beginning of
a code line
7. What does Python run on?
Python is a cross-platform programming language, 18. What is indentation used for?
which means that it can run on multiple platforms Provides readers with a sense of continuity.
like Windows, macOS, Linux.
19. How many types of Indentation?
Three types of indentation are present.
8. How many types of Python language are there?
There are four main Python coding styles: 20. What are the three types of indentation?
imperative, functional, object-oriented, and Normal indents, 1st line Indentation and hanging
procedural. indents.

21. What is the indentation symbol?


9. What was python weakness? Paragraph mark
Simplicity: Python is a simple programming
language which is also the biggest disadvantage. 22. How do I print Indentation in Python?
Four whitespaces are normally used for
indentation.
23. How many spaces is an indent python? 38. Which data type is used for gender?
4 spaces as default indentation spaces. Qualitative variable.

24. How do you show indent? 39. Which datatype is used to store a whole number?
Go to home and select line and paragraph spacing. Integer data type
Line spacing options at the bottom of the menu.
40. What is range of data type?
25. What is 0.5 indent? -32768 to +32767
Place the cursor at the start of a paragraph and hit
the tab key on your keyboard. 41. Which data types takes maximum bytes?
Maximum number of bytes that can be stored in a
26. What is normal indent size? VARCHAR
No smaller than the current point size.
42. What is tuple?
27. How do restart python shell? Tuple is an ordered set of values.
Press the f5 key on keyboard.
43. What are long data types?
28. What is the difference b/w python shell and Long datatype is 64-bit two’s complement integer.
interpreter?
The shell is where you write your code directly in 44. What are data units?
the CLI, whereas the interpreter is the program that Decimal unit such as KB, MB, GB used to express
will interpret your code and execute. size of data.

45. What is string in Data types?


29. How do run a python shell? An array data structure of bytes that stores a
Subprocess. Popen() sequence of elements, characters.

30. Is shell a syntax. 46. What are the operands that are permitted with
The shell is a command language interpreter logical operators in Python?
We have three different logical operators which are
31. What are Data types in Python? supported by python, and they are, logical AND,
A data type is a set of values and set of operation. logical OR & logical NOT.

32. Different data types in python? 47. What is the difference between “is” and “ == “ in
Mutable data Type (List, set, Dictionary) Python?
Immutable Data Type (Number, string, Tuples) == operator is used in python to check for value
equality of both the operands whereas is an
33. Which type of data type is python number? operator is used to express whether the two
It is immutable data type, which is used to store operands are pointing towards the same object or
numeric value. not.

34. Why we use Data types? 48. What does == mean in Python?
Because it ensures that data is collected in the == is a python comparison operator. It is mainly
preferred format & value of each property is as used to check whether the values of two operands
expected are equal or not.

35. What is the size of int data types? 49. What is operator precedence in Python?
Int & unsigned int types have size of four bytes. Operator precedence is a predetermined order
used to resolve the problem called multiple
36. Which data type is faster in python? operations at a single time.
Dictionaries is fast data types.
50. Which operator has the highest precedence in
37. Is array a data type? Python?
Array is a data types that represents a collection of () parentheses have the highest precedence in
elements. python.
51. Which operator has the lowest precedence Python? Lists are used to store multiple items in a single
Logical OR has the lowest precedence in python. variable. Lists are created using square brackets.

52. What is Floor Division Python? 62. What are characteristics of List?
The Floor Operator is used to make a division that List are ordered, mutable and, allow duplicate
results in the whole number adjusted to the left in members
the number line.
63. What methods are performed on List?
53. Is there a "not equal" operator in Python? There are many methods performed on list append,
Yes! We have Not equal operator in python, and it clear, copy, court, pop, remove, index, reverse etc.
is used to compare two operands and returns True
statement if they are Not equal, and False if they 64. What is the use of append method?
are Equal. It adds an element at the end of the list

54. What does <> mean in Python? 65. What is the used of index method?
!= or <> both symbols are used for expressing the It returns the index of the first element with the
not equal. specified value.

55. When programming in Python operators with the 66. What do you mean by traversing a list?
same precedence are evaluated in which manner? Traversing means to access each element of list
When two python operators have the same
precedence, you use associativity to determine the 67. What do you mean by Concatenation in list?
order. Almost all operators have associativity of left Concatenation of list means combining the two list.
to right.
68. What is difference between indexing and slicing?
56. How many types of operations are supported by By indexing we can extract only one element of list
the Python language? while by slicing we can fetch a Sub list from main
Python language supports the following types of list.
operations.
• Arithmetic operations 69. Define Tuple.
• Comparison (i.e. Rotational) operations A collection of ordered and immutable objects is
• Assignment operations known as a tuple
• Logical operations
• Bitwise operations 70. What methods are performed on tuple?
• Membership operations Count (), index ()
• Identity operations.
71. What is a nested tuple?
57. What do you mean by statement in Python? A tuple Inside another tuple is called a nested tuple.
A statement is an instruction that the Python
interpreter can execute. 72. What is difference b/w lists and tuples?
Lists are mutable and Tuples are immutable.
58. Explain Operators and Operands?
Operators are special symbols that represent 73. Explain the function len() in Tuple.
computations like addition and multiplication. The len() returns the no. of elements of the tuple.
values the operator uses are called Operands
74. How we Can remove list element?
59. How are comments written in a program? To remove a list element, you can use either the del
In Python, comment start with ‘#’ symbol. Anything statement or the remove method.
written after # in a line is ignored by interpreter.
75. What is the use of count() method in tuple?
60. Explain assigning values to variables in Python. It Returns the number of times a specified value
The equal sign (=) is used to assign values to occurs in a tuple.
variables.
76. Add a list of elements to a set.
61. What is List? Sample_set = {1, 2, 3}
Sample_List=[4,5] Only the Dictionary 's keys will exist in the returned
set.
77. Return a new set of identical items from two sets.
Set1 = {10, 20, 30} 91. What is function?
Set2 = {30, 40, 20} Functions are nothing but a group of related
Paint (set1. intersection (Set2)) statements that perform a specific task.

78. Get only unique items from two sets. 92. Difference between user-defined and built-in
Set1 = {10, 20, 30, 40, 50} functions.
Set2 = {30, 40, 50, 60, 70} • User-Defined Functions - these types of functions
Print (Set1.union (Set 2)) are defined by the user to perform any specific task
• Built-in Functions - These are pre-defined
79. Remove items from the set at once. functions in python.
Set1 ={10, 20, 30, 40, 50}
Set2.difference- update ({10, 20, 30}) 93. What keyword is used for defining a function and
Print(set1) write the syntax.
‘def’ keyword is used for defining a function.
80. What is a set? Syntax: def function_name(parameters)
A set is an unordered collection of unique objects.
Duplicate values are removed when any object is 94. What is Lambda function?
converted to set. Functions that are anonymous un-named function.

81. What is the difference between a subset and a 95. What is Recursive function?
proper Subset? Functions that calls itself is known as recursive.
A proper subset is a subset of a set, not equal to
itself. 96. What are the main advantages of function?
Main advantages of functions are
82. Check if a set is proper Subset. i) It avoids repetition and makes high degree of
We can check if a set is a proper subset of another. code reusing.
set using the ‘<’ operator. ii) It provides better modularity for your
application.
83. What is a dictionary?
Dictionary is a set of key Value pairs, with each pair 97. What is meant by scope of variable? Mention its
being Unique. types.
Scope of variable refers to the part of the program,
84. Are Dictionaries case-sensitive? where it is accessible. The two types of
Yes. dictionaries are Case-sensitive scopes - local scope and global scope.

85. Are Dictionaries Mutable? 98. Define global scope.


Yes, the Python dictionary is Mutable object. A variable, with global scope can be used anywhere
in the program. It can be created by defining a
86. Is it possible to find the length of a dictionary. variable outside the scope of any function/block.
yes, len() can provide length for dictionary too.
99. Mention the type of arguments used to call a
87. How to get a key of dictionary function.
Dictionary comes with keys() method that provides The following are the types of arguments that we
all list of all the keys in dictionary. can use to call a function:
1. Default arguments
88. How to get a value of dictionary? 2. Keyword arguments
Print(user_info.values()) 3. Required arguments
4. Variable-length arguments
89. How to get by and value of a dictionary?
Print (user_info.items()) 100. What are the default arguments? Explain in brief.
A default argument is a kind of parameter that
90. What is the result of passing a dictionary to a set takes as input a default value, if no value is supplied
constructor? for the argument when the function is called.
101. What are the Keyword Arguments? 113. What is the value of x if x = math.factorial(0)?
A keyword argument is where we provide a name Factorial of 0 is 1.
to the variable as we pass it into the function.
114. What are the types of modules in Python?
102. What is lambda function? Define its syntax. Modules in Python can be of two types: Built-in
A lambda function is a small anonymous function. Modules, User-defined Modules.
Example: x = lambda a : a + 10
115. What are Python modules used for?
103. What is the difference between void function and A module aims at developing a clearly identifiable
fruitful function? and certifiable portion of the curriculum, expressed
A fruitful function can also return multiple values. in terms of competence objectives.
Void functions are those that do not return any
value 116. What are basic modules?
Basic modules are those that send altered or
104. Define syntax for calling the function. entirely new requests to the crawler and register
def myFun(): call backs to handle the responses.
print("Hello World")
print(" Welcome to the Python") 117. How do modules work?
myFun() # Call Function to print the message A module is a function or group of similar functions.
They are grouped together within a file and contain
105. What are the types of Variable-length arguments? the code to execute a specific task when called into
There are two types: a larger application.
1. Non - Keyworded Arguments (*args)
2. Keyworded Arguments (**kwargs) 118. CAN modules have objects?
A module, just like any other object, can be bound
106. Define non-keyworded arguments. to a variable, an item in a container, or an attribute
*args: Receive multiple arguments as a tuple of an object.

107. Define keyworded arguments (**kwargs). 119. What is the mod symbol?
**kwargs: Receive multiple keyword arguments as Modulo is a math operation that finds the
a dictionary. remainder when one integer is divided by another.

108. Describe a module. 120. What is a collection of modules?


The term “module” refers to the implementation of Packages are a collection of related modules
specific functionality to be incorporated into a stacked up together.
program.
121. How are modules connected?
109. Tell about top-down design process. Module to-module connections are usually in the
Top-down design is an approach for deriving a form of plates that are bolted on site.
modular design in which the overall design.
122. Is a module a library?
110. What is the order of namespaces in which Python A module is basically a single purpose library.
looks for an identifier?
Python first searches for the local, then the global 123. What is a module in python?
and finally the built-in namespace. Module refers to the implementation of specific
functionality to be incorporated into a program.
111. Is the output of the function abs() the same as that
of the function 124. What do you mean by client of the module?
sometimes... because math.fabs() always returns a Program code making use of a given module is
float and does not work with complex numbers called the client of the module.
whereas the return type of abs() is determined by
the type of value that is passed to it. 125. In top-down design every module is broken into
same number of submodules. Is it true?
112. What is the value returned by math.fact(6)? False.
NameError, fact() is not defined.
126. Extension of the Python file? A class is a way of binding data members and
.py member function together, class is a template for
the object.
127. What does pip stand for python?
Preferred Installer Program. 139. What are class members? How do you define it?
Variables defined inside a class are called as class
128. Definition for packages in Python? variable and functions are called as methods. Class
A folder of python programs is called as a package variable & methods are together known as
of modules. members of the class members

129. The process of pickling in Python includes: 140. What is instantiation?


Pickling is the process of sterilizing a Python object, The process of creating object is called
that is, conversion of a byte stream into Python Instantiation.
object hierarchy. The reverse of this process is
known as unpickling. 141. Name of the method which is automatically
executed when an object is created?
130. The module _______________ is a comparatively __init__()
faster implementation of the pickle module.
The module cPickle is a comparatively faster 142. Declaration of a class:
implementation of the pickle module. class class_name:

131. The copy module uses the ___________________ 143. Define object?
protocol for shallow and deep copy. An object represents an entity in the real world that
The copy module uses the pickle protocol for can be distinctly identified.
shallow and deep copy.
144. What is used to create an object?
132. In which direction is the turtle module pointed by Constructor
default?
By default, the turtle is pointed towards the east 145. The assignment of more than one function to a
direction. particular operator is called
Operator overloading
133. Which Python module is used to parse dates in
almost any string format? 146. The class methods in python are:
dateutil module Static, bounded and unbounded methods.

134. Name of 5-packages of Python? 147. What are the methods which begin and end with
NumPy, pandas, Seaborn, Requests, Pillow. two underscore characters are called.
Special methods. (Special methods are
135. If you work with image data which package you automatically called during object creation)
must require in python?
If you work with image data, make sure to check 148. what is setattr() used for?
out the Pillow package. setattr(obj, name, valere) is used to set an
attribute. If attribute doesn’t exit, then it would be
136. Python package uses for drawing attractive created.
statistical graphics?
Seaborn is a high-level interface for drawing 149. getattr() used for?
attractive statistical graphics with just a few lines of getattr(obj, name) is used to get the attribute of an
code. object.

137. Which package uses If you work with tabular, time 150. What is the operator through which class members
series, or matrix data? are accessed?
If you work with tabular, time series, or matrix data, dot operator
pandas is your go-to Python package.
151. A class may contain:
138. what is class? Attribute, methods, properties, constructor and
instance attributes.
152. hasattr() is used for? An abstract clan is crated to declare a set of
hasattr checks if an attribute exists or not and methods that must be created in any child class
return True or False. build on top of this abstract class.

153. What is the syntax of hiding data in python. 165. What is the purpose of abstract methods?
_variablename Abstract methods force the child class to give the
implementation of these methods in them and the
154. Which feature of python disconnects objects within help us achieve abstraction on each subclass can
class from useless data to hide. irrelevant give its own implementation.
information from end user.
Data hiding 166. Write syntax to create an abstract class in python.
from abc impout ABC
155. State advantage of data hiding. Class <abstract_class_name>(ABC):
Makes application more secure & more robust.
Prevent Creation of links to Wrong data. 167. Define function overriding in Python.
If you want is override the parent class method,
156. Define method overriding in python. create a function in the child with the same name
It is an ability of any OOP language that allows a and no of parameter. It is called function overriding.
subclass or child close to prove a specific
implementation of a method that is already 168. How many except statements can a try-except
provided by one of its super class a parent class block have?
There has to be at least one except statement.
157. State condition when method in subclass is said to
override the method in superclass. 169. When will the else part of try-except-else be
When method in subclass has same name same executed?
parameter or signature and same section type The else part is executed when no exception occurs.

158. What determines that which version of an 170. Can one block of except statements handle multiple
overridden method will be execution exception?
The type of object which is being refered Each type of exception can be specified directly.
determines that which version of an overridden There is no need to put it in a list.
method will be executed.
171. When is the finally block executed?
159. How parent's method can be called within The finally block is always executed.
overridden method
Using class name 172. What happens when ‘1’ == 1 is executed?
Using supper() It simply evaluates to False and does not raise any
exception.
160. When feature of python defends access to specific
users in the application? 173. What will be the output of the following Python
Data Hiding code?
lst = [1, 2, 3]
161. How data hiding in python performed? lst[3]
It is performed using the double underscore(__) The snippet of code shown above throws an index
before done prefix. error. This is because the index of the list given in
the code, that is, 3 is out of range. The maximum
162. Which proves helps to build a large and index of this list is 2.
complicated programs.
Data abstraction 174. What will be the output of the following Python
code, if the time module has already been
163. How abstraction to implemented? imported?
Abstraction to implemented using a abstract class. 4 + '3'
The line of code shown above will result in a type
164. Why abstract class is created in Python? error. This is because the operand ‘+’ is not
supported when we combine the data types ‘int’
and ‘str’. Sine this is exactly what we have done in 185. Which of the following geometry managers are
the code shown above, a type error is thrown. available in Tkinter?
.grid()
175. What will be the output of the following Python
code? 186. Config() in python Tkinter are used for?
int('65.43') To change the property of the widget
The snippet of code shown above results in a value
error. This is because there is an invalid literal for 187. Creating lines are come in which type of thing?
int() with base 10: ’65.43’. Canvas

176. Which of the following is not a standard exception 188. For user entry data, which widget we use in
in Python? Tkinter?
NameError, IOError and ValueError are standard Text
exceptions in Python whereas Assignment error is
not a standard exception in Python. 189. For what purpose, the bg is used in the Tkinter
widget?
177. Syntax errors are also known as parsing errors. To change the background of the widget
Syntax errors are known as parsing errors. Syntax
errors are raised when there is a deviation from the 190. How we import Tkinter in the python program?
rules of a language. Hence the statement is true. import Tkinter, import Tkinter as t, from Tkinter
import *
178. _______________________ exceptions are raised
as a result of an error in opening a particular file. 191. Title() is used for
IOError exceptions are raised as a result of an error Give a title name to the window
in opening or closing a particular file.
192. What is Tk() in Tkinter python?
179. Which of the following blocks will be executed It is a widget, function, constructor
whether an exception is thrown or not?
The statements in the finally block will always be 193. What is work of turtle.shape() function in Python?
executed, whether an exception is thrown or not. This function is used to set the turtle shape to
This clause is used to close the resources used in a shape with a given name or, if the name is not
code. given, return the name of the current shape.

180. Which of the following is an Arithmetic Exception? 194. Why is turtle graphics important?
Over Flow Error, Zero Division Error, Floating Point Turtle graphics are a great way to introduce kids to
Error coding. With short programs of just five to ten lines
of code, kids can create and modify while learning.
181. In python code, on encountering a syntax error, the 195. Why do you require to setup Python turtle screen?
_______________ does not execute the program. Because it uses tkinter for the underlying graphics,
During this initial step of program execution, also it needs a version of Python installed with Tk
known as parsing, the interpreter will look for any support.
incorrect syntax in python. on encounting a syntax
error, the Interpreter does not execute the 196. What is the command for Turtle installation?
program. pip install PythonTurtle

182. Which exception is raised when the index or 197. What is the use of Turtle() method?
subscript in a sequence is out of range? It Creates and returns a new turtle object.
IndexError
198. What is testing in python?
183. In python context, what does GUI stand for? Automated testing is the execution of your test plan
Graphical User Interface by a script instead of a human. Python already
comes with a set of tools and libraries.
184. Which of the following are valid Tkinter widgets?
button 199. What is the Python unit test?
Unit testing is a technique in which particular The unittest module produces three possible
module is tested to check by developer himself outcomes- OK, Failure and Error
whether there are any errors.
212. What are the Advance Testing Scenario?
200. What does test cases mean in python? Generate necessary input Execute the code, taking
A test case is a set of conditions which is used to the output. Match the output with an expected
determine whether a system under test works result.
correctly.

201. What is the purpose of testing?


Two purposes of testing: verifying procurement
specifications and managing risk

202. Why testing is important in python?


Goal of python unit testing is to detect as many
bugs and inconsistencies in the infancy of the
application development as possible.

203. What are types of unit testing?


There are 2 types of Unit Testing: Manual, and
Automated.

204. How do I test a function in Python?


First you need to create a test file. Then import the
unittest module, define the testing class that
inherits from unittest. TestCase, and lastly, write a
series of methods to test all the cases of your
function's behavior.

205. What is scope of testing?


The scope of a test defines what areas of a
customer's product are supposed to get tested,
what functionalities to focus on, what bug types the
customer is interested in, and what areas or
features should not be tested by any means.

206. What are the best Python Testing Frameworks?


Robot,PyTest,Unittest,DocTest,Nose2,Testify.

207. How to test a variable in Python?


Python doesn't have a specific function to test
whether a variable is defined.

208. How do you write test cases?


Keep things straightforward and basic,Create
reusable test scenarios,Keep the test case IDs
separate and Peer review is crucial.

209. Which tool is used for testing?


Test Management Tool,Configuration management
tool,Static Analysis Tools,etc.

210. Is Selenium a testing tool?


Selenium is the leading testing tool for web apps.

211. What are the outcome of unittest module?

You might also like