Python Programs for practice



We have prepared a list of top 50 Python programming example questions to help Freshers and Experienced Python Developers in their preparations for the interviews. You can also use these Python programs for practice to upskill yourself.

You will find these questions very helpful in your interviews. Prepare well and All the very best.

All the feedbacks and suggestions are most welocome.


  1. Count the number of each vowel in a string.

  2. Sort alphabetically the words form a string provided by the user.

  3. Transpose a matrix using nested loop.

  4. Multiply two matrices using nested loops.

  5. Write a program for handling file operation errors.

  6. Write a program to display student’s information using multiple inheritances.

  7. Write a program to display customer information using multilevel inheritance.

  8. Small Tasks below:

    • Write a Python program to calculate number of days between two dates.

      Sample dates: (2014, 7, 2), (2014, 7, 11)

    • Write a Python program to display the examination schedule.

    • Write a Python program to print the calendar of a given month and year.

    • Write a Python program to get file creation and modification date/times

    • Python program to convert time from 12 hour to 24 hour format

  9. Write a Python program to create a histogram from a given list of integers.

  10. Write a Python program that will accept the base and height of a triangle and compute the area.

  11. Write a Python program to compute the greatest common divisor (GCD) of two positive integers.

  12. Write a Python program to get the least common multiple (LCM) of two positive integers.

  13. Set of small tasks related to OS administration:

    • Write a Python program to get OS name, platform and release information.

    • Write a Python program to find out the number of CPUs using

    • Write a Python program to check whether a file exists

    • Write a Python program to list all files in a directory in Python

    • Write a python program to access environment variables.

  14. Write a python program to sum of the first n positive integers.

  15. Write a Python program to convert height (in feet and inches) to centimeters.

  16. Write a Python program to convert the distance (in feet) to inches, yards, and miles.

  17. Write a Python program to convert all units of time into seconds.

  18. Python program to print all Prime numbers in an Interval.

  19. Python Program for How to check if a given number is Fibonacci number?

  20. Python program to find second largest number in a list

  21. Write a program to remove duplicate elements from list.

  22. Python program to print even length words in a string

  23. Python | Count the Number of matching characters in a pair of string

  24. Remove all duplicates from a given string in Python

  25. Python | Program to check if a string contains any special character

  26. Python program to find the sum of all items in a dictionary

  27. Set of taks regarding pattern print:

    • Print an Inverted Star Pattern

    • Print Diamond Pattern

    • Program to print the pattern ‘G’

    • Program to print the given Z Pattern

    • Program to print the pattern "GFG"

    • Print the given pattern recursively

    • Program to print the pattern "D"

    • Program to print the pattern "H"

  28. Find the position from where the parenthesis is not balanced

  29. Write a program to get all substrings of given string

  30. Write a program to converts json data into python Dictionary

  31. Write a Python program to convert Python object to JSON data.

  32. Write a Python program to print a long text, convert the string to a list and print all the words and their frequencies.

  33. Write a Python program to count the number of each character of a given text of a text file.

  34. Write a Python program to get all strobogrammatic numbers that are of length n.

    A strobogrammatic number is a number whose numeral is rotationally symmetric, so that it appears the same when rotated 180 degrees. In other words, the numeral looks the same rightside up and upside down (e.g., 69, 96, 1001).

    For example:

    - Given n = 2, return ["11", "69", "88", "96"].
    
    - Given n = 3, return ['818', '111', '916', '619', '808', '101', '906', '609', '888', '181', '986', '689']
    
  35. Write a Python program to find the number of notes (Sample of notes: 10, 20, 50, 100, 200 and 500 ) against an given amount.

  36. Write a Python program to find the number of divisors of a given integer is even or odd.

  37. Write a Python program to combine each line from first file with the corresponding line in second file.

  38. Write a Python program to make two given strings (lower case, may or may not be of the same length) anagrams removing any characters from any of the strings.

  39. Write a Python program to count Uppercase, Lowercase, special character and numeric values in a given string.

  40. Perform following operations with Hospital Database

    • Connect to the database and print its version

    • Read given Hospital and Doctor Information

    • Get List Of Doctors as per Speciality

    • Get List of doctors within a given Hospital

    • update doctor experience in years

  41. Create a basic calculator using python GUI(Tkinter)

  42. Create a GUI application which for student info.(use mysql database backend)

  43. Create a GUI for login page and connect with database..

  44. Write a program for e-mail sending in python.

  45. Write a simple client-serveri(chatting) python program using socket.

  46. Write a program to print Armstrong number from 1 to 10000.

  47. Write a program to print Perfect number from 1 to 10000.

  48. Write a program to print Special number from 1 to 10000.

  49. Write a program to reverse alternative word in a given string.

  50. Write a program for following:

    input: a3b5c7
    
    output: adbgcj
    
  51. Write a program for following:

    input: a3b2c4
    
    output: aaabbcccc
    






You may also refer to other interview preparation articles:


You may also explore other articles in our bucket, Happy reading !!: