Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Introduction to Python

>> Python is a widely used general-purpose, high level programming language. It was created by Guido van
Rossum in 1991 and further developed by the Python Software Foundation. It was designed with an emphasis
on code readability, and its syntax allows programmers to express their concepts in fewer lines of code.

>> Arthimetic operators in Python

Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication
and division.
There are 7 arithmetic operators in Python :
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Modulus
6. Exponentiation
7. Floor division

1. Addition Operator : In Python, + is the addition operator. It is used to add 2 values.
2. Subtraction Operator : In Python, – is the subtraction operator. It is used to subtract the second
value from the first value.
3. Multiplication Operator : In Python, * is the multiplication operator. It is used to find the product of 2
values.
4. Division Operator : In Python, / is the division operator. It is used to find the quotient when first
operand is divided by the second.
5. Modulus Operator : In Python, % is the modulus operator. It is used to find the remainder when first
operand is divided by the second.
6. Exponentiation Operator : In Python, ** is the exponentiation operator. It is used to raise the first
operand to power of second.
7. Floor division : In Python, // is used to conduct the floor division. It is used to find the floorof the
quotient when first operand is divided by the second.

>> Introduction to IDLE

In IDLE we write code line by line. One line will handle one thing. You type whatever you
want in that line and press enter to execute it. IDLE works more like a terminal or command
prompt - You write one line, press enter, it executes.

We can also create python file which will contain the complete multiline program and can
execute that using IDLE as well. A python script has an extension .py.

Python takes some time to compile, its compilation is not fast, thus writing the example code
in a file, then compiling the whole code again and again gets tedious and is not suited for
beginners. When we open the IDLE, a session is created, which saves all the lines of code that
you write and execute in that one window as a single program. This is the reason why, what
you wrote above may affect what you will write later, eg. using a variable. Here is a preview
of how we will be typing in IDLE.
>> String Operations in Python

A string is a sequence of characters.

A character is simply a symbol. For example, the English language has 26 characters.

Computers do not deal with characters, they deal with numbers (binary). Even though you may see
characters on your screen, internally it is stored and manipulated as a combination of 0s and 1s.

This conversion of character to a number is called encoding, and the reverse process is decoding. ASCII
and Unicode are some of the popular encodings used.

In Python, a string is a sequence of Unicode characters. Unicode was introduced to include every character
in all languages and bring uniformity in encoding. You can learn about Unicode from Python Unicode.

>> LIST

The list is a most versatile datatype available in Python which can be written as a list of comma-separated values
(items) between square brackets. Important thing about a list is that items in a list need not be of the same type.

>> Tuple in Python

A tuple is a collection of objects which ordered and immutable. Tuples are sequences, just like lists. The differences
between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use
square brackets.

You might also like