1] What type of language is python? Programming or scripting?
 Python is capable of scripting, but in general sense, it is considered as a general-purpose programming language.
2] What is pep 8?
 PEP stands for Python Enhancement Proposal. It is a set of rules that specify how to format Python code for maximum readability.
3] What is namespace in Python?
 A namespace is a naming system used to make sure that names are unique to avoid naming conflicts.
4] What are python modules? Name some commonly used built-in modules in Python?
 Python modules are files containing Python code. This code can either be functions classes or variables. A Python module is a .py file containing executable code.Some of the commonly used built-in modules are:
• os
• sys
• math
• random
• data time
5] What are local variables and global variables in Python?
 Global Variables:
• Variables declared outside a function or in global space are called global variables. These variables can be accessed by any function in the program.
 Local Variables:
• Any variable declared inside a function is known as a local variable. This variable is present in the local space and not in the global space.
6] What are Python libraries? Name a few of them.
 Python libraries are a collection of Python packages. Some of the majorly used python libraries are – Numpy, Pandas, Matplotlib, Scikit-learn
7] Does python support multiple inheritance?
 Multiple inheritance means that a class can be derived from more than one parent classes. Python does support multiple inheritance, unlike Java.
8] Define encapsulation in Python?
 Encapsulation means binding the code and the data together. A Python class in an example of encapsulation.
9] What does an object () do?
 It returns a featureless object that is a base for all classes. Also, it does not take any parameters.
10] What is Python?
 Python is one of the most successful interpreted languages. When you write a Python script, it doesn’t need to get compiled before execution. Few other interpreted languages are PHP and JavaScript.
11] What are the benefits of using python?
 Python is a dynamic-typed language. It means that you don’t need to mention the data type of variables during their declaration. It allows to set variables like var1=101 and var2 =” You are an engineer.” without any error.
 Python supports object orientated programming as you can define classes along with the composition and inheritance. It doesn’t use access specifiers like public or private).
 Functions in Python are like first-class objects. It suggests you can assign them to variables, return from other methods and pass as arguments.
 Developing using Python is quick but running it is often slower than compiled languages. Luckily, Python enables to include the “C” language extensions so you can optimize your scripts.
 Python has several usages like web-based applications, test automation, data modelling, big data analytics and much more. Alternatively, you can utilize it as a “glue” layer to work with other languages.
12] What are the built-in types available in Python?
 Immutable built-in data types of Python
• Numbers
• Strings
• Tuples
 Mutable built-in data types of Python
• List
• Dictionaries
• Sets
13] When is the Python decorator used?
 Python decorator is a relative change that you do in Python syntax to adjust the functions quickly.
14] How many basic types of functions are available in Python?
 Python gives us two basic types of functions.
• Built-in, and
• User-defined.
The built-in functions happen to be part of the Python language. Some of these are print (), dir (), len (), and abs () etc.
15] What is the return keyword used for in Python?
 The purpose of a function is to receive the inputs and return some output. The return is a Python statement which we can use in a function for sending a value back to its caller.
16] What is the return value of the trunk () function?
 The Python trunk () function performs a mathematical operation to remove the decimal values from a particular expression and provides an integer value as its output.
17] When should you use the break in Python?
 Python provides a break statement to exit from a loop. Whenever the break hits in the code, the control of the program immediately exits from the body of the loop. The break statement in a nested loop causes the control to exit from the inner iterative block.
18] What is whitespace in Python?
 Whitespace represents the characters that we use for spacing and separation. They possess an empty representation. In Python, it could be a tab or space.
19] What is isalpha () in Python?
 Python provides this built-in isalpha () function for the string handling purpose. It returns true if all characters in the string are of alphabet type, else it returns False.
20] What makes the C Python different from Python?
 C Python has its core developed in C. The prefix ‘C’ represents this fact. It runs an interpreter loop used for translating the Python-ish code to C language.
21] Which package is the fastest form of Python?
 PyPy provides maximum compatibility while utilizing C Python implementation for improving its performance.
 The tests confirmed that PyPy is nearly five times faster than the C Python. It currently supports Python 2.7.
22] What is GIL in Python language?
 Python supports GIL (the global interpreter lock) which is a mutex used to secure access to Python objects, synchronizing multiple threads from running the Python byte codes at the same time.
23] How does Python manage the memory?
 Python implements a heap manager internally which holds all of its objects and data structures. This heap manager does the allocation/de-allocation of heap space for objects.
24] What is the set object in Python?
 Sets are unordered collection objects in Python. They store unique and immutable objects. Python has its implementation derived from mathematics.
25] What are Errors and Exceptions in Python programs?
 Errors are coding issues in a program which may cause it to exit abnormally.
 Exceptions happen due to the occurrence of an external event which interrupts the normal flow of the program.
26] What is the difference between an Iterator and Iterable?
 The collection type like a list, tuple, dictionary, and set are all iterable objects whereas they are also iterable containers which return an iterator while traversing.
27] What does the “self” keyword do?
 The self is a Python keyword which represents a variable that holds the instance of an object. In almost, all the object-oriented languages, it is passed to the methods as a hidden parameter.
28] What is the purpose of docstrings in Python?
 In Python, the docstring is what we call as the docstrings. It sets a process of recording Python functions, modules, and classes.
29] How do you debug a program in Python? Is it possible to step through the Python code?
 Yes, we can use the Python debugger (pdb) to debug any Python program. And if we start a program using pdb, then it let us even step through the code.
30] List down some of the PDB commands for debugging Python programs?
 Add breakpoint (b)
 Resume execution (c)
 Step by step debugging (s)
 Move to the next line (n)
 List source code (l)
 Print an expression (p)
31] What does the yield keyword do in Python?
 The yield keyword can turn any function into a generator. It works like a standard return keyword. But it’ll always return a generator object. Also, a method can have multiple calls to the yield keyword.
32] What is Rstrip () in Python?
 Python provides the rstrip () method which duplicates the string but leaves out the whitespace characters from the end.
 The rstrip () escapes the characters from the right end based on the argument value, i.e., a string mentioning the group of characters to get excluded.
33] What does the ord () function do in Python?
 The ord(char) in Python takes a string of size one and returns an integer denoting the Unicode code format of the character in case of a Unicode type object, or the value of the byte if the argument is of 8-bit string type.
34] What does the Chr () function do in Python?
 It returns the string denoting a character whose Unicode code point is an integer.
 For example, the Chr (122) returns the string ‘z’ whereas the Chr (1212) returns the string ‘Ҽ’.
35] What does the len () function do in Python?
 In Python, the len () is a primary string function. It determines the length of an input string.
36] What is the difference between pass and continue in Python?
 The continue statement makes the loop to resume from the next iteration.
 The pass statement instructs to do nothing, and the remainder of the code executes as usual.
37] How is memory managed in Python?
 Memory in Python is managed by Python private heap space. All Python objects and data structures are located in a private heap. This private heap is taken care of by Python Interpreter itself, and a programmer doesn’t have any access to this private heap.
 Python memory manager takes care of the allocation of Python private heap space.
 Memory for Python private heap space is made available by Python’s inbuilt garbage collector which recycles and frees up all the unused memory.
38] What is a dictionary in Python?
 Python dictionary is one of the supported data types in Python. It is an unordered collection of elements. The elements in dictionaries are stored as key–value pairs. Dictionaries are indexed by keys.
39] How will you reverse a list in Python?
 list.reverse (): This function reverses objects of list.
40] What are split (), sub (), and subn () methods in Python?
 Split (): This method is used to split a given string into a list.
 Sub (): This method is used to find a substring where a regex pattern matches and then it replaces that matched substring with a different string.
 Subn (): This method is similar to the sub () method, but it also returns the new string, along with the number of replacements.
41] What do you understand by Tkinter?
 Tkinter is an inbuilt Python module that is used to create GUI applications. It’s Python’s standard toolkit for GUI development.
 Tkinter comes with Python, so there is no installation needed. We can start using it by importing it in our script.
42] What is the difference between append () and extend () methods?
 Both append () and extend () methods are methods used for lists. These methods are used to add elements at the end of a list.
 Append (element): Adds the given element at the end of the list which called this method
 Extend (another-list): Adds the elements of another-list at the end of the list which called the extend method
43] Do we need to declare variables with data types in Python?
 No. Python is a dynamically typed language, which means that Python Interpreter automatically identifies the data type of a variable based on the type of value assigned to the variable.
44] How will you read a random line in a file?
 We can read a random line in a file using a module named ‘random’.
45] How is Python executed?
 Python files are compiled to byte code. Which is then executed by the host.
46] How do you execute a Python Script?
From the command line, type python .py or pythonx.y
.py where the x.y is the version of the Python interpreter desired.
47] What is the lambda operator?
 The lambda operator is used to create anonymous functions. It is mostly used in cases where one wishes to pass functions as parameters. Or assign them to variable names.
48] What are the two major loop statements?
 for and while
49] How does the Python version numbering scheme work?
 Python versions are numbered A.B.C or A.B.
• A is the major version number. It is only incremented for major changes in the language.
• B is the minor version number, incremented for less earth-shattering changes.
• C is the micro-level. It is incremented for each bug fix release.
50] What Are The Implementation In Python Program?
 Python program can be implemented by two ways
• Interactive Mode (Submit statement by statement explicitly).
• Batch Mode (Writing all statements and submit all statements)
Pranjali sawaikar

Write A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.