SlideShare a Scribd company logo
What is Python?
Python is a popular programming language. It was
created by Guido van Rossum, and released in 1991.
It is used for:
web development (server-side),
software development,
mathematics,
system scripting.
What can Python do?
• Python can be used on a server to create web applications.
• Python can be used alongside software to create workflows.
• Python can connect to database systems. It can also read
and modify files.
• Python can be used to handle big data and perform complex
mathematics.
• Python can be used for rapid prototyping, or for production-
ready software development.
Why Python?
• Python works on different platforms (Windows, Mac, Linux,
Raspberry Pi, etc).
• Python has a simple syntax similar to the English language.
• Python has syntax that allows developers to write programs
with fewer lines than some other programming languages.
• Python runs on an interpreter system, meaning that code
can be executed as soon as it is written. This means that
prototyping can be very quick.
• Python can be treated in a procedural way, an object-
oriented way or a functional way.
example print("Hello, World!")
Variables
• Variables are containers for storing data values.
Creating Variables
• Python has no command for declaring a variable.
• A variable is created the moment you first assign a value to it.
input
x = 5
y = "John"
print(x)
print(y)
Output
5
John
Variables do not need to be declared with any particular type, and can even
change type after they have been set.
Example
x = 4 # x is of type int
x = "Sally" # x is now of type str
print(x)
output
Sally
Casting
• If you want to specify the data type of a variable, this
can be done with casting.
• Example
• x = str(3) # x will be '3'
y = int(3) # y will be 3
z = float(3) # z will be 3.0
Out put will be
3
3
3.0
• Variable Names
• A variable can have a short name (like x and y) or a
more descriptive name (age, carname, total_volume).
Rules for Python variables: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)
• A variable name cannot be any of the Python keywords.
• Example
• Legal variable names:
• myvar = "John"
my_var = "John"
_my_var = "John"
myVar = "John"
MYVAR = "John"
myvar2 = "John"
print(myvar)
print(my_var)
print(_my_var)
print(myVar)
print(MYVAR)
print(myvar2)
Many Values to Multiple Variables
• Python allows you to assign values to multiple variables in one line:
• Example
• x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
output will be
?
?
?
One Value to Multiple Variables
• you can assign the same value to multiple variables in one line:
• Example
• x = y = z = "Orange"
print(x)
print(y)
print(z)
• Output
• Orange
Orange
Orange
• Unpack a Collection
• If you have a collection of values in a list, tuple etc. Python
allows you to extract the values into variables. This is
called unpacking.
• Example
• Unpack a list:
• fruits = ["apple", "banana", "cherry"]
x, y, z = fruits
print(x)
print(y)
print(z)
Output
apple
banana
cherry
Output Variables
The Python print() function is often used to output variables.
• Example
• x = "Python is awesome"
print(x)
• Variables that are created outside of a function (as in all of the examples in the
previous pages) are known as global variables.
• Global variables can be used by everyone, both inside of functions and outside.
• Example
• Create a variable outside of a function, and use it inside the function
• x = "awesome"
def myfunc():
print("Python is " + x)
myfunc()
Output
Python is awesome
You can display a string literal with the print() function:
• Quotes Inside Quotes
• You can use quotes inside a string, as long as they don't
match the quotes surrounding the string:
• Example
• print("It's alright")
print("He is called 'Johnny'")
print('He is called "Johnny"')
• Control Structures in Python
• Most programs don't operate by carrying out a straightforward
sequence of statements. A code is written to allow making choices
and several pathways through the program to be followed depending
on shifts in variable values.
• All programming languages contain a pre-included set of control
structures that enable these control flows to execute, which makes it
conceivable.
• This tutorial will examine how to add loops and branches, i.e.,
conditions to our Python programs.
• Types of Control Structures
• Control flow refers to the sequence a program will follow during its
execution.
•Selection - This structure is used for making decisions by checking conditions and branching
•Repetition - This structure is used for looping, i.e., repeatedly executing a certain piece of a code block.
Sequential
Sequential statements are a set of statements whose execution process happens in a sequence.
The problem with sequential statements is that if the logic has
broken in any one of the lines, then the complete source code execution will break.
Code
1.# Python program to show how a sequential control structure works
2.
3.# We will initialize some variables
4.# Then operations will be done
5.# And, at last, results will be printed
6.# Execution flow will be the same as the code is written, and there is no hidden flow
7.a = 20
8.b = 10
9.c = a - b
10.d = a + b
11.e = a * b
12.print("The result of the subtraction is: ", c)
13.print("The result of the addition is: ", d)
14.print("The result of the multiplication is: ", e)
Output:
The result of the subtraction is: 10 The result of the addition is : 30 The result of the multiplication is: 200
Selection/Decision Control Statements
• The statements used in selection control structures are also referred to as branching statements or, as their
fundamental role is to make decisions, decision control statements.
• A program can test many conditions using these selection statements, and depending on whether the given
condition is true or not, it can execute different code blocks.
• There can be many forms of decision control structures. Here are some most commonly used control structures:
• Only if
• if-else
• The nested if
• The complete if-elif-else
• Simple if
• If statements in Python are called control flow statements. The selection statements assist us in running a certain
piece of code, but only in certain circumstances. There is only one condition to test in a basic if statement.
• The if statement's fundamental structure is as follows:
• Syntax
1. if <conditional expression> :
2. The code block to be executed if the condition is True
• These statements will always be executed. They are part of the main code.
• All the statements written indented after the if statement will run if the condition giver after the if the keyword is
True. Only the code statement that will always be executed regardless of the if the condition is the statement
written aligned to the main code. Python uses these types of indentations to identify a code block of a particular
control flow statement. The specified control structure will alter the flow of only those indented statements.
1.# Python program to show how a simple if keyword works
2.
3.# Initializing some variables
4.v = 5
5.t = 4
6.print("The initial value of v is", v, "and that of t is ",t)
7.
8.# Creating a selection control structure
9.if v > t :
10. print(v, "is bigger than ", t)
11. v -= 2
12.
13.print("The new value of v is", v, "and the t is ",t)
14.
15.# Creating the second control structure
16.if v < t :
17. print(v , "is smaller than ", t)
18. v += 1
19.
20.print("the new value of v is ", v)
21.
22.# Creating the third control structure
23.if v == t:
24. print("The value of v, ", v, " and t,", t, ", are equal")
Output:
ADVERTISEMENT
The initial value of v is 5 and that of t is 4 5 is bigger than 4 The new value of v is 3 and the t is 4 3 is smaller
than 4 the new value of v is 4 The value of v, 4 and t, 4, are equal
Code
1.# Python program to show how a simple if keyword works
2.
3.# Initializing some variables
4.v = 5
5.t = 4
6.print("The initial value of v is", v, "and that of t is ",t)
7.
8.# Creating a selection control structure
9.if v > t :
10. print(v, "is bigger than ", t)
11. v -= 2
12.
13.print("The new value of v is", v, "and the t is ",t)
14.
15.# Creating the second control structure
16.if v < t :
17. print(v , "is smaller than ", t)
18. v += 1
19.
20.print("the new value of v is ", v)
21.
22.# Creating the third control structure
23.if v == t:
24. print("The value of v, ", v, " and t,", t, ", are equal")
Output:
ADVERTISEMENT
The initial value of v is 5 and that of t is 4 5 is bigger than 4 The new value of v is 3 and the t is 4 3 is smaller than 4 the new value of v is 4 The value of v, 4 and t, 4, are equal

