Professional Documents
Culture Documents
PDF 25:12:2023 15:00:57-1
PDF 25:12:2023 15:00:57-1
PDF 25:12:2023 15:00:57-1
INDEX
S. Program Date Signature
No.
1. Sum & Product of a number 12-04-2023
2. Square & Cube of number 15-04-2023
3. Arithmetic operations 17-04-2023
4. Print Table of a number 27-04-2023
5. Maximum of numbers 28-04-2023
6. Prime Number 28-04-2023
7. Swapping of two number 04-07-2022
8. Operations on Circle 07-07-2023
9. Compound Interest 11-07-2023
10. Palindrome Number 12-07-2023
11. Operation on Circle using function 14-07-2023
12. Integer and Character Value 20-07-2023
13. Number, Alphabet or Special Character 22-07-2023
14. Checking divisibility 24-07-2023
15. Factorial of a number 24-07-2023
16. Armstrong number 28-07-2023
17. Fibonacci Series 28-07-2023
18. Printing patterns 01-08-2023
19. Sorting of list elements 01-08-2023
20. Working on Dictionaries 02-08-2023
21. String palindrome 11-08-2023
22. Binary Search 12-08-2023
23. Linear search 14-08-2023
24. Random numbers 17-08-2023
25. Writing data into file 18-08-2023
26. Displaying file contents 19-08-2023
27. Counting characters in data file 21-08-2023
28. Counting words in text file 26-08-2023
29. Most common word 28-08-2023
30. Longest word in text file 28-08-2023
31. Text File Operations 29-08-2023
32. Transferring text from files 29-08-2023
33. Counting words in text file - split function 01-09-2023
34. CSV file Operations 01-09-2023
35. Vowels in text file 02-09-2023
36. CSV file 04-09-2023
37. Read write data from CSV file 08-09-2023
38. Vowels and consonants in text file 09-09-2023
39. Read and display CSV file 13-09-2023
40. Stack in Python 17-10-2023
41. Stack (Push-Pop) 20-10-2023
42. Stack Operations 26-10-2023
43. Python-MySQL 28-10-2023
44. Python-MySQL 02-11-2023
45. Python-MySQL 03-11-2023
46. Python-MySQL 04-11-2023
47. Python-MySQL 22-11-2023
48. MySQL 23-11-2023
PROGRAM : 1
# Write a python program to take input for 2 numbers, calculate and print their sum,
product and difference?
s=a+b
p=a*b
if(a>b):
d=a-b
else:
d=b-a
print("Sum = ",s)
print("Product = ",p)
print("Difference = ",d)
PROGRAM : 2
#Write a python Program to take input for a number, calculate and print its square
and cube?
b=a*a
c=a*a*a
print("Square = ",b)
print("cube = ",c)
PROGRAM : 3
# Menu based program to find sum, subtraction, multiplication and division of values.
if choice==1 :
c=a+b
elif choice==2 :
c=a-b
c=a*b
elif choice==4 :
c=a/b
else :
print("Wrong choice")
PROGRAM : 4
#Write a python program to take input for 3 numbers, check and print the largest
number?
m=a
else:
if(b>c):
m=b
else:
m=c
print("Max no = ",m)
PROGRAM : 6
for i in range(2,num):
if num % I == 0:
break;
else:
temp = x
x=y
y = temp
print("\n\nAfter swapping")
print("\n\nBefore swapping")
swap(num1,num2)
PROGRAM : 8
import math
def cal_Diameter(radius):
return 2 * radius
def cal_Circum(radius):
def cal_Area(radius):
diameter = cal_Diameter(r)
circumference = cal_Circum(r)
area = cal_Area(r)
x=(1+r/100)**t
CI= p*x-p
n=num
res=0
while num>0:
rem=num%10
res=rem+res*10
num=num//10
if res==n:
print("Number is Palindrome")
else:
import math
def cal_Diameter(radius):
return 2 * radius
def cal_Circum(radius):
def cal_Area(radius):
diameter = cal_Diameter(r)
circumference = cal_Circum(r)
area = cal_Area(r)
var=True
while var:
if choice==1:
print(ord(ch))
elif choice==2:
print(chr(val))
else:
option=input()
if option=='y' or option=='Y':
var=True
else:
var=False
PROGRAM : 13
if ch.isalpha():
elif ch.isdigit():
elif ch.isalnum():
else:
num=float(input('Enter a number'))
if num%2==0:
if num%3==0:
else:
else:
if num%3==0:
else:
def factorial(n):
if n == 1:
return n
else:
return n*factorial(n-1)
if num < 0:
elif num == 0:
else:
#Write a python program to take input for a number check if the entered number is
Armstrong or not.
n1=n
s=0
while(n>0):
d=n%10
s=s + (d *d * d)
n=int(n/10)
if s==n1:
print("Armstrong Number")
else:
def fibonacci(n):
if n<=1:
return n
else:
return(fibonacci(n-1)+fibonacci(n-2))
for i in range(num):
'''*
**
***
****
*****'''
for i in range(1,6):
print()
for j in range(1,i+1):
print ('*',end="")
PROGRAM : 19
aList=[10,5,1,3]
print("Original List",aList)
n=len(aList)
for i in range(n-1):
for j in range(0,n-i-1):
if aList[j]>aList[j+1]:
aList[j],aList[j+1]=aList[j+1],aList[j]
print("Sorted List",aList)
PROGRAM : 20
d1=dict(),i=1
while i<=n:
c=input("enter country:")
cap=input("enter capital:")
d1[c]=[cap,curr]
i=i+1
l=d1.keys()
print("\ncountry\t\t","capital\t\t","currency")
for i in l:
z=d1[i]
print(i,'\t\t',end=" ")
for j in z:
print(j,'\t\t',end='\t\t')
for i in l:
if i==x:
print("\ncountry\t\t","capital\t\t","currency\t\t")
z=d1[i]
print(i,'\t\t',end=" ")
for j in z:
print(j,'\t\t',end="\t")
break
PROGRAM : 21
def isStringPalindrome(str):
if len(str)<=1:
return True
else:
if str[0]==str[-1]:
return isStringPalindrome(str[1:-1])
else:
return False
#__main__
y=isStringPalindrome(s)
if y==True:
print("String is Palindrome")
else:
if LB>UB:
mid=int((LB+UB)/2)
if item==sequence[mid]:
return mid
elif item<sequence[mid]:
UB=mid-1
else:
LB=mid+1
n=len(L)
found=Binary_Search(L,element,0,n-1)
if found>=0:
else:
n=len(L)
for i in range(n):
if L[i]==item:
break
else:
import random
n=random.randint(1,6)
if n==guess:
else:
# Program to write rollno, name and marks of a student in a data file Marks.dat.
fileout=open("Marks.dat","a")
for i in range(count):
rollno=int(input("Enter rollno:"))
name=input("name")
marks=float(input('marks'))
rec=str(rollno)+","+name+","+str(marks)+"\n"
fileout.write(rec)
fileout.close()
PROGRAM : 26
fileinp=open("Marks.dat","r")
while str:
str=fileinp.readline()
print(str)
fileinp.close()
PROGRAM : 27
file1=open("D:\\data.txt","r")
ch=" "
count=0
while ch:
ch=file1.read(1)
count+=1
print("Number of characters=",count)
file1.close()
PROGRAM : 28
file1=open("D:\\data.txt","r")
line=" "
count=0
while line:
line=file1.readline()
s=line.split()
for word in s:
count+=1
print("Number of words=",count)
file1.close()
PROGRAM : 29
import collections
fin = open('D:\\data.txt','r')
a= fin.read()
d={ }
L=a.lower().split()
for word in L:
word = word.replace(".","")
word = word.replace(",","")
word = word.replace(":","")
word = word.replace("\"","")
word = word.replace("!","")
word = word.replace("&","")
word = word.replace("*","")
for k in L:
key=k
if key not in d:
count=L.count(key)
d[key]=count
word_counter = collections.Counter(d)
fin.close()
PROGRAM : 30
fin = open("name.txt","r")
str = fin.read()
words = str.split()
if len(word)==max_len:
longest_word =word
print(longest_word)
PROGRAM : 31
# Write a python program to read a file named "filedetail.txt", count and print the
following:
"""
"""
def count():
a=0
ua=0
la=0
d=0
sp=0
spl=0
f= open("D:\filedetail.txt")
while True:
c=f.read(1)
if not c:
break
print(c,end=' ')
a=a+1
if((c>='A' and c<='Z') or (c>='a' and c<='z')):
a=a+1
ua=ua+1
else:
la=la+1
d=d+1
sp=sp+1
else:
spl=spl+1
# function calling
count()