Python V
Python V
Python V
Python
PYTHON
• Python is a widely used general-purpose, easy to learn, multiplatform high
level programming language.
• It was initially designed by Guido van Rossum in 1991 and developed by
Python Software Foundation.
• Python is very easy to learn and understand
• Python is a high level programming language that contains features of
functional programming language like C and object oriented programming
language like java.
• Pythons elegant syntax and dynamic programming, together with its
integrated nature, make it an ideal language for scripting and rapid
application development in many areas in most platforms.
PYTHON
Python is a high level programming language which is:
❑ Interpreted
❑ Interactive
❑ Object-Oriented
❑ One-Line command
❑ Dynamically Typed
❑ Easily Indentable
❑ Intuitive data structures like tuples, sets, dictionaries, strings, lists etc
APPLICATION OF PYTHON
Python language used in:
– Web Development
– Database programming
– Game Development
– Scientific Computing
– Web Framework
– Molecular Biology
STRUCTURE OF PYTHON
# comment line(single)
“”” This is a
multiline comment
in python
“””
# Import statements
# Global Variables
# Class definitions
# Function definitions
# sample program
a=15
b=16
print(a+b)
LITERALS
• literals are a notation for representing a fixed value in source code. They can
also be defined as raw value or data given in variables or constants.
• Types of literals
✓ String literals
✓ Numeric literals
✓ Boolean literals
COMMENTS
• Single line comments
• To put single line comments in code, use # symbol
• Multiline comments
• To put multiline comments in code enclose the comment statements with triple
Quotes ‘’’ or “””
Example
# This is a single line comment
“””
This is a
Multiline comment
“””
STRING DATATYPE
ARITHMETIC OPERATORS
Examples
• A<6 and B>10
• A<10 or B<8
• Not(A<6 and B>10)
TERNARY OPERATOR
• Ternary operators are more commonly known as conditional expressions
in Python. These operators evaluate something based on a condition being true or
not.
Syntax
[on_true] if [expression] else [on_false]
Example
>>> x, y = 5, 6
>>> print("x" if x> y else "y")
y
• There are two types of
identity operators in python:
❑ Is – Returns true if both
variables are the same
object
❑ Is Not – Returns true if
both variables are not the
same object
LISTS
• A list in python is an ordered group of items or elements, and these list
elements don’t have to be of the same type.
• Python lists are mutable objects that can change their values.
• A list contains items separated by commas and enclosed within square
brackets.
• List indexes like strings starting at 0 in the beginning of the list and working
their way from -1 at the end.
• Similar to strings, Lists operations include slicing ([ ] and [:]), concatenation
(+), repetition(*), membership(in).