Skip to content

🐍 Enhance your Python skills with structured practice questions. From fundamentals to real-world challenges, level up your Python programming. Start practicing now!

License

Notifications You must be signed in to change notification settings

DevDotCommunity/Python-Practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Python Practice Questions

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.

Introduction

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.

How to Use

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.

How to Contribute

We welcome contributions to improve this repository and make it a valuable resource for Python learners. Here's how you can contribute:

  1. Fork the Repository: Click the "Fork" button in the upper right corner of the repository to create your copy.

  2. 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
  3. 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.

  4. 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
  5. 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.

  6. 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.

  7. Submit the PR: Submit the pull request, and it will be reviewed by the repository maintainers.

Repository File Structure

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)
└── ...

Practice Problems

Week 1

Day 1

  1. Write a Python program to print "Hello, World!" to the console. (Printing to the console)
  2. Write a program to find the sum of two numbers entered by the user. (Input, Variables, Basic Arithmetic)
  3. Write a Python program to swap the values of two variables without using a temporary variable. (Variables, Swap)
  4. Write a Python program to calculate the factorial of a number. (Loops)
  5. Write a program that checks if a number is even or odd. (Conditional Statements)

Day 2

  1. Write a Python program to find the largest among three numbers entered by the user. (Conditional Statements)
  2. Write a program to check if a year is a leap year. (Conditional Statements)
  3. Write a Python program to calculate the square of a number. (Basic Arithmetic)
  4. Write a program that converts temperature from Fahrenheit to Celsius. (Variables, Basic Arithmetic)
  5. Write a Python program to calculate the area of a rectangle. (Variables, Basic Arithmetic)

Day 3

  1. Write a program to calculate the square root of a number. (Math Functions)
  2. Write a Python program to find the GCD (Greatest Common Divisor) of two numbers. (Math Functions)
  3. Write a program that converts a decimal number to a binary number. (Bitwise Operations)
  4. Write a Python program to reverse a string. (String Manipulation)
  5. Write a program to find the sum of all even numbers in a list. (Lists, Loops)

Day 4

  1. Write a Python program to check if a string is a palindrome. (String Manipulation, Loops)
  2. Write a program to find the smallest element in a list. (Lists, Loops)
  3. Write a program to generate the Fibonacci sequence up to n terms. (Lists, Loops)
  4. Write a Python program to find the LCM (Least Common Multiple) of two numbers. (Math Functions)
  5. Write a program that calculates the volume of a sphere. (Variables, Basic Arithmetic)

Day 5

  1. Write a Python program to count the number of vowels in a string. (String Manipulation, Loops)
  2. Write a program to find the second largest element in an array. (Lists)
  3. Write a Python program to check if a number is prime. (Loops, Conditional Statements)
  4. Write a program that finds the reverse of a list. (Lists, List Slicing)
  5. Write a Python program to calculate the area of a triangle given its base and height. (Variables, Basic Arithmetic)

Day 6

  1. Write a program to count the number of words in a sentence. (String Manipulation, Loops)
  2. Write a Python program to calculate the power of a number. (Math Functions)
  3. Write a program to check if a string contains only digits. (String Manipulation)
  4. Write a Python program to find the maximum product of two integers in an array. (Lists)
  5. Write a program that calculates the area of a parallelogram. (Variables, Basic Arithmetic)

Day 7

  1. Write a Python program to find the factors of a number. (Loops)
  2. Write a program to check if a given year is a common year. (Conditional Statements)
  3. Write a program to calculate the sum of the digits of a number. (Loops, Basic Arithmetic)
  4. Write a Python program to check if a number is a perfect square. (Math Functions)
  5. Write a program that converts a decimal number to a hexadecimal number. (String Manipulation, Math Functions)

Week 2

Day 1

  1. Write a Python program that finds the length of the longest word in a sentence. (String Manipulation)
  2. Write a program to calculate the sum of all prime numbers up to a given limit. (Loops, Conditional Statements)
  3. Write a Python program to find the intersection of two lists. (Lists, Sets)
  4. Write a program to rotate the elements of a list to the left by a specific number of positions. (Lists)
  5. Write a Python program to calculate the area of a circle. (Variables, Basic Arithmetic)

Day 2

  1. Write a program that checks if a string is an anagram of another string. (String Manipulation)
  2. Write a Python program to find the first non-repeating character in a string. (String Manipulation)
  3. Write a program to calculate the sum of squares of natural numbers up to a given limit. (Loops)
  4. Write a Python program to find the union of two sets. (Sets)
  5. Write a program to determine if a given string is a valid palindrome considering only alphanumeric characters and ignoring cases. (String Manipulation)

Day 3

  1. Write a Python program to implement binary search on a sorted list. (Lists)
  2. Write a program to find the median of a list of numbers. (Lists, Sorting)
  3. Write a Python program to implement a basic calculator that can perform addition, subtraction, multiplication, and division. (Conditional Statements)
  4. Write a program that removes duplicates from a list without using built-in functions. (Lists)
  5. Write a Python program to find the area of a trapezoid. (Variables, Basic Arithmetic)

