0% found this document useful (0 votes)
13 views7 pages

What Is Python

Python is a versatile programming language created by Guido van Rossum in 1991, used for web development, software development, mathematics, and system scripting. It features a simple syntax, dynamic typing, and can run on various platforms, making it accessible for both beginners and professionals. Python supports multiple programming paradigms and has built-in data types, allowing for efficient handling of data and operations.

Uploaded by

sexyblackman09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

What Is Python

Python is a versatile programming language created by Guido van Rossum in 1991, used for web development, software development, mathematics, and system scripting. It features a simple syntax, dynamic typing, and can run on various platforms, making it accessible for both beginners and professionals. Python supports multiple programming paradigms and has built-in data types, allowing for efficient handling of data and operations.

Uploaded by

sexyblackman09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

What is Python?

Python is a popular programming language. It was created by Guido van Rossum, and
released in 1991.

It is used for:

● web development (server-side),


● software development,
● mathematics,
● system scripting.

What can Python do?


● Python can be used on a server to create web applications.
● Python can connect to database systems. It can also read and modify files.
● Python can be used to handle big data and perform complex mathematics.

Why Python?
● Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
● Python has a simple syntax similar to the English language.
● Python has syntax that allows developers to write programs with fewer lines than
some other programming languages.
● Python runs on an interpreter system, meaning that code can be executed as soon
as it is written. This means that prototyping can be very quick.
● Python can be treated in a procedural way, an object-oriented way or a functional
way.

Why is Python different from other languages?


● Python stands out from other programming languages due to its clean and
readable syntax, making it easy to learn and use.
● It's a high-level, interpreted language, meaning you can run code directly without
needing to compile it, which speeds up development.
● Python’s dynamic typing allows you to write code without declaring variable types,
adding to its simplicity. With an extensive standard library, Python provides tools
for almost any task, from web development to data analysis.
● It's cross-platform, running on various operating systems, and supported by a
vast community that offers numerous resources.
● Python's versatility and ease of use make it a top choice for beginners and
professionals alike.

Execute Python Syntax


Python syntax can be executed by writing directly in the Command Line:
>>> print("Hello, World!")
Hello, World!

Or by creating a python file on the server, using the .py file extension, and running it in
the Command Line:

C:\Users\Your Name>python [Link]

Python Indentation
Indentation refers to the spaces at the beginning of a code line.

Where in other programming languages the indentation in code is for readability only, the
indentation in Python is very important.

Python uses indentation to indicate a block of code.

Python Comments
Comments can be used to explain Python code.

Comments can be used to make the code more readable.

Comments can be used to prevent execution when testing code.

Creating a Comment
Comments starts with a #, and Python will ignore them

#This is a comment
This comments for a single line.

Multiline Comments
Python does not really have a syntax for multiline comments.

To add a multiline comment you could insert a # for each line:

#This is a comment
#written in
#more than just one line

Python Variables
Variables are containers for storing data values.
Creating Variables
Python has no command for declaring a variable.

A variable is created the moment you first assign a value to it.

Variable is define by user.

Example
X=5

Y = ” hello ”

X is our variable

Variable name should start with letter(a-zA-Z) or underscore (_)

Valid : age , _age , Age

Invalid : 1age

In variable name, no special characters allowed other than underscore (_).

Valid : age_ , _age

Invalid : age_*

Variables are case sensitive. age and Age are different, since variable names are case
sensitive.

Variable name can have numbers but not at the beginning.

Example: Age1

Variable name should not be a Python [Link] are also called as reserved
words.
Example pass, break, continue.. etc are reserved for special meaning in Python. So, we
should not declare keyword as a variable name.

Python Data Types


In programming, data type is an important concept.
Variables can store data of different types, and different types can do different things.

Python has the following data types built-in by default, in these categories:

Text Type: str

Numeric Types: int, float, complex

Sequence Types: list, tuple, range

Mapping Type: dict

Set Types: set, frozenset

Boolean Type: bool

Binary Types: bytes, bytearray, memoryview

None Type: NoneType

1. int - holds signed integers of non-limited length.


2. long- holds long integers(exists in Python 2.x, deprecated in Python 3.x).
3. float- holds floating precision numbers and it’s accurate up to 15 decimal places.
4. complex- holds complex numbers.
5. str -it holds the string value examples:- “jhon”,”reva”
6. List- it is the collection of data .
7. Tuple - it is also used for collection of data.
8. Dict-it used to store the value in key : value pair.
9. Bool -boolean represent the one of two values: True or False
10. Binary Types-bytes, bytearray, memoryview

Getting the Data Type


You can get the data type of any object by using the type() function:
x = “hello”
print(x)
print(type(x))

Python Numbers
There are three numeric types in Python:

Int type

X=2

Float type

Y=2.3

Complex type

Z= 2+2j

How to check the type


X=2

print(type(x))

y=2.6

print(type(y))
y=4+6j

print(type(y))

Type conversion (type casting)


Type casting is used to convert int to float ,float to int and so on .

Example:-

X=2

Y= 2.4

Z=1+5j

print("Before conversion")

print(type(X))

print(type(Y))

print(type(Z))

print("After conversion")

A= float(X)

print(A)

print(type(A))

B= float(Y)

print(B)

print(type(B))

C= complex(Z)

print(C)

print(type(C))

You might also like