0% found this document useful (0 votes)
3 views9 pages

Python Practical Programs

The document contains a series of Python practical questions covering various programming concepts. Topics include temperature conversion, area calculations for different shapes, student mark lists, turtle graphics, counting occurrences in a tuple, identifying even and odd numbers, calculating factorials, finding prime numbers, and reversing a string word by word. Each section provides code snippets demonstrating the implementation of these concepts.

Uploaded by

arulrajb67
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views9 pages

Python Practical Programs

The document contains a series of Python practical questions covering various programming concepts. Topics include temperature conversion, area calculations for different shapes, student mark lists, turtle graphics, counting occurrences in a tuple, identifying even and odd numbers, calculating factorials, finding prime numbers, and reversing a string word by word. Each section provides code snippets demonstrating the implementation of these concepts.

Uploaded by

arulrajb67
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON PRACTICAL QUESTIONS

1. CONVERSION OF TEMPERATURE
print("\t\tConversion Of Temperature ") print("\n [Link] from
celsius to fahrenheit. \n 2. convert from fahrenheit to celsius.")
a=int(input("Enter your choice : ")) if(a==1): c=float(input("enter
temperature in celsius :")) f=(c*1.8)+32 print("the converted
temperature from celcius to fahrenheit is : ",f) else:
f=float(input("Enter temperature in fahrenheit :")) c=(f/1.8)-32
print("the converted temperature from fahrenheit to celcius is :
",c)
2. FIND THE AREA OF RECTANGLE, SQUARE, CIRCLE AND
TRIANGLE
l=int(input("Enter length :")) a=int(input("Enter area :"))
r=int(input("Enter radius :")) h=int(input("Enter heigth :"))
b=int(input("Enter breath : ")) def rectangle(l,b): return(l*b) def
square(a): return(a*a) def circle(r): return(3.14*r*r) def
triangle(b,h): return(b*h) print(rectangle(l,b),'\n',square(a),'\n'
,circle(r),'\n',triangle(b,h))
3. STUDENT MARK LIST
print("\t\tStudent marks Database ") sub1=int(input("enter mark 1
:")) sub2=int(input("enter mark 2 :")) sub3=int(input("enter mark 3
: ")) sub4=int(input("enter mark 4 : ")) sub5=int(input("enter mark
5 : ")) total =(sub1+sub2+sub3+sub4+sub5) avg=total/5
print(total,avg) if(avg>=90): print("A Grade") elif(avg>=80):
print("B Grade") else: print("FAIL")
4. TURTLE GRAPHICS
import turtle screen=[Link]() [Link]("TURTLE
GRAPHICS") t=[Link]() [Link](0) for i in range(4):
[Link](100) [Link](90) [Link]
5. COUNT THE OCCURRENCES OF ALL ITEMS OF THE LIST IN
THE TUPLE
def _occurence(): tuple_input=('a','b','c','d','a','b')
list_input=['a','b'] count=0 for item in list_input: count +=
tuple_input.count(item) print(f"tuple : {tuple_input}")
print(f"list :{list_input}") print(f"Total occurence :{count}")
_occurence()
6. COUNT THE NUMBER OF EVEN AND ODD NUMBERS
n=list(map(int,input("enter numbers :").split())) even=0 odd=0 for
i in n: if i%2==0: even+=1 else: odd+=1 print("Odd numbers :",odd)
print("Even numbers :",even)
7. FACTORIAL OF ‘n’ NUMBERS
def fact(n): if n==0: return 1 else: return n*fact(n-1)
n=int(input("Enter a number :")) print("factorial of
",n,"is",fact(n))
8. PRIME NUMBERS LESS THAN 20
print("Prime numbers less than 20 are:") for num in range(2, 20):
for i in range(2, num): if num % i == 0: break else: print(num)
9. REVERSE A STRING WORD BY WORD
class string_reverse: def reverse_words(self,text):
words=[Link]() reversed_words=words[::-1] return '
'.join(reversed_words) reverse=string_reverse() text=input("Enter a
String : ") result=reverse.reverse_words(text)
print("Reversed:",result)

You might also like