Day 4

  1. Write a program that counts the occurrences of each word in a sentence. (String Manipulation, Dictionaries)
  2. Write a Python program to find the n-th term in the Fibonacci sequence using recursion. (Recursion)
  3. Write a program to check if a list is sorted in ascending order. (Lists)
  4. Write a Python program to calculate the cube of a number. (Math Functions)
  5. Write a program that calculates the perimeter of a rectangle. (Variables, Basic Arithmetic)

Day 5

  1. Write a Python program to find the prime factors of a number. (Loops, Lists)
  2. Write a program to find the mode of a list of numbers. (Lists)
  3. Write a program that validates an email address. (String Manipulation, Regular Expressions)
  4. Write a Python program to implement the Sieve of Eratosthenes algorithm for prime number generation. (Lists)
  5. Write a program that calculates the area of a sector in a circle. (Variables, Basic Arithmetic)

Day 6

  1. Write a Python program to reverse the words in a sentence. (String Manipulation)
  2. Write a program that calculates the square of each element in a list. (Lists)
  3. Write a program to find the missing number in a list of integers from 1 to n. (Lists)
  4. Write a Python program to implement a simple stack. (Lists)
  5. Write a program to calculate the surface area of a cube. (Variables, Basic Arithmetic)

Day 7

  1. Write a Python program to find the sum of all elements in a 2D list. (Lists)
  2. Write a program to check if a given string is a pangram (contains every letter of the alphabet at least once). (String Manipulation)
  3. Write a program to find the average of a list of numbers. (Lists)
  4. Write a Python program to implement the Newton-Raphson method for finding the square root of a number. (Math Functions)
  5. Write a program that calculates the volume of a rectangular prism. (Variables, Basic Arithmetic)

Week 3

Day 1

  1. Write a Python program that finds the maximum element in a list. (Lists)
  2. Implement a function to calculate the factorial of a number using recursion. (Recursion)
  3. Write a program to reverse a list in-place. (Lists)
  4. Implement a function to check if a string is a palindrome ignoring spaces. (String Manipulation)
  5. Write a Python program to count the number of digits in an integer. (Loops, Basic Arithmetic)

Day 2

  1. Implement a function to check if a number is in a given range. (Conditional Statements)
  2. Write a program to sort a list of integers in ascending order. (Lists, Sorting)
  3. Implement a function to calculate the exponentiation of a number using a loop. (Loops, Basic Arithmetic)
  4. Write a Python program to find the index of an element in a list. (Lists)
  5. Implement a function to calculate the sum of all elements in a list using recursion. (Recursion, Lists)

Day 3

  1. Write a program to merge two sorted lists into a new sorted list. (Lists, Sorting)
  2. Implement a function to calculate the nth power of a number using the exponentiation operator. (Basic Arithmetic)
  3. Write a Python program to check if a string is a pangram. (String Manipulation)
  4. Implement a function to calculate the average of a list of floating-point numbers. (Lists, Basic Arithmetic)
  5. Write a program to find the maximum and minimum elements in a list simultaneously. (Lists)

Day 4

  1. Write a Python program to find the factorial of a number using a loop. (Loops)
  2. Implement a function to calculate the sum of natural numbers up to a given limit using the formula. (Math Functions)
  3. Write a program to remove the duplicates from a list without changing the order. (Lists)
  4. Implement a function to calculate the square root of a number using the exponentiation operator. (Math Functions)
  5. Write a Python program to check if a string is a valid identifier. (String Manipulation, Regular Expressions)

Day 5

  1. Implement a function to calculate the power of a number using recursion. (Recursion)
  2. Write a program to remove the last element from a list. (Lists)
  3. Implement a function to generate a list of n random integers. (Lists)
  4. Write a Python program to find the ASCII value of a character. (String Manipulation)
  5. Implement a function to perform linear search on a list and return the index of the element if found. (Lists)

Day 6

  1. Write a Python program to sort a list of strings based on their lengths. (Lists, Sorting)
  2. Implement a function to calculate the sum of squares of even numbers up to a given limit. (Loops, Basic Arithmetic)
  3. Write a program to concatenate two lists. (Lists)
  4. Implement a function to calculate the cube root of a number using the exponentiation operator. (Math Functions)
  5. Write a Python program to check if a number is a perfect number. (Math Functions)

Day 7

  1. Implement a function to generate the multiplication table of a given number. (Loops)
  2. Write a program to find the difference between two lists. (Lists)
  3. Implement a function to calculate the area of a circle using a user-defined function for pi. (Variables, Basic Arithmetic)
  4. Write a Python program to convert a string to title case. (String Manipulation)
  5. Implement a function to perform binary search on a sorted list and return the index of the element if found. (Lists)

About

🐍 Enhance your Python skills with structured practice questions. From fundamentals to real-world challenges, level up your Python programming. Start practicing now!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages