0% found this document useful (0 votes)
2 views4 pages

Python Practical File Full

The document outlines a practical file for Python programming, detailing 15 exercises including printing a poem, performing arithmetic operations, and calculating factorials. Each exercise includes the aim, program code, and a note that the program executed successfully. The exercises cover basic programming concepts such as loops, conditionals, and string manipulation.
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)
2 views4 pages

Python Practical File Full

The document outlines a practical file for Python programming, detailing 15 exercises including printing a poem, performing arithmetic operations, and calculating factorials. Each exercise includes the aim, program code, and a note that the program executed successfully. The exercises cover basic programming concepts such as loops, conditionals, and string manipulation.
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 FILE

1. Print a Small Poem


Aim: To write and execute the program.
Program:
print("Twinkle, Twinkle, Little Star")
print("How I wonder what you are!")

Result: Program executed successfully.

2. Arithmetic Operations
Aim: To write and execute the program.
Program:
a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
print("Addition =",a+b)
print("Subtraction =",a-b)
print("Multiplication =",a*b)
print("Division =",a/b)

Result: Program executed successfully.

3. Squares of List Elements


Aim: To write and execute the program.
Program:
lst=[8,2,11,20,6]
for i in lst:
print(i*i)

Result: Program executed successfully.

4. Sum of Natural Numbers


Aim: To write and execute the program.
Program:
n=int(input("Enter a number: "))
s=0
for i in range(1,n+1):
s+=i
print("Sum =",s)

Result: Program executed successfully.

5. Count Vowels and Consonants


Aim: To write and execute the program.
Program:
s=input("Enter a string: ")
v=c=0
for ch in [Link]():
if [Link]():
if ch in "aeiou":
v+=1
else:
c+=1
print("Vowels =",v)
print("Consonants =",c)
Result: Program executed successfully.

6. Reverse a String
Aim: To write and execute the program.
Program:
s=input("Enter a string: ")
print(s[::-1])

Result: Program executed successfully.

7. Factorial
Aim: To write and execute the program.
Program:
n=int(input())
fact=1
for i in range(1,n+1):
fact*=i
print(fact)

Result: Program executed successfully.

8. Triangle Type
Aim: To write and execute the program.
Program:
a=float(input())
b=float(input())
c=float(input())
if a+b>c and a+c>b and b+c>a:
if a==b==c:
print("Equilateral")
elif a==b or b==c or a==c:
print("Isosceles")
else:
print("Scalene")
else:
print("Triangle cannot be formed")

Result: Program executed successfully.

9. LCM of Two Numbers


Aim: To write and execute the program.
Program:
a=int(input())
b=int(input())
g=max(a,b)
while True:
if g%a==0 and g%b==0:
print("LCM =",g)
break
g+=1

Result: Program executed successfully.

10. Palindrome Number


Aim: To write and execute the program.
Program:
n=input()
if n==n[::-1]:
print("Palindrome")
else:
print("Not Palindrome")

Result: Program executed successfully.

11. Prime Number


Aim: To write and execute the program.
Program:
n=int(input())
if n>1:
for i in range(2,n):
if n%i==0:
print("Not Prime")
break
else:
print("Prime")
else:
print("Not Prime")

Result: Program executed successfully.

12. Swap Without Third Variable


Aim: To write and execute the program.
Program:
a=int(input())
b=int(input())
a,b=b,a
print(a,b)

Result: Program executed successfully.

13. Print n², n³ and n■


Aim: To write and execute the program.
Program:
n=int(input())
print(n**2)
print(n**3)
print(n**4)

Result: Program executed successfully.

14. Simple Interest and Compound Interest


Aim: To write and execute the program.
Program:
p=float(input())
r=float(input())
t=float(input())
si=(p*r*t)/100
ci=p*((1+r/100)**t)-p
print("SI =",si)
print("CI =",ci)

Result: Program executed successfully.


15. Student Details
Aim: To write and execute the program.
Program:
name=input("Name: ")
cls=input("Class: ")
age=input("Age: ")
print(name,cls,age)
print()
print()
print(name)
print(cls)
print(age)

Result: Program executed successfully.

You might also like