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

Que 1. What Is Python?: 1) Easy To Learn and Use

Python is an interpreted, object-oriented, and high-level programming language with dynamic semantics. It interprets code at runtime and garbage collects memory automatically. Python supports procedural, object-oriented, and functional programming styles. It has a large standard library and supports GUI programming. Python code is also easy to read and maintain.

Uploaded by

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

Que 1. What Is Python?: 1) Easy To Learn and Use

Python is an interpreted, object-oriented, and high-level programming language with dynamic semantics. It interprets code at runtime and garbage collects memory automatically. Python supports procedural, object-oriented, and functional programming styles. It has a large standard library and supports GUI programming. Python code is also easy to read and maintain.

Uploaded by

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

Que 1. What is Python?

Python Language is Object-Oriented. It focuses on objects, and combines data


and functions. Contrarily, a procedure-oriented language revolves around
functions, which are code that can be reused. Python supports both procedure-
oriented and object-oriented programming which is one of the key python
features.

Feachers:

1) Easy to Learn and Use


Python is easy to learn and use. It is developer-friendly and high level programming
language.

2) Expressive Language
Python language is more expressive means that it is more understandable and
readable.

3) Interpreted Language
Python is an interpreted language i.e. interpreter executes the code line by line at a
time. This makes debugging easy and thus suitable for beginners.

4) Cross-platform Language
Python can run equally on different platforms such as Windows, Linux, Unix and
Macintosh etc. So, we can say that Python is a portable language.

5) Free and Open Source


Python language is freely available at official web address. The source-code is also
available. Therefore it is open source.

6) Object-Oriented Language
Python supports object oriented language and concepts of classes and objects come
into existence.

7) Extensible
It implies that other languages such as C/C++ can be used to compile the code and
thus it can be used further in our python code.

8) Large Standard Library


Python has a large and broad library and provides rich set of module and functions
for rapid application development.

9) GUI Programming Support


Graphical user interfaces can be developed using Python.

10) Integrated
It can be easily integrated with languages like C, C++, JAVA etc.
Uses of python:

1. Applications:
Python can be used to develop different applications like web applications, graphic user

interface based applications, software development application, scientific and numeric

applications, network programming, Games and 3D applications and other business

applications. It makes an interactive interface and easy development of applications.

2. Multiple Programming paradigms:


Python is also used because of its providing continuous support to several programming

paradigms. As it supports object-oriented programming and structured programming. Python

has features, which also support various concepts of functional programming language. It is

used for dynamic type system and automatic memory management. Python language features

and programming paradigms allow you for developing the small as well as large applications. It

can be used for complex software applications.

3. Robust Standard Library:


Python has a large and robust standard library to use for developing the applications. It also

makes the developers use Python over other languages. The standard library helps in using the

different range of modules available for Python. As this module helps you in adding the

functionality without writing any more code. To get the information about various modules,

documentation on python standard library can be referred. While developing any web

application, implementing web services, performing string operations and other usages like

interface protocol, the standard library documentation helps.


4. Compatible with Major Platforms and Systems:
Python is mainly compatible with major platforms and systems because of which it is used

mainly for developing applications. With help of python interpreters, python code can be run on

specific platforms and tools as it supports many operating systems. As python is an interpreted

high-level programming language and it allows you to run the code on multiple platforms. The

new and modified code can be executed without recompiling and its impact can be monitored

or checked. It means it’s not required to recompile the code after every change. This feature

helps in saving the development time of the developers.

5. Access of Database:
Uses of Python also helps in accessing the database easily. Python helps in customizing the

interfaces of different databases like MySQL, Oracle, Microsoft SQL Server, PostgreSQL, and

other databases. It has an object database like Durus and ZODB. It is used for standard

database API and freely available for download.

6. Code Readability:
Python code is easy to read and maintained. It is easily reusable as well wherever it is required.

Python’s having simple syntax, which allows the different concepts to develop without writing

any additional code. The code should be of good quality and easy to maintain the source code

and simplify the maintenance, which is required to develop the software application. It also

emphasizes code readability, which is the great feature, unlike other programming languages. It

helps in building custom applications and clean code helps in maintaining and updating the

software applications without putting extra effort on the same code.


7. Simplify Complex Software Development:
Applications of Python is used to simplifying the complex software development process as it is

a general-purpose programming language. It is used for developing the complex application

like scientific and numeric application, and for both desktop and web applications. Python has

features like analyzing data and visualization, which helps in creating custom solutions without

putting extra effort and time. It helps you to visualize and present data in an effective way.

8. Many Open Source Frameworks and Tools:


Python is open source and easily available. This also helps in costing the software

development significantly. There are many open source applications of python frameworks,

libraries, and development tools for developing the application without putting extra cost.

Python frameworks simplify and make the process faster for web application development and

the frameworks are Django, Flask, pyramid etc. Python GUI frameworks are available for

developing the GUI based application.

9. Adopt Test Driven Development:


Python makes coding easier as well as testing with help of adopting Test Driven Development

approach. The test cases can be easily written before any code development. Whenever the

code development started, the written test cases can start testing the code simultaneously and

provides the result. These can also be used for checking or testing the pre-requirements based

on the source code.

10. Other applications for which python is used:


There are other applications for which python is used that are Robotics, web scraping, scripting,

artificial intelligence, data analysis, machine learning, face detection, color detection, 3D CAD
applications, console-based applications, audio-based applications, video-based applications,

enterprise applications, and applications for Images etc. These are some major applications

used.

Que 2. Explain python shell?

It means it executes the code line by line. Python provides a Python Shell (also known

as Python Interactive Shell) which is used to execute a single Python command and get the

result. Python Shell waits for the input command from the user.

Python is an interpreter language. It means it executes the code line by line.

Python provides a Python Shell (also known as Python Interactive Shell) which is

used to execute a single Python command and get the result.

Python Shell waits for the input command from the user. As soon as the user enters
the command, it executes it and displays the result.

To open the Python Shell on Windows, open the command prompt,


write python and press enter.

As you can see, a Python Prompt comprising of three Greater Than symbols (>>>)
appears. Now, you can enter a single statement and get the result. For example,
enter a simple expression like 3 + 2, press enter and it will display the result in the
next line.

Que 3. What is string? How work on string slicing?

A string in Python is a sequence of characters. Strings are immutable. This means


that once defined, they cannot be changed.

Python slice()

The slice() constructor creates a slice object representing the set of indices specified by
range(start, stop, step). The slice object is used to slice a given sequence (string,
bytes, tuple, list or range) or any object which supports sequence protocol (implements
__getitem__() and __len__() method).
The slice object is used to slice a given sequence (string, bytes, tuple, list or range) or any
object which supports sequence protocol (implements __getitem__() and __len__() method).
Slice object represents the indices specified by range(start, stop, step).

The syntax of slice() are:

slice(stop)

slice(start, stop, step)

slice() Parameters

slice() mainly takes three parameters which have the same meaning in both constructs:

 start - starting integer where the slicing of the object starts


 stop - integer until which the slicing takes place. The slicing stops at index stop - 1.
 step - integer value which determines the increment between each index for slicing
If a single parameter is passed, start and step are set to None.

Que 4.How to define comments in python?

