Skip to content

Latest commit

 

History

History
159 lines (152 loc) · 11.8 KB

README.md

File metadata and controls

159 lines (152 loc) · 11.8 KB

100 Python Practice Problems

A collection of 100 Python practice problems designed to help you improve your coding skills. These problems cover a wide range of topics from basic programming concepts to more advanced exercises, including string manipulation, data structures, algorithms, and more.

Description

This repository contains a variety of Python practice problems suitable for beginners and intermediate programmers. Whether you're just starting out or looking to hone your skills, these exercises will challenge you and help you become more proficient in Python programming.

Problems List

  1. Find the Oldest Age: User will input three ages. Find the oldest one.
  2. Celsius to Fahrenheit Converter: Write a program that will convert Celsius value to Fahrenheit.
  3. Swap Two Numbers: User will input two numbers. Write a program to swap the numbers.
  4. Sum of Digits: Write a program that will give you the sum of 3 digits.
  5. Reverse a Number and Check: Write a program that will reverse a four-digit number and check whether the reverse is the same as the original.
  6. Odd or Even: Write a program that will tell whether the number entered by the user is odd or even.
  7. Leap Year Checker: Write a program that will tell whether the given year is a leap year or not.
  8. Euclidean Distance: Write a program to find the Euclidean distance between two coordinates.
  9. Triangle Checker: Write a program that takes user input of three angles and determines whether they can form a triangle.
  10. Profit or Loss Calculator: Write a program that will take user input of cost price and selling price and determine whether it’s a loss or a profit.
  11. Simple Interest Calculator: Write a program to find the simple interest when the value of the principal, rate of interest, and time period is given.
  12. Volume of Cylinder and Cost Calculator: Write a program to find the volume of a cylinder. Also, find the cost when the cost of 1 litre of milk is 40 Rs.
  13. Divisibility Checker: Write a program that will tell whether the given number is divisible by both 3 and 6.
  14. Angle Between Hour and Minute Hand: Solve the problem here.
  15. Overlapping Rectangles: Solve the problem here.
  16. Weather Predictor: Write a program that determines the weather based on user-provided temperature and humidity.
    • TEMPERATURE(C) | HUMIDITY(%) | WEATHER
    • >= 30 | >= 90 | Hot and Humid
    • >= 30 | < 90 | Hot
    • < 30 | >= 90 | Cool and Humid
    • < 30 | < 90 | Cool
  17. Sum of Squares: Write a program that will take three digits from the user and return the sum of the squares of each digit.
  18. Armstrong Number Checker: Write a program that will check whether the number is an Armstrong number or not.
  19. Narcissist Number Checker: Write a program that will take user input of a 4-digit number and check whether it is a narcissist number or not.
  20. In-Hand Salary Calculator: Write a program that will give you the in-hand salary after the deduction of HRA (10%), DA (5%), PF (3%), and tax:
    • Salary between 5-10 lakh – 10%
    • Salary between 11-20 lakh – 20%
    • Salary > 20 lakh – 30%
    • Salary < 1 lakh print k
  21. Unit Converter: Write a menu-driven program:
    1. cm to ft
    2. kl to miles
    3. USD to INR
    4. Exit
  22. Animal Count: Write a program that will tell the number of dogs and chickens based on the user-provided value of total heads and legs.
  23. Swap Numbers: Write a program to swap numbers.
  24. Sum of First n Numbers: Write a program to find the sum of the first n numbers, where n is provided by the user. E.g., if the user provides n=10, the output should be 55.
  25. Multiplication Without Operator: Write a program that can multiply two numbers provided by the user without using the * operator.
  26. Factorial Calculator: Write a program that can find the factorial of a given number provided by the user.
  27. First 25 Odd Numbers: Write a program to print the first 25 odd numbers.
  28. Prime Number Checker: Write a program to check whether a given number is prime.
  29. Armstrong Numbers in Range: Print all Armstrong numbers in the range of 100 to 1000.
  30. Population Growth: The current population of a town is 10,000. The population is increasing at a rate of 10% per year. Write a program to find out the population at the end of each of the last 10 years.
    • E.g., current population = 10,000:
    • 10th year - 10,000
    • 9th year - 9,000
    • 8th year - 8,100, and so on.
  31. Unique Combinations: Write a program to print all unique combinations of 1, 2, 3, and 4.
  32. HCF Calculator: User will provide two numbers. Find the HCF of those numbers.
  33. LCM Calculator: User will provide two numbers. Find the LCM of those numbers.
  34. First 25 Prime Numbers: Print the first 25 prime numbers.
  35. Fibonacci Series: Print the first 20 numbers of a Fibonacci series.
  36. Compound Interest Calculator: Write a program to find the compound interest.
  37. Number Series Calculator: Write a Python program that accepts an integer n and computes the value of n + nn + nnn.
  38. Digit Counter: Take a number from the user and find the number of digits in it.
  39. Factor Finder: Print all factors of a given number provided by the user.
  40. Reverse a Number: Find the reverse of a number provided by the user (any number of digits).
  41. Pattern 1:
    *
    **
    ***
    ****
    *****
    
  42. Pattern 2:
    *
    **
    ***
    **
    *
    
  43. Pattern 3:
    *
    * * *
    * * * * *
    * * * * * * *
    * * * * * * * * *
    
  44. Pattern 4:
    1
    1 2 1
    1 2 3 2 1
    1 2 3 4 3 2 1
    1 2 3 4 5 4 3 2 1
    
  45. Pattern 5:
    1
    2 3
    4 5 6
    7 8 9 10
    
  46. Sum of Series: Write a program to calculate the sum of the following series till the nth term: 1/1! + 2/2! + 3/3! + ... + n/n!
  47. Another Series Sum: Write a Python program to find the sum of the series till the nth term: 1 + x^2/2 + x^3/3 + ... + x^n/n, where n is provided by the user.
  48. Natural Logarithm Series: The natural logarithm can be approximated by a series. Write a program to calculate the sum of the first seven terms of this series, where x is input by the user.
  49. Sum and Average Calculator: Write a program that keeps accepting numbers from the user until the user enters zero. Display the sum and average of all the numbers.
  50. Fraction Simplifier: Write a program that accepts two numbers from the user—a numerator and a denominator—and then simplifies it.
    • E.g., if num = 5, den = 15, the answer should be .
    • E.g., if num = 6, den = 9, the answer should be .
  51. String Length without len(): Find the length of a given string without using the len() function.
  52. Extract Username from Email: Extract the username from a given email.
  53. Character Frequency Counter: Count the frequency of a particular character in a provided string.
    • E.g., in the string 'hello how are you', the frequency of 'h' is 2.
  54. Character Position Finder: Find the index position of a particular character in another string.
  55. Vowel Counter: Count the number of vowels in a string provided by the user.
  56. Character Remover: Write a program that can remove a particular character from a string.
  57. Palindrome Checker: Write a program that can check whether a given string is a palindrome.
  58. Remove Duplicates from List: Write a Python program to remove all the duplicates from a list.
  59. String to Title Case without title(): Write a Python program to convert a string to title case without using the title() function.
  60. Max Item in List without max(): Write a Python program to find the max item from a list without using the max() function.
  61. Reverse a List: Write a Python program to reverse a list.
  62. Search in List: Write a Python program to search for a given number in a list.
  63. Square List Items: Write a program that creates a new list from a given list where each item in the new list is the square of the item in the old list.
  64. Reverse Words in String: Write a program that can reverse the words of a given string.
    • E.g., if the input is Hello how are you, the output should be you are how Hello.
  65. Word Counter: Write a program that can count the number of words in a given string.
  66. Check Ascending Order: Write a program to check if a list is in ascending order or not.
  67. Separate Odd and Even Numbers: Create two lists from a given list where one list contains all the odd numbers and the other contains all the even numbers from the original list.
  68. Merge Two Lists without + Operator: Write a program to merge two lists without using the + operator.
  69. Replace Item in List: Write a program to replace an item with a different item if found in the list.
  70. Convert 2D List to 1D List: Write a program that can convert a 2D list to a 1D list.
  71. Union and Intersection of Lists: Write a program that can perform union and intersection on two given lists.
  72. Max Item of Each Row in Matrix: Write a program to find the max item of each row of a matrix.
  73. Integer to String Converter: Write a program that can convert an integer to a string.
  74. Matrix Shape: Write a program to print the shape of a matrix.
  75. Matrix Multiplication Feasibility: Write a program that can check if you can perform matrix multiplication on two matrices.
  76. Matrix Multiplication: Write a program to perform matrix multiplication on two matrices.
  77. Sort List without Built-in Function: Write a program that can sort a given unsorted list without using any built-in function for sorting.
  78. Most Used Word in Song: Write a program that can find the most used word in a Bollywood song.
  79. List to Dictionary Converter: Assume a list with numbers from 1 to 10, then convert it into a dictionary where the key is the number, and the value is the square of that number.
  80. Merge Two Dictionaries: Write a program to merge two given dictionaries.
  81. Swap Key-Value Pairs for Max and Min: Write a program to swap the key-value pair for max and min values.
    • E.g., if the dict is like this: {‘a’: 1, ‘b’: 2, ‘c’: 3}, the output should be {a: 3, b: 2, c: 1}.
  82. Histogram Generator: Write a program to find a histogram of a given set of numbers. Take the bin size from the user and print the result as a dictionary.
  83. Case Count in String: Write a function that accepts a string and returns the number of uppercase and lowercase characters as a dictionary.
  84. Bag of Words: Write a function that accepts a list of strings and performs Bag of Words, converting it to numerical vectors.
  85. Login and Registration: Write a dummy program that can perform login and registration using a menu-driven interface.
  86. Nearest Neighbor: Write a program that accepts neighbors (a set of 2D coordinates) and a point (a single 2D coordinate) and tells the nearest neighbor (in terms of Euclidean distance).
  87. Recursive Factorial Function: Write a function that accepts a number and returns its factorial. You cannot use any loop.

Happy coding! 🎉

Course Resources : click here