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

What Is Python

Uploaded by

rameshdreamweb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

What Is Python

Uploaded by

rameshdreamweb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

● What is Python?

A) Python is an interpreted, high-level, general-purpose programming


language. The significant feature of Python Programming Language is its
code readability. Python is open source, which makes it free to use and
distribute.
● What are the advantages of using Python?
A) Python is mainly used for the following:
i. Extensive Support Libraries like Numpy, Pandas etc.
ii. Dynamically typed Language,
iii. High Level Language,
● What is an Interpreted Language?
A) An Interpreted Language is the one which executes most of its instructions
directly without the need to compile. Python is a good Example of Interpreted
Language.
● What is PEP 8?
A) PEP stands for Python Enhancement Proposal. PEP 8 is the style guide for
writing elegant python code. It consists of set of rules to enhance the
readability of Python code.
● What is pickling and unpickling?
A) Pickling or serialization is the process in which Python object hierarchy is
converted into byte stream. dumps() function is used to serialize object
hierarchy. Unpickling or de-serialization is the process in which the byte
stream is converted into Python Object Hierarchy. loads() function is used to
deserialize the byte stream.
● Is Python case sensitive?
A) Yes. Python is a case sensitive language.
● How type conversion is handled in Python?
A) int() – converts any data type into integer type
float() – converts any data type into float type
ord() – converts characters into integer
hex() – converts integers to hexadecimal
oct() – converts integer to octal
tuple() – This function is used to convert to a tuple.
set() – This function returns the type after converting to set.
list() – This function is used to convert any data type to a list type.
dict() – This function is used to convert a tuple of order (key,value) into a
dictionary.
str() – Used to convert a datatype into a string.
complex(real,imag) – This functionconverts real numbers to
complex(real,imag) number.
● What is __ init __?
A) __ init __ is a constructor function in python. This function is automatically
called when a new object / instance is created.
● What is self in Python?
A) self represents the instance/object of a class. By using 'self' keyword, we
are sending the calling the particular instance of a class.
● How do you write comments in Python?
A) Comments in Python starts with #. We can also comment using docstrings
(strings enclosed with triple quotes).
● How will you convert a string to all lowercase in Python?
A) using lower() function.
Eg:
s = 'ABCD'
print(s.lower())
● What are the supported data types in Python?
A) Python has 5 standard data types

i. Numbers
ii. Strings
iii. List
iv. Tuples
v. Dictionary
● What are the Tuples in Python?
A) Tuples are immutable collection of values enclosed in parenthesis. They
can be thought of as read-only lists.
● What is a list in Python?
A) List is a mutable collection of values enclosed in square braces. They can
be appended with additional values.
● What is the difference between tuples and lists in Python?
A) List is enclosed in square braces -[] where as tuples are enclosed in curly
braces List is mutable and tuple is immutable.
● What does ** operator do?
A) Performs exponential calculation. 2**3 is similar to 2 to the power of 3, i.e.
8.
● How to check if all the characters in a string are digits?
A) using isDigit() function.
● How to initialize an array with zeros?
A) a = array('i', (0 in range(4)))
● How to reverse a list?
A) list.reverse()
● What is an incomplete function called?
A) Stub
● Does python has a compiler?
A) Yes. Python has a compiler which compiles automatically.'
● What are dictionaries in Python?
A) Dictionaries are similar to hashtable type. They contains key-value pairs.
Dictionaries usually consists of numbers and strings but can be of any type.

You might also like