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

Python

Uploaded by

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

Python

Uploaded by

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

Python

What is python?

 Python is a popular programming language. Which is developed


by guido van rossum in 1991.

Why python is popular?

 Because python can handle big data and can do complex


calculations.
 It is used for software and web development.
 Python can work on different platforms like – windows, mac, linux
etc.
 Syntax of python is as simple as English language.
 Developer can write the syntax with very fewer lines which makes
the code more readable.

Indentation:-

In python indentation is very important because indicates a block of


code.

Indentation refers to the space in beginning of a code line.

In a block of code space should be atleast one.

For ex:-
if 5 > 2:
print("Five is greater than two!")
You have to use same no of space in same block of code to avoid error.
if 5 > 2:
print("Five is greater than two!")
print("Five is greater than two!")

Comments:-

Comments are used to explain the python code.

This made the code more readable.

Comments are of two types single line comment and multi line
comments.

Comments are mentioned by # sign .

Ex:-
#This is a comment
print("Hello, World!")
And
#This is a comment
#written in
#more than just one line
print("Hello, World!")
We can also use triple quotes in a multiline string which is not assigned
to a variable.
"""
This is a comment
written in
more than just one line
"""
print("Hello, World!")

Variables:-

Variable are containers for storing data value . A variable is created


when you assigned a value in it. Variables are case sensitive.

Ex:-
x = 5
y = "John"
print(x)
print(y)

By using casting method you can data type of a variable.

Ex:-
x = str(3) # x will be '3'
y = int(3) # y will be 3
z = float(3) # z will be 3.0
Conditions to create a variable:-

 A variable name must start with a letter or the underscore character


 A variable name cannot start with a number
 A variable name can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ )
 Variable names are case-sensitive (age, Age and AGE are three different
variables)

For Ex:-
myvar = "John"
my_var = "John"
_my_var = "John"
myVar = "John"
MYVAR = "John"
myvar2 = "John"

Data type:-

A form of data which is stored in a variable is called data type.


 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

You might also like