More Related Content

PPTX
python BY ME-2021python anylssis(1).pptx
rekhaaarohan
 
PDF
Python: An introduction A summer workshop
ForrayFerenc
 
PPTX
Python for beginner, learn python from scratch.pptx
olieee2023
 
PDF
Python Module-1.1.pdf
4HG19EC010HARSHITHAH
 
PPTX
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
PPTX
python-presentationpython-presentationpython-presentation.pptx
rkameshwaran50
 
PPTX
made it easy: python quick reference for beginners
SumanMadan4
 
PPTX
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 
python BY ME-2021python anylssis(1).pptx
rekhaaarohan
 
Python: An introduction A summer workshop
ForrayFerenc
 
Python for beginner, learn python from scratch.pptx
olieee2023
 
Python Module-1.1.pdf
4HG19EC010HARSHITHAH
 
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
python-presentationpython-presentationpython-presentation.pptx
rkameshwaran50
 
made it easy: python quick reference for beginners
SumanMadan4
 
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 

Similar to Presgfdjfwwwwwwwwwwqwqeeqentation11.pptx (20)

PPTX
lecture 2.pptx
Anonymous9etQKwW
 
PPTX
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
PPT
Python - Module 1.ppt
jaba kumar
 
PDF
python 34💭.pdf
AkashdeepBhattacharj1
 
PDF
python notes.pdf
RohitSindhu10
 
