SlideShare a Scribd company logo
1 of 23
PYTHON PROGRAMING
Python Programming Lab Program
Using Python 3.11
Instructor Name: Mr. Elias P.
For Automotive Engineering 4rth Year Students
Lab Objectives
To write, test, and debug simple Python programs.
To use operators in a python program.
To implement Python programs with conditionals.
To implement Python programs with loops.
Use functions for structuring Python programs.
Represent compound data using Python lists, tuples, and
dictionaries.
Lab Outcomes
Upon completion of the course, students will be able to:
Write, test, and debug simple Python programs.
Use operators in a python program.
Implement Python programs with conditionals.
Implement Python programs with loops.
Develop Python programs step-wise by defining functions and calling
them.
Use Python lists, tuples, dictionaries for representing compound data.
Download and Install Python Setup
Download the setup from the below link
http://python.org/downloads/
Installation steps
Step 1: Select Version of Python to Install.
Step 2: Download Python Executable Installer.
Step 3: Run Executable Installer.
Step 4: Verify Python Was Installed on Windows.
Step 5: Verify Pip Was Installed.
Step 6: Add Python Path to Environment Variables (Optional)
What is python
Python is a popular programming language. It was created in
1991 by Guido Van Rossum.
It is used for
Web development
Software development
Data analysis
Game development
Desktop application
Embedded application
Introduction to Python
Write python program to display hello world on the screen
i.e print("hello world")
Python First Program
Python Variables
Unlike other programming languages, Python has no command for
declaring variable.
A variable is created at the moment you first assign a value to it.
Example
X=5 # x is now type of int
Y= “Elias” # Y is now type of string
Print(x)
Print(y)
Variables do not need to be declared with any particular type and can even
change type after they have been set.
Python Variables Names
A variable can have a short name (like x and y) or amore descriptive name
like (age, fnam, lname, etc).
Rules for naming Python variables
A variable name must start with letter or 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 _)
A variable names are case sensitive (age, Age and AGE are three
different variables)
Continued
The python print statement is often used to output variables.
To combine both text and a variable, Python uses the + character:
Example
X=“Intereting.”
Print(“Python is “+ x)
The output will be
Python is Interesting.
Python Data Types
 Write a program to demonstrate different
number data types and string in Python.
INPUT
a=10; #Integer Datatype
b=11.5; #Float Datatype
c=2.05j; #Complex Number
xy="Automotive Engineering"
print("a is Type of",type(a)); #prints type of variable a
print("b is Type of",type(b)); #prints type of variable b
print("c is Type of",type(c)); #prints type of variable c
print("xy is Type of",type(xy)); #prints type of variable xy
OUTPUT
a is Type of <class ‘int’>
b is Type of <class ‘float’>
c is Type of <class ‘complex’>
xy is Type of <class ‘str’>
Reading input from Keyboard
Write a python program that reads input(your full name) from keyboard and
displays the result . Type the following code.
Input
fname=str(input("Please enter your first name :"))
lname=str(input("Please enter your Last name :"))
print("Your full name is" "n"+fname + " " +lname)
Output
Please enter your first name :ELIAS
Please enter your Last name :PETROS
Your full name is
ELIAS PETROS
ARTHIMETIC OPERATIONS
INPUT
Write a Python Program that accepts two numbers and make
d/t arithmetic on it
a = int(input ('Enter the first number:'))
b = int(input ('Enter the second number:'))
summ=a+b
mul=a*b
div=a/b
fdiv=a//b
modu=a%b
print("Addition of a and b is :" +str(summ))
print("Multiplication of a and b is :" +str(mul))
print("Division of a and b is :" +str(div))
print("Floar Division of a and b is :" +str(fdiv))
print("Modulo devision of a and b is :" +str(modu))
OUTPUT
Enter the first number:24
Enter the second number:13
Addition of a and b is :37
Multiplication of a and b is :312
Division of a and b is :1.8461538461538463
Floar Division of a and b is :1
Modulo devision of a and b is :11
Continued
Continued
Python String Methods and Functions
Python String Methods and Functions
#isalnum()
string= "bbc123"
print(string.isalnum())
#isalpha()(add 2)
string="campus"
print(string.isalpha())
#isdigit() (add a letter)
string="0123456789"
print(string.isdigit())
string="012345689"
print(string.isnumeric() )
string="Arba minch Sawla Campus"
print(string.istitle())
string="Arba Minch Technology Campus"
print(string.replace('Technology Campus','Univeristy'))
OUTPUT
True
True
True
True
False
Arba Minch Univeristy
Python String Methods and Functions
Python String Methods and Functions
Write a program to create, concatenate and
print a string and accessing sub-string from a
given string.
INPUT
s1=input("Enter first String : ");
s2=input("Enter second String : ");
print("First string is : ",s1);
print("Second string is : ",s2);
print("concatenations of two strings :",s1+s2);
print("Substring of given string :",s1[1:4]); # prints strin
g from 1 to 3 because array Indexing starts from 0 and
ends at n-1.
OUTPUT
Enter first String: COMPUTER
Enter second String: SCIENCE
First String is : COMPUTER
Second String is : SCIENCE
Concatenations of two strings :
COMPUTERSCIENCE
Substring of given string: OMP
Python Conditional (If ) Statement
Write a python program which accept one integer number
from keyboard then display the number when number is
greater than 0 using python if statement.
INPUT
a = int(input ('Enter the number:'))
if a > 0:
print (a, "is greater than 0")
OUTPUT
It displays a if the entered
number is greater than 0
Unless it cant display anything.
Python Conditional(If-Else) Statements
Write a python program which accept two integer
numbers from keyboard then display which number is
greater using python if-else statement.
INPUT
a = int(input ('Enter the first number:'))
b = int(input ('Enter the second number:'))
if a > b:
print (a, "is greater than ", b)
else:
print (b, "is greater than ",a)
OUTPUT
Enter the first number:12
Enter the second number:23
23 is greater than 12
Python Conditional(If-Elif- Else ) Statements
Write a python program which takes numbers from
keyboard then display the number is either positive,
negative or 0 using python if-elif-else statement.
INPUT
number=int(input("Please enter the number you want to check
?"))
if number>0:
print("The number you entered is positive")
elif number<0:
print("The number you entered is negative")
else :
print("The number you entered is zero")
OUTPUT
Please enter the number you
want to check ?32
The number you entered is
positive
Write a python sources code that accept students score then calculate the grade
of the score?
Note:- Score range and grade were provided as bellow
Score range: Grade :
90-100 ===>A
80-89 ===>B
70-79 ===>C
60-69 ===> D
Below 60 ===>F
Python Conditional Nested(If-Elif- Else ) Statements
Continued
INPUT
score=float(input("Please enter your score:"))
if score>=90:
print("Grade = A ")
elif score>=80:
print("Grade = B ")
elif score>=70:
print("Grade = C ")
elif score>=60:
print("Grade = D ")
else :
print("Grade = F ")
OUTPUT
Please enter your score:34
Grade = F

More Related Content

Similar to Python.pptx

PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...manikamr074
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfKosmikTech1
 
unit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptxunit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptxusvirat1805
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxKoteswari Kasireddy
 
The Input Statement in Core Python .pptx
The Input Statement in Core Python .pptxThe Input Statement in Core Python .pptx
The Input Statement in Core Python .pptxKavitha713564
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfrajatxyz
 
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.pdfEjazAlam23
 
Python quick guide
Python quick guidePython quick guide
Python quick guideHasan Bisri
 
Python-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptxPython-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptxElijahSantos4
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshopBAINIDA
 
Introduction to python programming ( part-1)
Introduction to python programming  ( part-1)Introduction to python programming  ( part-1)
Introduction to python programming ( part-1)Ziyauddin Shaik
 
basics of python programming5.pdf
basics of python programming5.pdfbasics of python programming5.pdf
basics of python programming5.pdfPushkaran3
 
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON Nandakumar P
 

Similar to Python.pptx (20)

PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
 
unit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptxunit (1)INTRODUCTION TO PYTHON course.pptx
unit (1)INTRODUCTION TO PYTHON course.pptx
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
 
Python basics
Python basicsPython basics
Python basics
 
The Input Statement in Core Python .pptx
The Input Statement in Core Python .pptxThe Input Statement in Core Python .pptx
The Input Statement in Core Python .pptx
 
Python basics
Python basicsPython basics
Python basics
 
python
pythonpython
python
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.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 quick guide
Python quick guidePython quick guide
Python quick guide
 
Python-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptxPython-CH01L04-Presentation.pptx
Python-CH01L04-Presentation.pptx
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Introduction to python programming ( part-1)
Introduction to python programming  ( part-1)Introduction to python programming  ( part-1)
Introduction to python programming ( part-1)
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
basics of python programming5.pdf
basics of python programming5.pdfbasics of python programming5.pdf
basics of python programming5.pdf
 
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
 
Python
PythonPython
Python
 

More from EliasPetros

ghgfjfhgdjfdhgdhgfdgfdhgdhgfdhgzeka.pptx
ghgfjfhgdjfdhgdhgfdgfdhgdhgfdhgzeka.pptxghgfjfhgdjfdhgdhgfdgfdhgdhgfdhgzeka.pptx
ghgfjfhgdjfdhgdhgfdgfdhgdhgfdhgzeka.pptxEliasPetros
 
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptxL04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptxEliasPetros
 
lkjhlkjhjhkjhlkjhkjhkjhkjhkjhkjhjhkjh.ppt
lkjhlkjhjhkjhlkjhkjhkjhkjhkjhkjhjhkjh.pptlkjhlkjhjhkjhlkjhkjhkjhkjhkjhkjhjhkjh.ppt
lkjhlkjhjhkjhlkjhkjhkjhkjhkjhkjhjhkjh.pptEliasPetros
 
ehhhhhhhhhhhhhhhhhhhhhhhhhjjjjjllaye.pptx
ehhhhhhhhhhhhhhhhhhhhhhhhhjjjjjllaye.pptxehhhhhhhhhhhhhhhhhhhhhhhhhjjjjjllaye.pptx
ehhhhhhhhhhhhhhhhhhhhhhhhhjjjjjllaye.pptxEliasPetros
 
Database Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptxDatabase Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptxEliasPetros
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxEliasPetros
 
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptxhjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptxEliasPetros
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxEliasPetros
 
chaptet 4 DC and CN.ppt
chaptet 4 DC and CN.pptchaptet 4 DC and CN.ppt
chaptet 4 DC and CN.pptEliasPetros
 
5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptxEliasPetros
 
chapter 1 DC and CN-1.ppt
chapter 1 DC and CN-1.pptchapter 1 DC and CN-1.ppt
chapter 1 DC and CN-1.pptEliasPetros
 

More from EliasPetros (12)

ghgfjfhgdjfdhgdhgfdgfdhgdhgfdhgzeka.pptx
ghgfjfhgdjfdhgdhgfdgfdhgdhgfdhgzeka.pptxghgfjfhgdjfdhgdhgfdgfdhgdhgfdhgzeka.pptx
ghgfjfhgdjfdhgdhgfdgfdhgdhgfdhgzeka.pptx
 
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptxL04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
L04 - Control Structuresjhgjhgjhgjhgfjgfjhgfjgf.pptx
 
lkjhlkjhjhkjhlkjhkjhkjhkjhkjhkjhjhkjh.ppt
lkjhlkjhjhkjhlkjhkjhkjhkjhkjhkjhjhkjh.pptlkjhlkjhjhkjhlkjhkjhkjhkjhkjhkjhjhkjh.ppt
lkjhlkjhjhkjhlkjhkjhkjhkjhkjhkjhjhkjh.ppt
 
ehhhhhhhhhhhhhhhhhhhhhhhhhjjjjjllaye.pptx
ehhhhhhhhhhhhhhhhhhhhhhhhhjjjjjllaye.pptxehhhhhhhhhhhhhhhhhhhhhhhhhjjjjjllaye.pptx
ehhhhhhhhhhhhhhhhhhhhhhhhhjjjjjllaye.pptx
 
Database Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptxDatabase Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptx
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
 
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptxhjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
 
Chapter 08.pptx
Chapter 08.pptxChapter 08.pptx
Chapter 08.pptx
 
chaptet 4 DC and CN.ppt
chaptet 4 DC and CN.pptchaptet 4 DC and CN.ppt
chaptet 4 DC and CN.ppt
 
5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptx
 
chapter 1 DC and CN-1.ppt
chapter 1 DC and CN-1.pptchapter 1 DC and CN-1.ppt
chapter 1 DC and CN-1.ppt
 

Recently uploaded

Is Your BMW PDC Malfunctioning Discover How to Easily Reset It
Is Your BMW PDC Malfunctioning Discover How to Easily Reset ItIs Your BMW PDC Malfunctioning Discover How to Easily Reset It
Is Your BMW PDC Malfunctioning Discover How to Easily Reset ItEuroService Automotive
 
❤️Panchkula Enjoy 24/7 Escort Service sdf
❤️Panchkula Enjoy 24/7 Escort Service sdf❤️Panchkula Enjoy 24/7 Escort Service sdf
❤️Panchkula Enjoy 24/7 Escort Service sdfvershagrag
 
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一qh1ao5mm
 
SEM 922 MOTOR GRADER PARTS LIST, ALL WHEEL DRIVE
SEM 922 MOTOR GRADER PARTS LIST, ALL WHEEL DRIVESEM 922 MOTOR GRADER PARTS LIST, ALL WHEEL DRIVE
SEM 922 MOTOR GRADER PARTS LIST, ALL WHEEL DRIVEZhandosBuzheyev
 
Top profile Call Girls In dewas [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In dewas [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In dewas [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In dewas [ 7014168258 ] Call Me For Genuine Models We ...gajnagarg
 
West Bengal Factories Rules, 1958.bfpptx
West Bengal Factories Rules, 1958.bfpptxWest Bengal Factories Rules, 1958.bfpptx
West Bengal Factories Rules, 1958.bfpptxPankajBhagat45
 
+97470301568>>buy vape oil,thc oil weed,hash and cannabis oil in qatar doha}}
+97470301568>>buy vape oil,thc oil weed,hash and cannabis oil in qatar doha}}+97470301568>>buy vape oil,thc oil weed,hash and cannabis oil in qatar doha}}
+97470301568>>buy vape oil,thc oil weed,hash and cannabis oil in qatar doha}}Health
 
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样wsppdmt
 
一比一原版伯明翰城市大学毕业证成绩单留信学历认证
一比一原版伯明翰城市大学毕业证成绩单留信学历认证一比一原版伯明翰城市大学毕业证成绩单留信学历认证
一比一原版伯明翰城市大学毕业证成绩单留信学历认证62qaf0hi
 
Is Your Volvo XC90 Displaying Anti-Skid Service Required Alert Here's Why
Is Your Volvo XC90 Displaying Anti-Skid Service Required Alert Here's WhyIs Your Volvo XC90 Displaying Anti-Skid Service Required Alert Here's Why
Is Your Volvo XC90 Displaying Anti-Skid Service Required Alert Here's WhyBavarium Autoworks
 
Washim Call Girls 📞9332606886 Call Girls in Washim Escorts service book now C...
Washim Call Girls 📞9332606886 Call Girls in Washim Escorts service book now C...Washim Call Girls 📞9332606886 Call Girls in Washim Escorts service book now C...
Washim Call Girls 📞9332606886 Call Girls in Washim Escorts service book now C...Dipal Arora
 
如何办理(NCL毕业证书)纽卡斯尔大学毕业证毕业证成绩单原版一比一
如何办理(NCL毕业证书)纽卡斯尔大学毕业证毕业证成绩单原版一比一如何办理(NCL毕业证书)纽卡斯尔大学毕业证毕业证成绩单原版一比一
如何办理(NCL毕业证书)纽卡斯尔大学毕业证毕业证成绩单原版一比一avy6anjnd
 
Stacey+= Dubai Calls Girls O525547819 Call Girls In Dubai
Stacey+= Dubai Calls Girls O525547819 Call Girls In DubaiStacey+= Dubai Calls Girls O525547819 Call Girls In Dubai
Stacey+= Dubai Calls Girls O525547819 Call Girls In Dubaikojalkojal131
 
CELLULAR RESPIRATION. Helpful slides for
CELLULAR RESPIRATION. Helpful slides forCELLULAR RESPIRATION. Helpful slides for
CELLULAR RESPIRATION. Helpful slides foreuphemism22
 
Bhilai Escorts Service Girl ^ 8250092165, WhatsApp Anytime Bhilai
Bhilai Escorts Service Girl ^ 8250092165, WhatsApp Anytime BhilaiBhilai Escorts Service Girl ^ 8250092165, WhatsApp Anytime Bhilai
Bhilai Escorts Service Girl ^ 8250092165, WhatsApp Anytime Bhilaimeghakumariji156
 
Muslim Call Girls Churchgate WhatsApp +91-9930687706, Best Service
Muslim Call Girls Churchgate WhatsApp +91-9930687706, Best ServiceMuslim Call Girls Churchgate WhatsApp +91-9930687706, Best Service
Muslim Call Girls Churchgate WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
Top profile Call Girls In Thrissur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Thrissur [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Thrissur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Thrissur [ 7014168258 ] Call Me For Genuine Models ...nirzagarg
 
Top profile Call Girls In Ranchi [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Ranchi [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Ranchi [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Ranchi [ 7014168258 ] Call Me For Genuine Models We...gajnagarg
 
John deere 7200r 7230R 7260R Problems Repair Manual
John deere 7200r 7230R 7260R Problems Repair ManualJohn deere 7200r 7230R 7260R Problems Repair Manual
John deere 7200r 7230R 7260R Problems Repair ManualExcavator
 
一比一原版(Greenwich毕业证书)格林威治大学毕业证如何办理
一比一原版(Greenwich毕业证书)格林威治大学毕业证如何办理一比一原版(Greenwich毕业证书)格林威治大学毕业证如何办理
一比一原版(Greenwich毕业证书)格林威治大学毕业证如何办理bd2c5966a56d
 

Recently uploaded (20)

Is Your BMW PDC Malfunctioning Discover How to Easily Reset It
Is Your BMW PDC Malfunctioning Discover How to Easily Reset ItIs Your BMW PDC Malfunctioning Discover How to Easily Reset It
Is Your BMW PDC Malfunctioning Discover How to Easily Reset It
 
❤️Panchkula Enjoy 24/7 Escort Service sdf
❤️Panchkula Enjoy 24/7 Escort Service sdf❤️Panchkula Enjoy 24/7 Escort Service sdf
❤️Panchkula Enjoy 24/7 Escort Service sdf
 
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
在线定制(UBC毕业证书)英属哥伦比亚大学毕业证成绩单留信学历认证原版一比一
 
SEM 922 MOTOR GRADER PARTS LIST, ALL WHEEL DRIVE
SEM 922 MOTOR GRADER PARTS LIST, ALL WHEEL DRIVESEM 922 MOTOR GRADER PARTS LIST, ALL WHEEL DRIVE
SEM 922 MOTOR GRADER PARTS LIST, ALL WHEEL DRIVE
 
Top profile Call Girls In dewas [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In dewas [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In dewas [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In dewas [ 7014168258 ] Call Me For Genuine Models We ...
 
West Bengal Factories Rules, 1958.bfpptx
West Bengal Factories Rules, 1958.bfpptxWest Bengal Factories Rules, 1958.bfpptx
West Bengal Factories Rules, 1958.bfpptx
 
+97470301568>>buy vape oil,thc oil weed,hash and cannabis oil in qatar doha}}
+97470301568>>buy vape oil,thc oil weed,hash and cannabis oil in qatar doha}}+97470301568>>buy vape oil,thc oil weed,hash and cannabis oil in qatar doha}}
+97470301568>>buy vape oil,thc oil weed,hash and cannabis oil in qatar doha}}
 
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
一比一原版西安大略大学毕业证(UWO毕业证)成绩单原件一模一样
 
