1. Python
PYTHON IS AN INTERPRETED, OBJECT-ORIENTED, HIGH-LEVEL
PROGRAMMING LANGUAGE WITH DYNAMIC SEMANTICS. ITS
HIGH-LEVEL BUILT IN DATA STRUCTURES, COMBINED WITH
DYNAMIC TYPING AND DYNAMIC BINDING, MAKE IT VERY
ATTRACTIVE FOR RAPID APPLICATION DEVELOPMENT, AS WELL
AS FOR USE AS A SCRIPTING OR GLUE LANGUAGE TO CONNECT
EXISTING COMPONENTS TOGETHER. PYTHON’S SIMPLE, EASY TO
LEARN SYNTAX EMPHASIZES READABILITY AND THEREFORE
REDUCES THE COST OF PROGRAM MAINTENANCE.
2. Variables in python
A variable is a name given to a memory location. It is the
basic unit of storage in a program.
The value stored in a variable can be changed during
program execution.
A variable is only a name given to a memory location, all
the operations done on the variable effects that memory
location.
3. Data types in python
It represents the kind of value that tells what operations can be
performed on a particular data.
Python has many native data types. Here are the important ones:
Booleans are either True or False.
Numbers can be integers (1 and 2), floats (1.1 and 1.2), fractions
(1/2 and 2/3), or even complex numbers.
Strings are sequences of Unicode characters, e.g. an HTML
document.
4. Bytes and byte arrays, e.g. a JPEG image file.
Lists are ordered sequences of values.
Tuples are ordered, immutable sequences of values.
Sets are unordered bags of values.
5. Python operator
There are there types of operators –
1.Arithmetic Operator
2.Relational operator
3.Logical operator
1.Arithmetic operator- Arithmetic operators are used with numeric
values to perform common mathematical operations:
8. 3.Logical operator-
Logical operators are used on conditional statements (either True or False). They perform
Logical AND, Logical OR and Logical NOT operations.
9. Python tokens
All statements and instructions in a program are built with
tokens. The various tokens in python are :
1. Keywords
2. Identitiers
3. Literals
4. Operators
10. 1.Keywords: -Keywords are words that have some special meaning or significance in a
programming language. They can’t be used as variable names, function names, or any
other random purpose.
2.Identifiers: Identifiers are the names given to any variable, function, class, list, methods,
etc. for their identification. Python is a case-sensitive language and it has some rules
and regulations to name an identifier
3.Literals or Values: Literals are the fixed values or data items used in a source code.
11. Data structures in Python
The basic Python data structures in Python include list, set,
tuples, and dictionary. Each of the data structures is unique in
its own way. Data structures are “containers” that organize and
group data according to type.
12. Tuple in python
Tuples are used to store multiple items in a single variable.
Tuple is one of 4 built-in data types in Python used to store collections of data, the other 3
are List, Set, and Dictionary, all with different qualities and usage.
A tuple is a collection which is ordered and unchangeable.
Tuples are written with round brackets.
13. Basics operations in tuples-Tuples respond to
the + and * operators much like strings; they
mean concatenation and repetition here too,
except that the result is a new tuple, not a string.
15. List in python -
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.
Creating a list is as simple as putting different comma-
separated values between square brackets. For example −
list1 = [‘physics’, ‘chemistry’, 1997, 2000]; list2 = [1, 2, 3, 4, 5 ];
list3 = [“a”, “b”, “c”, “d”];
16.
17. Given below are some of the most widely used list operations in Python:
A few of the basic list operations used in Python programming are extend(), insert(),
append(), remove(), pop(), slice, reverse(), min() & max(), concatenate(), count(),
multiply(), sort(), index(), clear(), etc.
myList = [1, 2, 3, ‘EduCBA’, ‘makes learning fun!’]
1. append()-
The append() method is used to add elements at the end of the list. This method can only
add a single element at a time. To add multiple elements, the append() method can be
used inside a loop.
Code:
My list.append(4)
18. 2. extend()
The extend() method is used to add more than
one element at the end of the list. Although it
can add more than one element, unlike
append(), it adds them at the end of the list like
append().
Code:
myList.extend([4, 5, 6])
for I in range(7, 9):
myList.append(i)
print(myList)
19. 3. insert()-
The insert() method can add an element at a given position in the list. Thus,
unlike append(), it can add elements at any position, but like append(), it can
add only one element at a time. This method takes two arguments. The first
argument specifies the position, and the second argument specifies the
element to be inserted.
Code:
myList.insert(3, 4)
myList.insert(4, 5)
myList.insert(5, 6)
print(myList)
20.
21. Sets
Sets are used to store multiple items in a single variable.
Set is one of 4 built-in data types in Python used to store collections of data, the other 3
are List, Tuple, and Dictionary, all with different qualities and usage.
A set is a collection which is unordered, unchangeable*, and unindexed.
22. Dictionary in python-
Sets are used to store multiple items in a single variable.
Set is one of 4 built-in data types in Python used to store collections of data, the other 3
are List, Tuple, and Dictionary, all with different qualities and usage.
A set is a collection which is unordered, unchangeable*, and unindexed.
Dictionaries are written with curly brackets, and have keys and values
23. Looping statement-
If we want to execute a group of statements multiple times, then we should go for a
looping kind of execution. There are two types of loops available in python. They are:
1.while loop
2.for loop
1.While loop- A "While" Loop is used to repeat a specific block of code
an unknown number of times, until a condition is met.
2.For loop- for loops are used when you have a block of code which you want to
repeat a fixed number of times.
24. Conclusion-
It is manifest that Python is a robust, high-level programming
language with easy-to-read code lines. Its extensive support and
power have made Python a superior programming language across
the globe. It has gained importance across the globe as computer
giant Google has made it one of its official programming languages.