Python Programs List
Python Programs List
1. Write a Python program to find those numbers which are divisible by 7 and multiple of 5,
between 1500 and 2700 (both included).
4. Write a Python program to construct the following pattern, using a nested for loop.
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
5. Write a Python program that accepts a word from the user and reverse it.
6. Write a Python program to count the number of even and odd numbers from a series of
numbers.
Sample numbers : numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9)
Expected Output :
Number of even numbers : 5
Number of odd numbers : 4
7. Write a Python program that prints each item and its corresponding type from the
following list.
Sample List : datalist = [1452, 11.23, 1+2j, True, 'w3resource', (0, -1), [5, 12], {"class":'V',
"section":'A'}]
8. Write a Python program that prints all the numbers from 0 to 6 except 3 and 6.
Note : Use 'continue' statement.
Expected Output : 0 1 2 4 5
10. Write a Python program which iterates the integers from 1 to 50. For multiples of three
print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers
which are multiples of both three and five print "FizzBuzz".
5. Write a Python program to count the number of strings where the string length is 2 or more
and the first and last character are same from a given list of strings.
Sample List : ['abc', 'xyz', 'aba', '1221']
Expected Result : 2
6. Write a Python program to get a list, sorted in increasing order by the last element in each
tuple from a given list of non-empty tuples.
Sample List : [(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]
Expected Result : [(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)]
11. Write a Python function that takes two lists and returns True if they have at least one
common member.
12. Write a Python program to print a specified list after removing the 0th, 4th and 5th
elements.
Sample List : ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
Expected Output : ['Green', 'White', 'Black']
1. Write a Python program to check that a string contains only a certain set of characters (in
this case a-z, A-Z and 0-9).
2. Write a Python program that matches a string that has an a followed by zero or more b's.
3. Write a Python program that matches a string that has an a followed by one or more b's.
4. Write a Python program that matches a string that has an a followed by zero or one 'b'.
5. Write a Python program that matches a string that has an a followed by three 'b'.
6. Write a Python program that matches a string that has an a followed by two to three 'b'.
7. Write a Python program to find sequences of lowercase letters joined with a underscore.
8. Write a Python program to find the sequences of one upper case letter followed by lower
case letters.
9. Write a Python program that matches a string that has an 'a' followed by anything, ending
in 'b'.
10. Write a Python program that matches a word at the beginning of a string.
11. Write a Python program that matches a word at the end of string, with optional
punctuation.
Sample Dictionary :
dic1={1:10, 2:20}
dic2={3:30, 4:40}
dic3={5:50,6:60}
Expected Result : {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}
4. Write a Python script to check whether a given key already exists in a dictionary.
7. Write a Python script to print a dictionary where the keys are numbers between 1 and 15
(both included) and the values are square of keys.
Sample Dictionary
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14:
196, 15: 225}