Welcome to the Python Practice Questions repository! This repository is designed to help you enhance your Python programming skills through a structured set of practice questions. Whether you're a beginner looking to build a strong foundation or an experienced developer aiming to sharpen your Python skills, this repository is for you.
Python is a versatile and widely-used programming language known for its simplicity and readability. It's an excellent choice for a wide range of applications, from web development to data analysis and machine learning. To become proficient in Python, it's essential to practice and apply your knowledge.
The Python Practice Questions repository offers a comprehensive set of practice questions divided into weeks, with each week containing daily exercises. This structured approach allows you to progress gradually and steadily improve your Python skills.
You can use these practice questions to:
- Reinforce your understanding of Python fundamentals.
- Explore more advanced Python concepts and problem-solving.
- Develop practical coding skills through real-world examples.
Simply follow the weekly structure, starting with Week 1, and work through the questions day by day. Each question comes with a suggested list of concepts you should be familiar with to tackle the task successfully. If you're just getting started with Python, begin with Week 1 and gradually progress through the weeks.
We welcome contributions to improve this repository and make it a valuable resource for Python learners. Here's how you can contribute:
-
Fork the Repository: Click the "Fork" button in the upper right corner of the repository to create your copy.
-
Create a New Branch: After forking, create a new branch for your contributions. We recommend naming the branch after your name or the feature you're working on.
git checkout -b your-branch-name
-
Add Your Code: Place your Python solution files in your respective day's folder within the "Week_X" directory that you created within your folder name. add your solution.
-
Push Your Code: Commit your changes and push the branch to your forked repository.
git add . git commit -m "Add solutions for Week X, Day Y" git push origin your-branch-name
-
Create a Pull Request (PR): Navigate to your forked repository on GitHub and click the "New Pull Request" button. Make sure to set the base branch to the original repository's branch.
-
Describe Your Changes: In the PR description, explain the purpose of your changes, mention the questions you've added or modified, and any other relevant information.
-
Submit the PR: Submit the pull request, and it will be reviewed by the repository maintainers.
To keep your work organized, we recommend following this file structure when submitting your solutions:
Your_Name/
βββ Week_1/
β βββ Day_1/
β β βββ question_1.py
β β βββ question_2.py
β β βββ question_3.py
β β βββ question_4.py
β β βββ question_5.py
β βββ Day_2/
β β βββ question_6.py
β β βββ question_7.py
β β βββ question_8.py
β β βββ question_9.py
β β βββ question_10.py
βββ Week_2/
β βββ ... (other days)
β βββ ...
βββ ... (other weeks)
βββ ...
- Write a Python program to print "Hello, World!" to the console. (Printing to the console)
- Write a program to find the sum of two numbers entered by the user. (Input, Variables, Basic Arithmetic)
- Write a Python program to swap the values of two variables without using a temporary variable. (Variables, Swap)
- Write a Python program to calculate the factorial of a number. (Loops)
- Write a program that checks if a number is even or odd. (Conditional Statements)
- Write a Python program to find the largest among three numbers entered by the user. (Conditional Statements)
- Write a program to check if a year is a leap year. (Conditional Statements)
- Write a Python program to calculate the square of a number. (Basic Arithmetic)
- Write a program that converts temperature from Fahrenheit to Celsius. (Variables, Basic Arithmetic)
- Write a Python program to calculate the area of a rectangle. (Variables, Basic Arithmetic)
- Write a program to calculate the square root of a number. (Math Functions)
- Write a Python program to find the GCD (Greatest Common Divisor) of two numbers. (Math Functions)
- Write a program that converts a decimal number to a binary number. (Bitwise Operations)
- Write a Python program to reverse a string. (String Manipulation)
- Write a program to find the sum of all even numbers in a list. (Lists, Loops)
- Write a Python program to check if a string is a palindrome. (String Manipulation, Loops)
- Write a program to find the smallest element in a list. (Lists, Loops)
- Write a program to generate the Fibonacci sequence up to n terms. (Lists, Loops)
- Write a Python program to find the LCM (Least Common Multiple) of two numbers. (Math Functions)
- Write a program that calculates the volume of a sphere. (Variables, Basic Arithmetic)
- Write a Python program to count the number of vowels in a string. (String Manipulation, Loops)
- Write a program to find the second largest element in an array. (Lists)
- Write a Python program to check if a number is prime. (Loops, Conditional Statements)
- Write a program that finds the reverse of a list. (Lists, List Slicing)
- Write a Python program to calculate the area of a triangle given its base and height. (Variables, Basic Arithmetic)
- Write a program to count the number of words in a sentence. (String Manipulation, Loops)
- Write a Python program to calculate the power of a number. (Math Functions)
- Write a program to check if a string contains only digits. (String Manipulation)
- Write a Python program to find the maximum product of two integers in an array. (Lists)
- Write a program that calculates the area of a parallelogram. (Variables, Basic Arithmetic)
- Write a Python program to find the factors of a number. (Loops)
- Write a program to check if a given year is a common year. (Conditional Statements)
- Write a program to calculate the sum of the digits of a number. (Loops, Basic Arithmetic)
- Write a Python program to check if a number is a perfect square. (Math Functions)
- Write a program that converts a decimal number to a hexadecimal number. (String Manipulation, Math Functions)
- Write a Python program that finds the length of the longest word in a sentence. (String Manipulation)
- Write a program to calculate the sum of all prime numbers up to a given limit. (Loops, Conditional Statements)
- Write a Python program to find the intersection of two lists. (Lists, Sets)
- Write a program to rotate the elements of a list to the left by a specific number of positions. (Lists)
- Write a Python program to calculate the area of a circle. (Variables, Basic Arithmetic)
- Write a program that checks if a string is an anagram of another string. (String Manipulation)
- Write a Python program to find the first non-repeating character in a string. (String Manipulation)
- Write a program to calculate the sum of squares of natural numbers up to a given limit. (Loops)
- Write a Python program to find the union of two sets. (Sets)
- Write a program to determine if a given string is a valid palindrome considering only alphanumeric characters and ignoring cases. (String Manipulation)
- Write a Python program to implement binary search on a sorted list. (Lists)
- Write a program to find the median of a list of numbers. (Lists, Sorting)
- Write a Python program to implement a basic calculator that can perform addition, subtraction, multiplication, and division. (Conditional Statements)
- Write a program that removes duplicates from a list without using built-in functions. (Lists)
- Write a Python program to find the area of a trapezoid. (Variables, Basic Arithmetic)
- Write a program that counts the occurrences of each word in a sentence. (String Manipulation, Dictionaries)
- Write a Python program to find the n-th term in the Fibonacci sequence using recursion. (Recursion)
- Write a program to check if a list is sorted in ascending order. (Lists)
- Write a Python program to calculate the cube of a number. (Math Functions)
- Write a program that calculates the perimeter of a rectangle. (Variables, Basic Arithmetic)
- Write a Python program to find the prime factors of a number. (Loops, Lists)
- Write a program to find the mode of a list of numbers. (Lists)
- Write a program that validates an email address. (String Manipulation, Regular Expressions)
- Write a Python program to implement the Sieve of Eratosthenes algorithm for prime number generation. (Lists)
- Write a program that calculates the area of a sector in a circle. (Variables, Basic Arithmetic)
- Write a Python program to reverse the words in a sentence. (String Manipulation)
- Write a program that calculates the square of each element in a list. (Lists)
- Write a program to find the missing number in a list of integers from 1 to n. (Lists)
- Write a Python program to implement a simple stack. (Lists)
- Write a program to calculate the surface area of a cube. (Variables, Basic Arithmetic)
- Write a Python program to find the sum of all elements in a 2D list. (Lists)
- Write a program to check if a given string is a pangram (contains every letter of the alphabet at least once). (String Manipulation)
- Write a program to find the average of a list of numbers. (Lists)
- Write a Python program to implement the Newton-Raphson method for finding the square root of a number. (Math Functions)
- Write a program that calculates the volume of a rectangular prism. (Variables, Basic Arithmetic)
- Write a Python program that finds the maximum element in a list. (Lists)
- Implement a function to calculate the factorial of a number using recursion. (Recursion)
- Write a program to reverse a list in-place. (Lists)
- Implement a function to check if a string is a palindrome ignoring spaces. (String Manipulation)
- Write a Python program to count the number of digits in an integer. (Loops, Basic Arithmetic)
- Implement a function to check if a number is in a given range. (Conditional Statements)
- Write a program to sort a list of integers in ascending order. (Lists, Sorting)
- Implement a function to calculate the exponentiation of a number using a loop. (Loops, Basic Arithmetic)
- Write a Python program to find the index of an element in a list. (Lists)
- Implement a function to calculate the sum of all elements in a list using recursion. (Recursion, Lists)
- Write a program to merge two sorted lists into a new sorted list. (Lists, Sorting)
- Implement a function to calculate the nth power of a number using the exponentiation operator. (Basic Arithmetic)
- Write a Python program to check if a string is a pangram. (String Manipulation)
- Implement a function to calculate the average of a list of floating-point numbers. (Lists, Basic Arithmetic)
- Write a program to find the maximum and minimum elements in a list simultaneously. (Lists)
- Write a Python program to find the factorial of a number using a loop. (Loops)
- Implement a function to calculate the sum of natural numbers up to a given limit using the formula. (Math Functions)
- Write a program to remove the duplicates from a list without changing the order. (Lists)
- Implement a function to calculate the square root of a number using the exponentiation operator. (Math Functions)
- Write a Python program to check if a string is a valid identifier. (String Manipulation, Regular Expressions)
- Implement a function to calculate the power of a number using recursion. (Recursion)
- Write a program to remove the last element from a list. (Lists)
- Implement a function to generate a list of n random integers. (Lists)
- Write a Python program to find the ASCII value of a character. (String Manipulation)
- Implement a function to perform linear search on a list and return the index of the element if found. (Lists)
- Write a Python program to sort a list of strings based on their lengths. (Lists, Sorting)
- Implement a function to calculate the sum of squares of even numbers up to a given limit. (Loops, Basic Arithmetic)
- Write a program to concatenate two lists. (Lists)
- Implement a function to calculate the cube root of a number using the exponentiation operator. (Math Functions)
- Write a Python program to check if a number is a perfect number. (Math Functions)
- Implement a function to generate the multiplication table of a given number. (Loops)
- Write a program to find the difference between two lists. (Lists)
- Implement a function to calculate the area of a circle using a user-defined function for pi. (Variables, Basic Arithmetic)
- Write a Python program to convert a string to title case. (String Manipulation)
- Implement a function to perform binary search on a sorted list and return the index of the element if found. (Lists)