PDF
pythonQuick.pdf
PhanMinhLinhAnxM0190
 
PPTX
Presentation of Python Programming Language
DeepakYaduvanshi16
 
PDF
Python indroduction
FEG
 
DOCX
A Introduction Book of python For Beginners.docx
kumarrabinderkumar77
 
PPTX
Dr.C S Prasanth-Physics ppt.pptx computer
kavitamittal18
 
PPTX
Intro to Python Programming Language
Dipankar Achinta
 
PPTX
Programming with python
sarogarage
 
PPTX
Machine learning session3(intro to python)
Abhimanyu Dwivedi
 
PPTX
Python 01.pptx
AliMohammadAmiri
 
PPTX
Basic of Python- Hands on Session
Dharmesh Tank
 
PDF
Introduction To Programming with Python
Sushant Mane
 
PPTX
Python Seminar PPT
Shivam Gupta
 
PPTX
Python
Shivam Gupta
 
PDF
python-160403194316.pdf
gmadhu8
 
PPTX
Python Introduction
Punithavel Ramani
 
lecture 2.pptx
Anonymous9etQKwW
 
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
Python - Module 1.ppt
jaba kumar
 
python 34💭.pdf
AkashdeepBhattacharj1
 
python notes.pdf
RohitSindhu10
 
pythonQuick.pdf
PhanMinhLinhAnxM0190
 
Presentation of Python Programming Language
DeepakYaduvanshi16
 
Python indroduction
FEG
 
A Introduction Book of python For Beginners.docx
kumarrabinderkumar77
 
Dr.C S Prasanth-Physics ppt.pptx computer
kavitamittal18
 
Intro to Python Programming Language
Dipankar Achinta
 
Programming with python
sarogarage
 
Machine learning session3(intro to python)
Abhimanyu Dwivedi
 
Python 01.pptx
AliMohammadAmiri
 
Basic of Python- Hands on Session
Dharmesh Tank
 
Introduction To Programming with Python
Sushant Mane
 
Python Seminar PPT
Shivam Gupta
 
Python
Shivam Gupta
 
python-160403194316.pdf
gmadhu8
 
Python Introduction
Punithavel Ramani
 
Ad

Recently uploaded (20)

PDF
Invincible season 2 storyboard revisions seq3 by Mark G
MarkGalez
 
PPTX
LESSON 5 TLE 7SDHSJFJDFHDJFHDJFEWFFFEDDDD
roeltabuyo4
 
PPT
Gas turbine mark VIe control Monitoring IO.ppt
aliyu4ahmad
 
PPTX
PPT Lapkas helminthiasiiiiiiiiiiiiis.pptx
ratnaernawati4
 
PPTX
Digital Marketing training in Chandigarh
chetann0777
 
PDF
【2nd】Explanatory material of DTU(230207).pdf
kewalsinghpuriya
 
PDF
Left Holding the Bag sequence 2 Storyboard by Mark G
MarkGalez
 
PPTX
MASTERING COMMUNICATION SKILLS.pptxgdee33w
akramm8009
 
PPTX
Jaipur Sees Exponential Growth in Data Analytics Jobs Salarite Smart Hiring P...
vinay salarite
 
PPTX
Capstone Professional Portfolio Melissa Alice
malice926
 
PDF
Family therapy by Alan Carr.pdf oo000889999
DivyaMohan270477
 
PPTX
Title The Power of Oral Communication (2).pptx
amankumar7762044
 
PDF
Looking forward to a challenging Role in the same area and would like to expl...
Kazi Jahangeer Alam
 
PPTX
arif og 2.pptx defence mechanism of gingiva
arifkhansm29
 
PPTX
9e3e3981-1864-438b-93b4-ebabcb5090d0.pptx
SureshKumar565390
 
PPT
Leadership essentials to build your carrier
ahmedhasan769002
 
PPT
Gas turbine mark VIe control basics tool box description
aliyu4ahmad
 
PPTX
Soil_Health_Card_Template_Style.pptxkkki
Akash486765
 
DOCX
(14-5) Bo-15-De-luyen-thi-vao-10-Ha-Noi-25-26.docx
27QuynNhnChu
 
PPTX
Tags_of_Chaman_Lifestyle Balochistan.pptx
MuhammadAkramKhan9
 
Invincible season 2 storyboard revisions seq3 by Mark G
MarkGalez
 
LESSON 5 TLE 7SDHSJFJDFHDJFHDJFEWFFFEDDDD
roeltabuyo4
 
