Python Programs PDF
Python Programs PDF
output
sum = 0
num=int(input("Enter any Number : "))
temp = num
while temp > 0:
digit = temp % 10
sum += (digit ** 3)
temp //= 10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
output
output
output
Enter a number:145
The number is a strong number
Enter a number:200
The number is not a strong number
5. write python program to check a number is odd or even.
num=int(input("Enter a number:"))
if(num%2==0):
print("The number is a Even number")
else:
print("The number is Odd number")
Output
Enter a number:100
The number is a Even number
Enter a number:201
The number is Odd number
n=int(input("Enter number:"))
temp=n
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
if(temp==rev):
print("The number is a palindrome!")
else:
print("The number isn't a palindrome!")
output
Enter number:161
The number is a palindrome!
Enter number:162
The number isn't a palindrome!
Output
import cmath
a = int(input('Enter a Value for a : '))
b = int(input('Enter a Value for b : '))
c = int(input('Enter a Value for c : '))
d = (b**2) - (4*a*c)
sol1 = (-b-cmath.sqrt(d))/(2*a)
sol2 = (-b+cmath.sqrt(d))/(2*a)
print('The solution are {0} and {1}'.format(sol1,sol2))
output
output
output
Enter a value : 5
120
output
Enter a Vaule : 10
1
23
456
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
output
output
14. Write a python program which produces its own source code as its output
output
x=open(f)
for i in x :
print(i)
output
output
output
output
Enter number: 10
Enter number: 20
30
5. Write a python program to subtract two numbers without using subtraction operator.( sum = a + ~b +
1)
output
Enter number: 20
Enter number: 30
-10
>>>
Enter number: 30
Enter number: 20
10
6. Write a python program to find largest among three numbers using binary minus operator.
7. Write a python program to find largest among three numbers using conditional operator
8. Write a python program to find out generic root of any number.
(Generic root: %d",(x=num%9)?x:9)
9. Write a python program to find out prime factor of given number.
10. Write a python program to find out NCR factor of given number.
11. How to convert string to int without using library functions in c
12. Program in c to print 1 to 100 without using loop
13. python program for swapping of two numbers
14. Program to find largest of n numbers in c
15. Split number into digits in python programming
16. python program to count number of digits in a number
Swapping
String
1. Write a python program to convert the string from upper case to lower case.
2. Write a python program to convert the string from lower case to upper case.
3. Write a python program to delete the all consonants from given string.
4. Write a python program to count the different types of characters in given string.
5. Write a python program to sort the characters of a string.
6. Write a python program for concatenation two strings without using string.h header file.
7. Write a python program to find the length of a string using pointer.
8. Write a python program which prints initial of any name.
9. Write a python program to print the string from given character.
10. Write a python program to reverse a string
11. Reverse a string using recursion in c
12. String concatenation in c without using strcat
13. How to compare two strings in c without using strcmp
14. String copy without using strcpy in c
15. Convert a string to ASCII in c
Matrix
1. Write a python program for addition of two matrices.
2. Write a python program for subtraction of two matrices
3. Write a python program for multiplication of two matrices.
4. Write a python program to find out sum of diagonal element of a matrix.
5. Write a python program to find out transport of a matrix.
6. Write a python program for scalar multiplication of matrix.
7. python program to find inverse of a matrix
8. Lower triangular matrix in c
9. Upper triangular matrix in c
10. Strassen's matrix multiplication program in c
11. python program to find determinant of a matrix
File
1. Write a python program to open a file and write some text and close its.
2. Write a python program to delete a file.
3. Write a python program to copy a file from one location to other location.
4. Write a python program to copy a data of file to other file.
5. Write a python program which display source code as a output.
6. Write a python program which writes string in the file.
7. Write a python program which reads string from file.
8. Write a python program which writes array in the file.
9. Write a python program which concatenate two file and write it third file.
10. Write a python program to find out size of any file.
11. Write a python program to know type of file.
12. Write a python program to know permission of any file.
13. Write a python program to know last date of modification of any file.
14. Write a python program to find size and drive of any file.
Complex number
1. Complex numbers program in c
2. Write a python program for addition and subtraction of two complex numbers.
3. Write a python program for multiplication of two complex numbers.
4. Write a python program for division two complex numbers.
Series
1. Write a python program to find out the sum of series 1 + 2 + …. + n.
2. Write a python program to find out the sum of series 1^2 + 2^2 + …. + n^2.
3. Write a python program to find out the sum of series 1^3 + 2^3 + …. + n^3.
4. Write a python program to find out the sum of given A.P.
5. Write a python program to find out the sum of given G.P.
6. Write a python program to find out the sum of given H.P.
7. Write a python program to find out the sum of series 1 + 2 + 4 + 8 … to infinity.
Array
1. Write a python program to find out largest element of an array.
2. Write a python program to find out second largest element of an unsorted array.
3. Write a python program to find out second smallest element of an unsorted array.
4. Write a python program which deletes the duplicate element of an array.
5. Write a python program for delete an element at desired position in an array.
6. Write a python program for insert an element at desired position in an array.
7. python program to find largest and smallest number in an array
Sorting
1. Write a python program for bubble sort.
2. Write a python program for insertion sort.
3. Write a python program for selection sort.
4. Write a python program for quick sort.
5. Write a python program for heap sort.
6. Write a python program for merge sort.
7. Write a python program for shell sort.
Recursion
1. Write a python program to find factorial of a number using recursion.
2. Write a python program to find GCD of a two numbers using recursion.
3. Write a python program to find out sum digits of a number using recursion.
4. Write a python program to find power of a number using function recursion.
5. Write a python program to reverse any number using recursion.
Searching
1. Write a python program for linear search.
2. Write a python program for binary search.
3. Write a python program for binary search using recursion.