一比一原版伯明翰城市大学毕业证成绩单留信学历认证
一比一原版伯明翰城市大学毕业证成绩单留信学历认证一比一原版伯明翰城市大学毕业证成绩单留信学历认证
一比一原版伯明翰城市大学毕业证成绩单留信学历认证
 
Is Your Volvo XC90 Displaying Anti-Skid Service Required Alert Here's Why
Is Your Volvo XC90 Displaying Anti-Skid Service Required Alert Here's WhyIs Your Volvo XC90 Displaying Anti-Skid Service Required Alert Here's Why
Is Your Volvo XC90 Displaying Anti-Skid Service Required Alert Here's Why
 
Washim Call Girls 📞9332606886 Call Girls in Washim Escorts service book now C...
Washim Call Girls 📞9332606886 Call Girls in Washim Escorts service book now C...Washim Call Girls 📞9332606886 Call Girls in Washim Escorts service book now C...
Washim Call Girls 📞9332606886 Call Girls in Washim Escorts service book now C...
 
如何办理(NCL毕业证书)纽卡斯尔大学毕业证毕业证成绩单原版一比一
如何办理(NCL毕业证书)纽卡斯尔大学毕业证毕业证成绩单原版一比一如何办理(NCL毕业证书)纽卡斯尔大学毕业证毕业证成绩单原版一比一
如何办理(NCL毕业证书)纽卡斯尔大学毕业证毕业证成绩单原版一比一
 
Stacey+= Dubai Calls Girls O525547819 Call Girls In Dubai
Stacey+= Dubai Calls Girls O525547819 Call Girls In DubaiStacey+= Dubai Calls Girls O525547819 Call Girls In Dubai
Stacey+= Dubai Calls Girls O525547819 Call Girls In Dubai
 
CELLULAR RESPIRATION. Helpful slides for
CELLULAR RESPIRATION. Helpful slides forCELLULAR RESPIRATION. Helpful slides for
CELLULAR RESPIRATION. Helpful slides for
 
Bhilai Escorts Service Girl ^ 8250092165, WhatsApp Anytime Bhilai
Bhilai Escorts Service Girl ^ 8250092165, WhatsApp Anytime BhilaiBhilai Escorts Service Girl ^ 8250092165, WhatsApp Anytime Bhilai
Bhilai Escorts Service Girl ^ 8250092165, WhatsApp Anytime Bhilai
 
Muslim Call Girls Churchgate WhatsApp +91-9930687706, Best Service
Muslim Call Girls Churchgate WhatsApp +91-9930687706, Best ServiceMuslim Call Girls Churchgate WhatsApp +91-9930687706, Best Service
Muslim Call Girls Churchgate WhatsApp +91-9930687706, Best Service
 
Top profile Call Girls In Thrissur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Thrissur [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Thrissur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Thrissur [ 7014168258 ] Call Me For Genuine Models ...
 
Top profile Call Girls In Ranchi [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Ranchi [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Ranchi [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Ranchi [ 7014168258 ] Call Me For Genuine Models We...
 
John deere 7200r 7230R 7260R Problems Repair Manual
John deere 7200r 7230R 7260R Problems Repair ManualJohn deere 7200r 7230R 7260R Problems Repair Manual
John deere 7200r 7230R 7260R Problems Repair Manual
 
一比一原版(Greenwich毕业证书)格林威治大学毕业证如何办理
一比一原版(Greenwich毕业证书)格林威治大学毕业证如何办理一比一原版(Greenwich毕业证书)格林威治大学毕业证如何办理
一比一原版(Greenwich毕业证书)格林威治大学毕业证如何办理
 

Python.pptx

  • 1. PYTHON PROGRAMING Python Programming Lab Program Using Python 3.11 Instructor Name: Mr. Elias P. For Automotive Engineering 4rth Year Students
  • 2. Lab Objectives To write, test, and debug simple Python programs. To use operators in a python program. To implement Python programs with conditionals. To implement Python programs with loops. Use functions for structuring Python programs. Represent compound data using Python lists, tuples, and dictionaries.
  • 3. Lab Outcomes Upon completion of the course, students will be able to: Write, test, and debug simple Python programs. Use operators in a python program. Implement Python programs with conditionals. Implement Python programs with loops. Develop Python programs step-wise by defining functions and calling them. Use Python lists, tuples, dictionaries for representing compound data.
  • 4. Download and Install Python Setup Download the setup from the below link http://python.org/downloads/ Installation steps Step 1: Select Version of Python to Install. Step 2: Download Python Executable Installer. Step 3: Run Executable Installer. Step 4: Verify Python Was Installed on Windows. Step 5: Verify Pip Was Installed. Step 6: Add Python Path to Environment Variables (Optional)
  • 5. What is python Python is a popular programming language. It was created in 1991 by Guido Van Rossum. It is used for Web development Software development Data analysis Game development Desktop application Embedded application Introduction to Python
  • 6. Write python program to display hello world on the screen i.e print("hello world") Python First Program
  • 7. Python Variables Unlike other programming languages, Python has no command for declaring variable. A variable is created at the moment you first assign a value to it. Example X=5 # x is now type of int Y= “Elias” # Y is now type of string Print(x) Print(y) Variables do not need to be declared with any particular type and can even change type after they have been set.
  • 8. Python Variables Names A variable can have a short name (like x and y) or amore descriptive name like (age, fnam, lname, etc). Rules for naming Python variables A variable name must start with letter or 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 _) A variable names are case sensitive (age, Age and AGE are three different variables)
  • 9. Continued The python print statement is often used to output variables. To combine both text and a variable, Python uses the + character: Example X=“Intereting.” Print(“Python is “+ x) The output will be Python is Interesting.
  • 10. Python Data Types  Write a program to demonstrate different number data types and string in Python. INPUT a=10; #Integer Datatype b=11.5; #Float Datatype c=2.05j; #Complex Number xy="Automotive Engineering" print("a is Type of",type(a)); #prints type of variable a print("b is Type of",type(b)); #prints type of variable b print("c is Type of",type(c)); #prints type of variable c print("xy is Type of",type(xy)); #prints type of variable xy OUTPUT a is Type of <class ‘int’> b is Type of <class ‘float’> c is Type of <class ‘complex’> xy is Type of <class ‘str’>
  • 11. Reading input from Keyboard Write a python program that reads input(your full name) from keyboard and displays the result . Type the following code. Input fname=str(input("Please enter your first name :")) lname=str(input("Please enter your Last name :")) print("Your full name is" "n"+fname + " " +lname) Output Please enter your first name :ELIAS Please enter your Last name :PETROS Your full name is ELIAS PETROS
  • 12. ARTHIMETIC OPERATIONS INPUT Write a Python Program that accepts two numbers and make d/t arithmetic on it a = int(input ('Enter the first number:')) b = int(input ('Enter the second number:')) summ=a+b mul=a*b div=a/b fdiv=a//b modu=a%b print("Addition of a and b is :" +str(summ)) print("Multiplication of a and b is :" +str(mul)) print("Division of a and b is :" +str(div)) print("Floar Division of a and b is :" +str(fdiv)) print("Modulo devision of a and b is :" +str(modu)) OUTPUT Enter the first number:24 Enter the second number:13 Addition of a and b is :37 Multiplication of a and b is :312 Division of a and b is :1.8461538461538463 Floar Division of a and b is :1 Modulo devision of a and b is :11
  • 15. Python String Methods and Functions
  • 16. Python String Methods and Functions #isalnum() string= "bbc123" print(string.isalnum()) #isalpha()(add 2) string="campus" print(string.isalpha()) #isdigit() (add a letter) string="0123456789" print(string.isdigit()) string="012345689" print(string.isnumeric() ) string="Arba minch Sawla Campus" print(string.istitle()) string="Arba Minch Technology Campus" print(string.replace('Technology Campus','Univeristy')) OUTPUT True True True True False Arba Minch Univeristy
  • 17. Python String Methods and Functions
  • 18. Python String Methods and Functions Write a program to create, concatenate and print a string and accessing sub-string from a given string. INPUT s1=input("Enter first String : "); s2=input("Enter second String : "); print("First string is : ",s1); print("Second string is : ",s2); print("concatenations of two strings :",s1+s2); print("Substring of given string :",s1[1:4]); # prints strin g from 1 to 3 because array Indexing starts from 0 and ends at n-1. OUTPUT Enter first String: COMPUTER Enter second String: SCIENCE First String is : COMPUTER Second String is : SCIENCE Concatenations of two strings : COMPUTERSCIENCE Substring of given string: OMP
  • 19. Python Conditional (If ) Statement Write a python program which accept one integer number from keyboard then display the number when number is greater than 0 using python if statement. INPUT a = int(input ('Enter the number:')) if a > 0: print (a, "is greater than 0") OUTPUT It displays a if the entered number is greater than 0 Unless it cant display anything.
  • 20. Python Conditional(If-Else) Statements Write a python program which accept two integer numbers from keyboard then display which number is greater using python if-else statement. INPUT a = int(input ('Enter the first number:')) b = int(input ('Enter the second number:')) if a > b: print (a, "is greater than ", b) else: print (b, "is greater than ",a) OUTPUT Enter the first number:12 Enter the second number:23 23 is greater than 12
  • 21. Python Conditional(If-Elif- Else ) Statements Write a python program which takes numbers from keyboard then display the number is either positive, negative or 0 using python if-elif-else statement. INPUT number=int(input("Please enter the number you want to check ?")) if number>0: print("The number you entered is positive") elif number<0: print("The number you entered is negative") else : print("The number you entered is zero") OUTPUT Please enter the number you want to check ?32 The number you entered is positive
  • 22. Write a python sources code that accept students score then calculate the grade of the score? Note:- Score range and grade were provided as bellow Score range: Grade : 90-100 ===>A 80-89 ===>B 70-79 ===>C 60-69 ===> D Below 60 ===>F Python Conditional Nested(If-Elif- Else ) Statements
  • 23. Continued INPUT score=float(input("Please enter your score:")) if score>=90: print("Grade = A ") elif score>=80: print("Grade = B ") elif score>=70: print("Grade = C ") elif score>=60: print("Grade = D ") else : print("Grade = F ") OUTPUT Please enter your score:34 Grade = F