SlideShare a Scribd company logo
Introduction to Python
Programming
Python
Printing Messages on Screen
Reading input from console
Python Identifiers and Keywords
Data types in Python
Operators
Using math library function
ï‚— Developed by GuidoVan Roussum in
1991.
ï‚— Python is processed at runtime by
the interpreter.
ï‚— There is no need to compile your
program before executing it.
ï‚— Python has a design philosophy that
emphasizes code readability.
Hello World Program
mohammed.sikander@cranessoftware.com 4
>>> print(‘Hello’)
>>> print(‘Welcome to Python Programming!')
Print Statement
#Python 2.x Code #Python 3.x Code
print "SIKANDER"
print 5
print 2 + 4
SIKANDER
5
6
The "print" directive prints contents to console.
 In Python 2, the "print" statement is not a function,and therefore it is invoked
without parentheses.
 In Python 3, it is a function, and must be invoked with parentheses.
(It includes a newline, unlike in C)
 A hash sign (#) that is not inside a string literal begins a comment.
All characters after the # and up to the end of the physical line are part of the
comment and the Python interpreter ignores them.
print("SIKANDER")
print(5)
print(2 + 4)
Output
Python Identifiers
ï‚— Identifier is the name given to entities like class, functions, variables etc.
ï‚— Rules for writing identifiers
ï‚— Identifiers can be a combination of letters in lowercase (a to z) or
uppercase (A to Z) or digits (0 to 9) or an underscore (_).
ï‚— An identifier cannot start with a digit.
ï‚— Keywords cannot be used as identifiers.
ï‚— We cannot use special symbols like !, @, #, $, % etc. in our identifier.
Python Keywords
ï‚— Keywords are the reserved words in Python.
ï‚— We cannot use a keyword as variable
name, function name or any other identifier.
ï‚— They are used to define the syntax and structure of the
Python language.
ï‚— keywords are case sensitive.
ï‚— There are 33 keywords in Python 3.3.
Keywords in Python programming language
False class finally is return
None continue for lambda try
True def from nonlocal while
and del global not with
as elif if or yield
assert else import pass
break except in raise
All the keywords except True, False and None are in
lowercase
PythonVariables
ï‚— A variable is a location in memory used to store
some data (value).
ï‚— They are given unique names to differentiate
between different memory locations.The rules
for writing a variable name is same as the rules
for writing identifiers in Python.
ï‚— We don't need to declare a variable before using
it.
ï‚— In Python, we simply assign a value to a variable
and it will exist.
ï‚— We don't even have to declare the type of the
variable.This is handled internally according to
the type of value we assign to the variable.
Variable assignment
ï‚— We use the assignment operator (=) to
assign values to a variable.
ï‚— Any type of value can be assigned to any
valid variable.
Multiple assignments
ï‚— In Python, multiple assignments can be made in
a single statement as follows:
If we want to assign the same value to multiple
variables at once, we can do this as
x = y = z = "same"
Data types in Python
ï‚— Every value in Python has a datatype.
ï‚— Since everything is an object in Python
ï‚— Data types are actually classes and variables are
instance (object) of these classes.
ï‚— Numbers
ï‚— int
ï‚— float
 String – str
ï‚— Boolean - bool
Type of object – type()
ï‚— type() function can be used to know to
which class a variable or a value belongs
to.
Reading Input
Python 2.x Python 3.x
ï‚— print("Enter the name :")
ï‚— name = raw_input()
ï‚— print(name)
ï‚— print("Enter the name :")
ï‚— name = input()
ï‚— print(name)
If you want to prompt the user for input, you can use raw_input in Python 2.X, and
just input in Python 3.
ï‚— name = input("Enter the name :")
 print(“Welcome “ + name)
ï‚¡ Input function can print a prompt and
read the input.
Arithmetic Operators
Operator Meaning Example
+ Add two operands or unary plus x + y
+2
- Subtract right operand from the left or
unary minus
x - y
-2
* Multiply two operands x * y
/ Divide left operand by the right one
(always results into float)
x / y
% Modulus - remainder of the division of left
operand by the right
x % y (remainder of x/y)
// Floor division - division that results into
whole number adjusted to the left in the
number line
x // y
** Exponent - left operand raised to the
power of right
x**y (x to the power y)
Arithmetic Operators
What is the output
ï‚— Data read from input is in the form of string.
ï‚— To convert to integer, we need to typecast.
ï‚— Syntax : datatype(object)
Exercise
ï‚— Write a program to calculate the area of
Circle given its radius.
 area = πr2
ï‚— Write a program to calculate the area of
circle given its 3 sides.
ï‚— s = (a+b+c)/2
 area = √(s(s-a)*(s-b)*(s-c))
Given the meal price (base cost of a meal), tip percent (the percentage of
the meal price being added as tip), and tax percent (the percentage of
the meal price being added as tax) for a meal, find and print the
meal's total cost.
Input
12.00 20 8
Output
The total meal cost is 15 dollars.
ï‚— Temperature Conversion.
ï‚— Given the temperature in Celsius, convert
it to Fahrenheit.
ï‚— Given the temperature in Fahrenheit,
convert it to Celsius.
Relational operators
ï‚— Relational operators are used to compare values.
ï‚— It returns True or False according to condition
Operator Meaning Example
>
Greater that - True if left operand is greater than the
right
x > y
< Less that - True if left operand is less than the right x < y
== Equal to - True if both operands are equal x == y
!= Not equal to - True if operands are not equal x != y
>=
Greater than or equal to - True if left operand is
greater than or equal to the right
x >= y
<=
Less than or equal to - True if left operand is less
than or equal to the right
x <= y
Logical operators
Operator Meaning Example
and True if both the operands are true x and y
or True if either of the operands is true x or y
not
True if operand is false
(complements the operand)
not x
Bitwise operators
ï‚— Bitwise operators operates on individual
bits of number.
Operator Meaning Example
& Bitwise AND 10 & 4 = 0
| Bitwise OR 10 | 4 = 14
~ Bitwise NOT ~10 = -11
^ Bitwise XOR 10 ^ 4 = 14
>> Bitwise right shift 10>> 2 = 2
<< Bitwise left shift 10<< 2 = 42
Compound Assignment operators
Operator Example Equivatent to
= x = 5 x = 5
+= x += 5 x = x + 5
-= x -= 5 x = x - 5
*= x *= 5 x = x * 5
/= x /= 5 x = x / 5
%= x %= 5 x = x % 5
//= x //= 5 x = x // 5
**= x **= 5 x = x ** 5
&= x &= 5 x = x & 5
|= x |= 5 x = x | 5
^= x ^= 5 x = x ^ 5
>>= x >>= 5 x = x >> 5
<<= x <<= 5 x = x << 5
Precedence of Python Operators
Operators Meaning
() Parentheses
** Exponent
+x, -x, ~x Unary plus, Unary minus, Bitwise NOT
*, /, //, % Multiplication,Division, Floor division, Modulus
+, - Addition,Subtraction
<<, >> Bitwise shift operators
& Bitwise AND
^ Bitwise XOR
| Bitwise OR
==, !=, >, >=, <, <=, is, is not, in, not in Comparisions,Identity, Membership operators
not Logical NOT
and Logical AND
or Logical OR

More Related Content

What's hot

Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
VedaGayathri1
 
Inline function
Inline functionInline function
Inline functionTech_MX
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
Ashok Raj
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
RaginiJain21
 
Dictionaries in Python
Dictionaries in PythonDictionaries in Python
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Python programming : Standard Input and Output
Python programming : Standard Input and OutputPython programming : Standard Input and Output
Python programming : Standard Input and Output
Emertxe Information Technologies Pvt Ltd
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
Srinivas Narasegouda
 
Python programming : Control statements
Python programming : Control statementsPython programming : Control statements
Python programming : Control statements
Emertxe Information Technologies Pvt Ltd
 
Break and continue
Break and continueBreak and continue
Break and continueFrijo Francis
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
nitamhaske
 
Exception handling and function in python
Exception handling and function in pythonException handling and function in python
Exception handling and function in python
TMARAGATHAM
 
Strings in python
Strings in pythonStrings in python
Strings in python
Prabhakaran V M
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
Devashish Kumar
 
Variables in python
Variables in pythonVariables in python
Variables in python
Jaya Kumari
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
Kamal Acharya
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
Kamal Acharya
 

What's hot (20)

Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
 
Inline function
Inline functionInline function
Inline function
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
 
Dictionaries in Python
Dictionaries in PythonDictionaries in Python
Dictionaries in Python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Python programming : Standard Input and Output
Python programming : Standard Input and OutputPython programming : Standard Input and Output
Python programming : Standard Input and Output
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Python programming : Control statements
Python programming : Control statementsPython programming : Control statements
Python programming : Control statements
 
Break and continue
Break and continueBreak and continue
Break and continue
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Exception handling and function in python
Exception handling and function in pythonException handling and function in python
Exception handling and function in python
 
Strings in python
Strings in pythonStrings in python
Strings in python
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Variables in python
Variables in pythonVariables in python
Variables in python
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Python Flow Control
Python Flow ControlPython Flow Control
Python Flow Control
 

Similar to Introduction to Python

PPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptxPPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptx
tcsonline1222
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
Mukul Kirti Verma
 
basics of python programming5.pdf
basics of python programming5.pdfbasics of python programming5.pdf
basics of python programming5.pdf
Pushkaran3
 
Python Operators
Python OperatorsPython Operators
Python Operators
Adheetha O. V
 
Python basics
Python basicsPython basics
Python basics
Manisha Gholve
 
Python_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxPython_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptx
SahajShrimal1
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golang
www.ixxo.io
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
jaba kumar
 
Python-review1.pdf
Python-review1.pdfPython-review1.pdf
Python-review1.pdf
paijitk
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.ppt
balewayalew
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
snowflakebatch
 
Python programming
Python  programmingPython  programming
Python programming
Ashwin Kumar Ramasamy
 
Python Lecture 2
Python Lecture 2Python Lecture 2
Python Lecture 2
Inzamam Baig
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
Sumit Satam
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
Ankita Shirke
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
PhanMinhLinhAnxM0190
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
RohitSindhu10
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
AkashdeepBhattacharj1
 
TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdf
EjazAlam23
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
AKANSHAMITTAL2K21AFI
 

Similar to Introduction to Python (20)

PPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptxPPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptx
 
Welcome to python workshop
Welcome to python workshopWelcome to python workshop
Welcome to python workshop
 
basics of python programming5.pdf
basics of python programming5.pdfbasics of python programming5.pdf
basics of python programming5.pdf
 
Python Operators
Python OperatorsPython Operators
Python Operators
 
Python basics
Python basicsPython basics
Python basics
 
Python_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptxPython_Unit-1_PPT_Data Types.pptx
Python_Unit-1_PPT_Data Types.pptx
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golang
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
 
Python-review1.pdf
Python-review1.pdfPython-review1.pdf
Python-review1.pdf
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.ppt
 
Python-review1.ppt
Python-review1.pptPython-review1.ppt
Python-review1.ppt
 
Python programming
Python  programmingPython  programming
Python programming
 
Python Lecture 2
Python Lecture 2Python Lecture 2
Python Lecture 2
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
 
TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdf
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 

More from Mohammed Sikander

Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Mohammed Sikander
 
Operator Overloading in C++
Operator Overloading in C++Operator Overloading in C++
Operator Overloading in C++
Mohammed Sikander
 
Python_Regular Expression
Python_Regular ExpressionPython_Regular Expression
Python_Regular Expression
Mohammed Sikander
 
Modern_CPP-Range-Based For Loop.pptx
Modern_CPP-Range-Based For Loop.pptxModern_CPP-Range-Based For Loop.pptx
Modern_CPP-Range-Based For Loop.pptx
Mohammed Sikander
 
Modern_cpp_auto.pdf
Modern_cpp_auto.pdfModern_cpp_auto.pdf
Modern_cpp_auto.pdf
Mohammed Sikander
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
Mohammed Sikander
 
Python tuple
Python   tuplePython   tuple
Python tuple
Mohammed Sikander
 
Python strings
Python stringsPython strings
Python strings
Mohammed Sikander
 
Python set
Python setPython set
Python set
Mohammed Sikander
 
Python list
Python listPython list
Python list
Mohammed Sikander
 
Pointer basics
Pointer basicsPointer basics
Pointer basics
Mohammed Sikander
 
Pipe
PipePipe
Signal
SignalSignal
File management
File managementFile management
File management
Mohammed Sikander
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
Mohammed Sikander
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - Reference
Mohammed Sikander
 
Java arrays
Java    arraysJava    arrays
Java arrays
Mohammed Sikander
 
Java strings
Java   stringsJava   strings
Java strings
Mohammed Sikander
 
Java notes 1 - operators control-flow
Java notes   1 - operators control-flowJava notes   1 - operators control-flow
Java notes 1 - operators control-flow
Mohammed Sikander
 

More from Mohammed Sikander (20)

Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Operator Overloading in C++
Operator Overloading in C++Operator Overloading in C++
Operator Overloading in C++
 
Python_Regular Expression
Python_Regular ExpressionPython_Regular Expression
Python_Regular Expression
 
Modern_CPP-Range-Based For Loop.pptx
Modern_CPP-Range-Based For Loop.pptxModern_CPP-Range-Based For Loop.pptx
Modern_CPP-Range-Based For Loop.pptx
 
Modern_cpp_auto.pdf
Modern_cpp_auto.pdfModern_cpp_auto.pdf
Modern_cpp_auto.pdf
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Python tuple
Python   tuplePython   tuple
Python tuple
 
Python strings
Python stringsPython strings
Python strings
 
Python set
Python setPython set
Python set
 
Python list
Python listPython list
Python list
 
Pointer basics
Pointer basicsPointer basics
Pointer basics
 
Pipe
PipePipe
Pipe
 
Signal
SignalSignal
Signal
 
File management
File managementFile management
File management
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - Reference
 
Java arrays
Java    arraysJava    arrays
Java arrays
 
Java strings
Java   stringsJava   strings
Java strings
 
Java notes 1 - operators control-flow
Java notes   1 - operators control-flowJava notes   1 - operators control-flow
Java notes 1 - operators control-flow
 

Recently uploaded

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 

Recently uploaded (20)

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 

Introduction to Python

  • 2. Python Printing Messages on Screen Reading input from console Python Identifiers and Keywords Data types in Python Operators Using math library function
  • 3. ï‚— Developed by GuidoVan Roussum in 1991. ï‚— Python is processed at runtime by the interpreter. ï‚— There is no need to compile your program before executing it. ï‚— Python has a design philosophy that emphasizes code readability.
  • 4. Hello World Program mohammed.sikander@cranessoftware.com 4 >>> print(‘Hello’) >>> print(‘Welcome to Python Programming!')
  • 5. Print Statement #Python 2.x Code #Python 3.x Code print "SIKANDER" print 5 print 2 + 4 SIKANDER 5 6 The "print" directive prints contents to console.  In Python 2, the "print" statement is not a function,and therefore it is invoked without parentheses.  In Python 3, it is a function, and must be invoked with parentheses. (It includes a newline, unlike in C)  A hash sign (#) that is not inside a string literal begins a comment. All characters after the # and up to the end of the physical line are part of the comment and the Python interpreter ignores them. print("SIKANDER") print(5) print(2 + 4) Output
  • 6. Python Identifiers ï‚— Identifier is the name given to entities like class, functions, variables etc. ï‚— Rules for writing identifiers ï‚— Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore (_). ï‚— An identifier cannot start with a digit. ï‚— Keywords cannot be used as identifiers. ï‚— We cannot use special symbols like !, @, #, $, % etc. in our identifier.
  • 7. Python Keywords ï‚— Keywords are the reserved words in Python. ï‚— We cannot use a keyword as variable name, function name or any other identifier. ï‚— They are used to define the syntax and structure of the Python language. ï‚— keywords are case sensitive. ï‚— There are 33 keywords in Python 3.3.
  • 8. Keywords in Python programming language False class finally is return None continue for lambda try True def from nonlocal while and del global not with as elif if or yield assert else import pass break except in raise All the keywords except True, False and None are in lowercase
  • 9. PythonVariables ï‚— A variable is a location in memory used to store some data (value). ï‚— They are given unique names to differentiate between different memory locations.The rules for writing a variable name is same as the rules for writing identifiers in Python. ï‚— We don't need to declare a variable before using it. ï‚— In Python, we simply assign a value to a variable and it will exist. ï‚— We don't even have to declare the type of the variable.This is handled internally according to the type of value we assign to the variable.
  • 10. Variable assignment ï‚— We use the assignment operator (=) to assign values to a variable. ï‚— Any type of value can be assigned to any valid variable.
  • 11. Multiple assignments ï‚— In Python, multiple assignments can be made in a single statement as follows: If we want to assign the same value to multiple variables at once, we can do this as x = y = z = "same"
  • 12. Data types in Python ï‚— Every value in Python has a datatype. ï‚— Since everything is an object in Python ï‚— Data types are actually classes and variables are instance (object) of these classes. ï‚— Numbers ï‚— int ï‚— float ï‚— String – str ï‚— Boolean - bool
  • 13. Type of object – type() ï‚— type() function can be used to know to which class a variable or a value belongs to.
  • 14. Reading Input Python 2.x Python 3.x ï‚— print("Enter the name :") ï‚— name = raw_input() ï‚— print(name) ï‚— print("Enter the name :") ï‚— name = input() ï‚— print(name) If you want to prompt the user for input, you can use raw_input in Python 2.X, and just input in Python 3.
  • 15. ï‚— name = input("Enter the name :") ï‚— print(“Welcome “ + name) ï‚¡ Input function can print a prompt and read the input.
  • 16. Arithmetic Operators Operator Meaning Example + Add two operands or unary plus x + y +2 - Subtract right operand from the left or unary minus x - y -2 * Multiply two operands x * y / Divide left operand by the right one (always results into float) x / y % Modulus - remainder of the division of left operand by the right x % y (remainder of x/y) // Floor division - division that results into whole number adjusted to the left in the number line x // y ** Exponent - left operand raised to the power of right x**y (x to the power y)
  • 18. What is the output
  • 19. ï‚— Data read from input is in the form of string. ï‚— To convert to integer, we need to typecast. ï‚— Syntax : datatype(object)
  • 20.
  • 21. Exercise ï‚— Write a program to calculate the area of Circle given its radius. ï‚— area = Ï€r2
  • 22.
  • 23.
  • 24. ï‚— Write a program to calculate the area of circle given its 3 sides. ï‚— s = (a+b+c)/2 ï‚— area = √(s(s-a)*(s-b)*(s-c))
  • 25.
  • 26. Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost. Input 12.00 20 8 Output The total meal cost is 15 dollars.
  • 27.
  • 28. ï‚— Temperature Conversion. ï‚— Given the temperature in Celsius, convert it to Fahrenheit. ï‚— Given the temperature in Fahrenheit, convert it to Celsius.
  • 29. Relational operators ï‚— Relational operators are used to compare values. ï‚— It returns True or False according to condition Operator Meaning Example > Greater that - True if left operand is greater than the right x > y < Less that - True if left operand is less than the right x < y == Equal to - True if both operands are equal x == y != Not equal to - True if operands are not equal x != y >= Greater than or equal to - True if left operand is greater than or equal to the right x >= y <= Less than or equal to - True if left operand is less than or equal to the right x <= y
  • 30.
  • 31.
  • 32. Logical operators Operator Meaning Example and True if both the operands are true x and y or True if either of the operands is true x or y not True if operand is false (complements the operand) not x
  • 33.
  • 34. Bitwise operators ï‚— Bitwise operators operates on individual bits of number. Operator Meaning Example & Bitwise AND 10 & 4 = 0 | Bitwise OR 10 | 4 = 14 ~ Bitwise NOT ~10 = -11 ^ Bitwise XOR 10 ^ 4 = 14 >> Bitwise right shift 10>> 2 = 2 << Bitwise left shift 10<< 2 = 42
  • 35. Compound Assignment operators Operator Example Equivatent to = x = 5 x = 5 += x += 5 x = x + 5 -= x -= 5 x = x - 5 *= x *= 5 x = x * 5 /= x /= 5 x = x / 5 %= x %= 5 x = x % 5 //= x //= 5 x = x // 5 **= x **= 5 x = x ** 5 &= x &= 5 x = x & 5 |= x |= 5 x = x | 5 ^= x ^= 5 x = x ^ 5 >>= x >>= 5 x = x >> 5 <<= x <<= 5 x = x << 5
  • 36. Precedence of Python Operators Operators Meaning () Parentheses ** Exponent +x, -x, ~x Unary plus, Unary minus, Bitwise NOT *, /, //, % Multiplication,Division, Floor division, Modulus +, - Addition,Subtraction <<, >> Bitwise shift operators & Bitwise AND ^ Bitwise XOR | Bitwise OR ==, !=, >, >=, <, <=, is, is not, in, not in Comparisions,Identity, Membership operators not Logical NOT and Logical AND or Logical OR