Gas turbine mark VIe control Monitoring IO.ppt
aliyu4ahmad
 
PPT Lapkas helminthiasiiiiiiiiiiiiis.pptx
ratnaernawati4
 
Digital Marketing training in Chandigarh
chetann0777
 
【2nd】Explanatory material of DTU(230207).pdf
kewalsinghpuriya
 
Left Holding the Bag sequence 2 Storyboard by Mark G
MarkGalez
 
MASTERING COMMUNICATION SKILLS.pptxgdee33w
akramm8009
 
Jaipur Sees Exponential Growth in Data Analytics Jobs Salarite Smart Hiring P...
vinay salarite
 
Capstone Professional Portfolio Melissa Alice
malice926
 
Family therapy by Alan Carr.pdf oo000889999
DivyaMohan270477
 
Title The Power of Oral Communication (2).pptx
amankumar7762044
 
Looking forward to a challenging Role in the same area and would like to expl...
Kazi Jahangeer Alam
 
arif og 2.pptx defence mechanism of gingiva
arifkhansm29
 
9e3e3981-1864-438b-93b4-ebabcb5090d0.pptx
SureshKumar565390
 
Leadership essentials to build your carrier
ahmedhasan769002
 
Gas turbine mark VIe control basics tool box description
aliyu4ahmad
 
Soil_Health_Card_Template_Style.pptxkkki
Akash486765
 
(14-5) Bo-15-De-luyen-thi-vao-10-Ha-Noi-25-26.docx
27QuynNhnChu
 
Tags_of_Chaman_Lifestyle Balochistan.pptx
MuhammadAkramKhan9
 
Ad

