SlideShare a Scribd company logo
Python Practical Questions
Python program to check whether the given
number is even or not.
number = input("Enter a number: ")
x = int(number)%2
if x == 0:
print("The number is Even.")
else:
print("The number is Odd.")
Output:
Enter a number: 7
The number is Odd.
Enter a number: 6
The number is Even.
Python program to convert the temperature
in degree centigrade to Fahrenheit
Output:
c = input("Enter temperature in
Centigrade: ")
f = (9*(int(c))/5)+32
print("Temperature in Fahrenheit is: ", f)
Enter temperature in Centigrade: 30
Temperature in Fahrenheit is: 86.0
Python program to find out the average of a set
of integers
Output:
count = int(input("Enter the count of numbers: "))
i = 0
sum = 0
for i in range(count):
x = int(input("Enter an integer: "))
sum = sum + x
avg = sum/count
print("The average is: ", avg)
Enter the count of numbers: 5
Enter an integer: 3
Enter an integer: 6
Enter an integer: 8
Enter an integer: 5
Enter an integer: 7
The average is: 5.8
Python program to find the circumference
and area of a circle with a given radius
Output:
r = float(input("Input the radius of the circle: "))
c = 2 * 3.14 * r
area = 3.14 * r * r
print("The circumference of the circle is: ", c)
print("The area of the circle is: ", area)
Input the radius of the circle: 7
The circumference of the circle is: 43.96
The area of the circle is: 153.86
Python program to check whether the given
integer is a multiple of both 5 and 7
Output:
number = int(input("Enter an integer: "))
if((number%5==0)and(number%7==0)):
print(number, "is a multiple of both 5 and 7")
else:
print(number, "is not a multiple of both 5 and 7")
Enter an integer: 33
33 is not a multiple of both 5 and 7
Python program to display the given integer
in a reverse manner
Output:
number = int(input("Enter a positive integer: "))
rev = 0
while(number!=0):
digit = number%10
rev = (rev*10)+digit
number = number//10
print(rev)
Enter a positive integer: 739
937
Python program to implement linear search
Output:
numbers = [4,2,7,1,8,3,6]
f = 0 #flag
x = int(input("Enter the number to be found out: "))
for i in range(len(numbers)):
if (x==numbers[i]):
print("Successful search, the element is found at position", i)
f = 1
break
if(f==0):
print("Oops! Search unsuccessful")
Enter the number to be found out: 7
Successful search, the element is found at position 2
Python Program to Find the Sum of all the
elements of a list
Output:
List=[2,6,12,8,32,17,15]
Sum = 0
for i in List:
Sum=Sum+i
print("The sum of the list elements =",Sum)
The sum of the list elements = 92
Program to accessing elements of a list using
loops
a= [32,55,7,12,65,32,90,27,12]
for i in a:
print(i)
Output
32
55
7
12
65
32
90
27
12 10
Program to generate a list of 10 even numbers
List=[]
for i in range(2,21,2):
List.append(i)
print(List)
Output
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

More Related Content

PDF
140+ Basic Python Programs This resource can assist you in preparing for your...
PDF
140+ Basic Python Programs This resource can assist you in preparing for your...
PDF
140+ Basic Python Programs This resource can assist you in preparing for your...
PDF
140 pythonexercises en -puyhon pour apprendre Ă  programmer.pdf
PPTX
PYTHON PROGRAMMING INTERVIEW QUESTIONS.pptx
DOCX
CBSE Class 12 Computer practical Python Programs and MYSQL
PDF
introduction to python programming course 2
PDF
Python Programming Laboratory Manual for Students
140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...
140+ Basic Python Programs This resource can assist you in preparing for your...
140 pythonexercises en -puyhon pour apprendre Ă  programmer.pdf
PYTHON PROGRAMMING INTERVIEW QUESTIONS.pptx
CBSE Class 12 Computer practical Python Programs and MYSQL
introduction to python programming course 2
Python Programming Laboratory Manual for Students

Similar to Python..._Practical_.goated programs.pptx (20)

PPTX
python_1.pptx
PDF
Sasin nisar
PDF
python lab programs.pdf
DOCX
Python Math Concepts Book
PDF
Class 2: Welcome part 2
PDF
Python Lab Manual
PPTX
Python Question - Python Assignment Help
PPTX
Python.pptx
PDF
Python programs
PDF
Lecture 5 numbers and built in functions
PPTX
loops _
PDF
pythonQuick.pdf
PDF
python 34💭.pdf
PDF
python notes.pdf
PDF
Introduction to phyton , important topic
PDF
Some hours of python
PDF
Practical File waale code.pdf
PDF
Python_Unit_1.pdf
PPTX
lecture 2.pptx
PPTX
made it easy: python quick reference for beginners
python_1.pptx
Sasin nisar
python lab programs.pdf
Python Math Concepts Book
Class 2: Welcome part 2
Python Lab Manual
Python Question - Python Assignment Help
Python.pptx
Python programs
Lecture 5 numbers and built in functions
loops _
pythonQuick.pdf
python 34💭.pdf
python notes.pdf
Introduction to phyton , important topic
Some hours of python
Practical File waale code.pdf
Python_Unit_1.pdf
lecture 2.pptx
made it easy: python quick reference for beginners
Ad

Recently uploaded (20)

PDF
International_Financial_Reporting_Standa.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
My India Quiz Book_20210205121199924.pdf
PPTX
History, Philosophy and sociology of education (1).pptx
 
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
Complications of Minimal Access-Surgery.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PPTX
Virtual and Augmented Reality in Current Scenario
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
Empowerment Technology for Senior High School Guide
International_Financial_Reporting_Standa.pdf
Weekly quiz Compilation Jan -July 25.pdf
My India Quiz Book_20210205121199924.pdf
History, Philosophy and sociology of education (1).pptx
 
TNA_Presentation-1-Final(SAVE)) (1).pptx
What if we spent less time fighting change, and more time building what’s rig...
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Complications of Minimal Access-Surgery.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
Virtual and Augmented Reality in Current Scenario
Paper A Mock Exam 9_ Attempt review.pdf.
Cambridge-Practice-Tests-for-IELTS-12.docx
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
Empowerment Technology for Senior High School Guide
Ad