Single-line comments are created simply by beginning a line with the hash (#) character, and
they are automatically terminated by the end of line. Comments that span multiple lines – used
to explain things in more detail – are created by adding a delimiter (“””) on each end of
the comment.
When working with any programming language, you include comments in the code to notate
your work. This details what certain parts of the code are for, and lets other developers – you
included – know what you were up to when you wrote the code. This is a necessary practice,
and good developers make heavy use of the comment system. Without it, things can get real
confusing, real fast.
How to Write Comments in Python
In Python, there are two ways to annotate your code.
The first is to include comments that detail or indicate what a section of code – or snippet –
does.
The second makes use of multi-line comments or paragraphs that serve as documentation for
others reading your code.
Think of the first type as a comment for yourself, and the second as a comment for others.
There is not right or wrong way to add a comment, however. You can do whatever feels
comfortable.
Single-line comments are created simply by beginning a line with the hash (#) character, and
they are automatically terminated by the end of line.
For example:

#This would be a comment in Python

Que 5.Write a short note on print function ?

The print() function prints the specified message to the screen, or other standard
output device. The message can be a string, or any other object, the object will be
converted into a string before written to the screen.

Syntax
print(object(s), separator=separator, end=end, file=file, flush=flush)

Example

Print more than one object:

print("Hello", "how are you?")

How print() works in Python?


 'separator is used. Notice, the space between two objects in output.
 end parameter '\n' (newline character) is used. Notice, each print statement displays
the output in the new line.
 file is sys.stdout . The output is printed on the screen.
 flush is False .

print() Parameters
 objects - object to the printed. * indicates that there may be more than one object
 sep - objects are separated by sep. Default value: ' '
 end - end is printed at last
 file - must be an object with write(string) method. If omitted it, sys.stdout will be used which
prints objects on the screen.
 flush - If True, the stream is forcibly flushed. Default value: False

Que 6. What are numbers system in python?


In Python, number data types are used to store numeric values. There are four different
numerical types in Python: int (plain integers): this one is pretty standard --
plain integers are just positive or negative whole numbers. long (long integers):
long integers are integers of infinite size.

In any OOP language, there are many different data types. In Python, number data types are
used to store numeric values. There are four different numerical types in Python:

1. int (plain integers): this one is pretty standard -- plain integers are just positive or
negative whole numbers.
2. long (long integers): long integers are integers of infinite size. They look just like plain
integers except they're followed by the letter "L" (ex: 150L).
3. float (floating point real values): floats represent real numbers, but are written with
decimal points (or scientific notation) to divide the whole number into fractional parts.
4. complex (complex numbers): represented by the formula a + bJ, where a and b are
floats, and J is the square root of -1 (the result of which is an imaginary number).
Complex numbers are used sparingly in Python.
5. Python supports integers, floating point numbers and complex numbers. They are
defined as int, float and complex class in Python.

6. Integers and floating points are separated by the presence or absence of a decimal
point. 5 is integer whereas 5.0 is a floating point number.

7. Complex numbers are written in the form, x + yj, where x is the real part and y is the
imaginary part.

Que 8. What are operators used in python?

1. Arithmetic operators: Arithmetic operators are used to perform mathematical


operations like addition, subtraction, multiplication and division.
OPERATOR DESCRIPTION SYNTAX

+ Addition: adds two operands x+y

- Subtraction: subtracts two operands x-y

* Multiplication: multiplies two operands x*y

/ Division (float): divides the first operand by the second x/y

// Division (floor): divides the first operand by the second x // y


% Modulus: returns the remainder when first operand is divided by the second x%y

2. Relational Operators: Relational operators compares the values. It either


returns True or False according to the condition.

OPERATOR DESCRIPTION SYNTAX

> Greater than: True if left operand is greater than the right x>y

< Less than: True if left operand is less than the right x<y

== Equal to: True if both operands are equal x == y

!= Not equal to - True if operands are not equal x != y

>= Greater than or equal to: True if left operand is greater than or equal to the right x >= y

<= Less than or equal to: True if left operand is less than or equal to the right x <= y

3. Logical operators: Logical operators perform Logical AND, Logical OR and Logical
NOT operations.

OPERATOR DESCRIPTION SYNTAX

and Logical AND: True if both the operands are true x and y

or Logical OR: True if either of the operands is true x or y

not Logical NOT: True if operand is false not x


1. Bitwise operators: Bitwise operators acts on bits and performs bit by bit
operation.
OPERATOR DESCRIPTION SYNTAX

& Bitwise AND x&y

| Bitwise OR x|y

~ Bitwise NOT ~x

^ Bitwise XOR x^y

>> Bitwise right shift x>>

<< Bitwise left shift x<<

Que 9.What is data structure in Python?

Data Structures (list, dict, tuples, sets, strings) . The built ins data structures are: lists,
tuples, dictionaries, strings, sets and frozen sets. Lists, strings and tuples are ordered
sequences of objects. Unlike strings that contain only characters, list and tuples can
contain any type of objects.
There are quite a few data structures available. The builtins data structures are:
lists, tuples, dictionaries, strings, sets and frozensets.
Lists, strings and tuples are ordered sequences of objects. Unlike strings that
contain only characters, list and tuples can contain any type of objects. Lists and
tuples are like arrays. Tuples like strings are immutables. Lists are mutables so
they can be extended or reduced at will. Sets are mutable unordered sequence of
unique elements whereas frozensets are immutable sets.
Lists are enclosed in brackets:
l = [1, 2, "a"]
Tuples are enclosed in parentheses:
t = (1, 2, "a")
Tuples are faster and consume less memory. See Tuples for more information.
Dictionaries are built with curly brackets:
d = {"a":1, "b":2}.

You might also like