List OF Python Programs
1. Python Program to Find the Largest Among Three Numbers
2. Python Program to Find Numbers Divisible by Another Number
3. Python Program to Check Leap Year
4. Find the Largest Among Three Numbers
5. Find HCF or GCD
6. Python Function to Add Two Numbers passed as parameters.
7. Make a Simple Calculator
8. Check Prime Number
9. Print all Prime Numbers in an Interval
10. Find the Factorial of a Number
11. Find Sum of Natural Numbers Using Recursion
12. Write a Python program of recursion list sum.
13. Check if a Number is Positive, Negative or 0
14. Find Factors of Number
15. Print the Fibonacci sequence
16. Check Prime Number
17. Check Armstrong Number
18. Find Armstrong Number in an Interval
19. Convert Decimal to Binary, Octal
and Hexadecimal
20. Find ASCII Value of Character
21. Python Program to Display Fibonacci Sequence Using Recursion
22. Here is an example to make a list with each item being increasing power of 2. What will
be output
a. pow2 = [2 ** x for x in range(10)]
b. print(pow2)
23. Python Program to Add Two Matrices
24. Python Program to Transpose a Matrix
25. Python Program to Check Whether a String is Palindrome or Not
26. Python Program to Sort Words in Alphabetic Order
27. Python Program to Count the Number of Each Vowel in a string entered by user.
28. Python Program to Remove Punctuations From a String
29. Python function to count the number of times a specific number is repeated in a list
passed as parameter.
30. Write a Python program to get the factorial of a non-negative integer
31. Find the reverse of a 5 digit number using recursion.
32. Write a Python function that accepts a string and calculate the number of upper case
letters and lower case letters
33. Write a Python function that takes a list and returns a new list with unique elements of
the first list.
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]
Practice String and List Methods
Python String Methods
capitalize() - Returns the string with first letter capitalized and the rest
lowercased.
casefold() - Returns a lowercase string, generally used for caseless matching.
This is more aggressive than the lower() method.
center() - Center the string within the specified width with optional fill character.
count() - Count the non-overlapping occurrence of supplied substring in the
string.
encode() - Return the encoded version of the string as a bytes object.
endswith() - Returns ture if the string ends with the supplied substring.
expandtabs() - Return a string where all the tab characters are replaced by the
supplied number of spaces.
find() - Return the index of the first occurrence of supplied substring in the string.
Return -1 if not found.
format() - Format the given string.
format_map() - Format the given string.
index() - Return the index of the first occurrence of supplied substring in the
string. Raise ValueError if not found.
isalnum() - Return true if the string is non-empty and all characters are
alphanumeric.
isalpha() - Return true if the string is non-empty and all characters are alphabetic.
isdecimal() - Return true if the string is non-empty and all characters are decimal
characters.
isdigit() - Return true if the string is non-empty and all characters are digits.
isidentifier() - Return true if the string is a valid identifier.
islower() - Return true if the string has all lowercased characters and at least one
is cased character.
isnumeric() - Return true if the string is non-empty and all characters are
numeric.
isprintable() - Return true if the string is empty or all characters are printable.
isspace() - Return true if the string is non-empty and all characters are
whitespaces.
istitle() - Return true if the string is non-empty and titlecased.
isupper() - Return true if the string has all uppercased characters and at least
one is cased character.
join() - Concatenate strings in the provided iterable with separator between them
being the string providing this method.
ljust() - Left justify the string in the provided width with optional fill characters.
lower() - Return a copy of all lowercased string.
lstrip() - Return a string with provided leading characters removed.
maketrans() - Return a translation table.
partition() - Partition the string at first occurrence of substring (separator) and
return a 3-tuple with part before separator, the separator and part after separator.
replace() - Replace all old substrings with new substrings.
rfind() - Return the index of the last occurrence of supplied substring in the string.
Return -1 if not found.
rindex() - Return the index of the last occurrence of supplied substring in the
string. Raise ValueError if not found.
rjust() - Right justify the string in the provided width with optional fill characters.
rpartition() - Partition the string at last occurrence of substring (separator) and
return a 3-tuple with part before separator, the separator and part after separator.
rsplit() - Return a list of words delimited by the provided subtring. If maximum
number of split is specified, it is done from the right.
rstrip() - Return a string with provided trailing characters removed.
split() - Return a list of words delimited by the provided subtring. If maximum
number of split is specified, it is done from the left.
splitlines() - Return a list of lines in the string.
startswith() - Return true if the string starts with the provided substring.
strip() - Return a string with provided leading and trailing characters removed.
swapcase() - Return a string with lowercase characters converted to uppercase
and vice versa.
title() - Return a title (first character of each word capitalized, others lowercased)
cased string.
translate() - Return a copy of string that has been mapped according to the
provided map.
upper() - Return a copy of all uppercased string.
zfill() - Return a numeric string left filled with zeros in the provided width.
Python List Methods
append() - Add an element to the end of the list
extend() - Add all elements of a list to the another list
insert() - Insert an item at the defined index
remove() - Removes an item from the list
pop() - Removes and returns an element at the given index
clear() - Removes all items from the list
index() - Returns the index of the first matched item
count() - Returns the count of number of items passed as an argument
sort() - Sort items in a list in ascending order
reverse() - Reverse the order of items in the list
copy() - Returns a shallow copy of the list