Python..._Practical_.goated programs.pptx

  • 2. Python program to check whether the given number is even or not. number = input("Enter a number: ") x = int(number)%2 if x == 0: print("The number is Even.") else: print("The number is Odd.") Output: Enter a number: 7 The number is Odd. Enter a number: 6 The number is Even.
  • 3. Python program to convert the temperature in degree centigrade to Fahrenheit Output: c = input("Enter temperature in Centigrade: ") f = (9*(int(c))/5)+32 print("Temperature in Fahrenheit is: ", f) Enter temperature in Centigrade: 30 Temperature in Fahrenheit is: 86.0
  • 4. Python program to find out the average of a set of integers Output: count = int(input("Enter the count of numbers: ")) i = 0 sum = 0 for i in range(count): x = int(input("Enter an integer: ")) sum = sum + x avg = sum/count print("The average is: ", avg) Enter the count of numbers: 5 Enter an integer: 3 Enter an integer: 6 Enter an integer: 8 Enter an integer: 5 Enter an integer: 7 The average is: 5.8
  • 5. Python program to find the circumference and area of a circle with a given radius Output: r = float(input("Input the radius of the circle: ")) c = 2 * 3.14 * r area = 3.14 * r * r print("The circumference of the circle is: ", c) print("The area of the circle is: ", area) Input the radius of the circle: 7 The circumference of the circle is: 43.96 The area of the circle is: 153.86
  • 6. Python program to check whether the given integer is a multiple of both 5 and 7 Output: number = int(input("Enter an integer: ")) if((number%5==0)and(number%7==0)): print(number, "is a multiple of both 5 and 7") else: print(number, "is not a multiple of both 5 and 7") Enter an integer: 33 33 is not a multiple of both 5 and 7
  • 7. Python program to display the given integer in a reverse manner Output: number = int(input("Enter a positive integer: ")) rev = 0 while(number!=0): digit = number%10 rev = (rev*10)+digit number = number//10 print(rev) Enter a positive integer: 739 937
  • 8. Python program to implement linear search Output: numbers = [4,2,7,1,8,3,6] f = 0 #flag x = int(input("Enter the number to be found out: ")) for i in range(len(numbers)): if (x==numbers[i]): print("Successful search, the element is found at position", i) f = 1 break if(f==0): print("Oops! Search unsuccessful") Enter the number to be found out: 7 Successful search, the element is found at position 2
  • 9. Python Program to Find the Sum of all the elements of a list Output: List=[2,6,12,8,32,17,15] Sum = 0 for i in List: Sum=Sum+i print("The sum of the list elements =",Sum) The sum of the list elements = 92
  • 10. Program to accessing elements of a list using loops a= [32,55,7,12,65,32,90,27,12] for i in a: print(i) Output 32 55 7 12 65 32 90 27 12 10
  • 11. Program to generate a list of 10 even numbers List=[] for i in range(2,21,2): List.append(i) print(List) Output [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]