Presgfdjfwwwwwwwwwwqwqeeqentation11.pptx

  • 1. What is Python? Python is a popular programming language. It was created by Guido van Rossum, and released in 1991. It is used for: web development (server-side), software development, mathematics, system scripting.
  • 2. What can Python do? • Python can be used on a server to create web applications. • Python can be used alongside software to create workflows. • Python can connect to database systems. It can also read and modify files. • Python can be used to handle big data and perform complex mathematics. • Python can be used for rapid prototyping, or for production- ready software development.
  • 3. Why Python? • Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc). • Python has a simple syntax similar to the English language. • Python has syntax that allows developers to write programs with fewer lines than some other programming languages. • Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick. • Python can be treated in a procedural way, an object- oriented way or a functional way.
  • 4. example print("Hello, World!") Variables • Variables are containers for storing data values. Creating Variables • Python has no command for declaring a variable. • A variable is created the moment you first assign a value to it. input x = 5 y = "John" print(x) print(y) Output 5 John
  • 5. Variables do not need to be declared with any particular type, and can even change type after they have been set. Example x = 4 # x is of type int x = "Sally" # x is now of type str print(x) output Sally
  • 6. Casting • If you want to specify the data type of a variable, this can be done with casting. • Example • x = str(3) # x will be '3' y = int(3) # y will be 3 z = float(3) # z will be 3.0 Out put will be 3 3 3.0
  • 7. • Variable Names • A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for Python variables: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) • A variable name cannot be any of the Python keywords.
  • 8. • Example • Legal variable names: • myvar = "John" my_var = "John" _my_var = "John" myVar = "John" MYVAR = "John" myvar2 = "John" print(myvar) print(my_var) print(_my_var) print(myVar) print(MYVAR) print(myvar2)
  • 9. Many Values to Multiple Variables • Python allows you to assign values to multiple variables in one line: • Example • x, y, z = "Orange", "Banana", "Cherry" print(x) print(y) print(z) output will be ? ? ? One Value to Multiple Variables • you can assign the same value to multiple variables in one line: • Example • x = y = z = "Orange" print(x) print(y) print(z) • Output • Orange Orange Orange
  • 10. • Unpack a Collection • If you have a collection of values in a list, tuple etc. Python allows you to extract the values into variables. This is called unpacking. • Example • Unpack a list: • fruits = ["apple", "banana", "cherry"] x, y, z = fruits print(x) print(y) print(z) Output apple banana cherry
  • 11. Output Variables The Python print() function is often used to output variables. • Example • x = "Python is awesome" print(x) • Variables that are created outside of a function (as in all of the examples in the previous pages) are known as global variables. • Global variables can be used by everyone, both inside of functions and outside. • Example • Create a variable outside of a function, and use it inside the function • x = "awesome" def myfunc(): print("Python is " + x) myfunc() Output Python is awesome
  • 12. You can display a string literal with the print() function: • Quotes Inside Quotes • You can use quotes inside a string, as long as they don't match the quotes surrounding the string: • Example • print("It's alright") print("He is called 'Johnny'") print('He is called "Johnny"')
  • 13. • Control Structures in Python • Most programs don't operate by carrying out a straightforward sequence of statements. A code is written to allow making choices and several pathways through the program to be followed depending on shifts in variable values. • All programming languages contain a pre-included set of control structures that enable these control flows to execute, which makes it conceivable. • This tutorial will examine how to add loops and branches, i.e., conditions to our Python programs. • Types of Control Structures • Control flow refers to the sequence a program will follow during its execution.
  • 14. •Selection - This structure is used for making decisions by checking conditions and branching •Repetition - This structure is used for looping, i.e., repeatedly executing a certain piece of a code block. Sequential Sequential statements are a set of statements whose execution process happens in a sequence. The problem with sequential statements is that if the logic has broken in any one of the lines, then the complete source code execution will break. Code 1.# Python program to show how a sequential control structure works 2. 3.# We will initialize some variables 4.# Then operations will be done 5.# And, at last, results will be printed 6.# Execution flow will be the same as the code is written, and there is no hidden flow 7.a = 20 8.b = 10 9.c = a - b 10.d = a + b 11.e = a * b 12.print("The result of the subtraction is: ", c) 13.print("The result of the addition is: ", d) 14.print("The result of the multiplication is: ", e) Output: The result of the subtraction is: 10 The result of the addition is : 30 The result of the multiplication is: 200
  • 15. Selection/Decision Control Statements • The statements used in selection control structures are also referred to as branching statements or, as their fundamental role is to make decisions, decision control statements. • A program can test many conditions using these selection statements, and depending on whether the given condition is true or not, it can execute different code blocks. • There can be many forms of decision control structures. Here are some most commonly used control structures: • Only if • if-else • The nested if • The complete if-elif-else • Simple if • If statements in Python are called control flow statements. The selection statements assist us in running a certain piece of code, but only in certain circumstances. There is only one condition to test in a basic if statement. • The if statement's fundamental structure is as follows: • Syntax 1. if <conditional expression> : 2. The code block to be executed if the condition is True • These statements will always be executed. They are part of the main code. • All the statements written indented after the if statement will run if the condition giver after the if the keyword is True. Only the code statement that will always be executed regardless of the if the condition is the statement written aligned to the main code. Python uses these types of indentations to identify a code block of a particular control flow statement. The specified control structure will alter the flow of only those indented statements.
  • 16. 1.# Python program to show how a simple if keyword works 2. 3.# Initializing some variables 4.v = 5 5.t = 4 6.print("The initial value of v is", v, "and that of t is ",t) 7. 8.# Creating a selection control structure 9.if v > t : 10. print(v, "is bigger than ", t) 11. v -= 2 12. 13.print("The new value of v is", v, "and the t is ",t) 14. 15.# Creating the second control structure 16.if v < t : 17. print(v , "is smaller than ", t) 18. v += 1 19. 20.print("the new value of v is ", v) 21. 22.# Creating the third control structure 23.if v == t: 24. print("The value of v, ", v, " and t,", t, ", are equal") Output: ADVERTISEMENT The initial value of v is 5 and that of t is 4 5 is bigger than 4 The new value of v is 3 and the t is 4 3 is smaller than 4 the new value of v is 4 The value of v, 4 and t, 4, are equal
  • 17. Code 1.# Python program to show how a simple if keyword works 2. 3.# Initializing some variables 4.v = 5 5.t = 4 6.print("The initial value of v is", v, "and that of t is ",t) 7. 8.# Creating a selection control structure 9.if v > t : 10. print(v, "is bigger than ", t) 11. v -= 2 12. 13.print("The new value of v is", v, "and the t is ",t) 14. 15.# Creating the second control structure 16.if v < t : 17. print(v , "is smaller than ", t) 18. v += 1 19. 20.print("the new value of v is ", v) 21. 22.# Creating the third control structure 23.if v == t: 24. print("The value of v, ", v, " and t,", t, ", are equal") Output: ADVERTISEMENT The initial value of v is 5 and that of t is 4 5 is bigger than 4 The new value of v is 3 and the t is 4 3 is smaller than 4 the new value of v is 4 The value of v, 4 and t, 4, are equal