Skip to content

vaibhavnalla15/PyNative

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

266 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 Data Structure Exercise

A beginner-friendly collection of Python exercises focusing on Lists, Sets, and Dictionaries — perfect for building a strong foundation in Python data structures.


📘 Table of Contents

Exercise No. Title
✅ 01 List Creation using two lists
✅ 02 Remove and Add Item in a List
✅ 03 Slice List into 3 Equal Chunks and Reverse Each
✅ 04 Count the Occurrence of Each Element from a List
✅ 05 Paired Elements from Two Lists as a Set
✅ 06 Set Intersection and Removal
✅ 07 Subset or Superset of Another Set
✅ 08 Filter List Against Dictionary Values
✅ 09 Extract Unique Dictionary Values to List
✅ 10 Remove Duplicates from a List

📌 Goals Strengthen understanding of Python core data structures

Practice common operations and patterns using list, set, and dict

Learn to write clean, testable Python code

💡 Tip Use these exercises to improve:

Data structure manipulation

Problem-solving techniques

Coding confidence 💪


⏰ Date and Time Exercise

A collection of beginner-friendly Python exercises focused on working with datetime — ideal for mastering time, date manipulation, and formatting in Python.


📘 Table of Contents

Exercise No. Title
✅ 01 Print Current Date and Time
✅ 02 Convert String Into Datetime Object
✅ 03 Subtract a Week From a Given Date
✅ 04 Format DateTime
✅ 05 Find Day of Week
✅ 06 Add Week to Given Date
✅ 07 Print Current Time in Milliseconds
✅ 08 Convert Datetime into String
✅ 09 Calculate the Date 4 Months from Today
✅ 10 Calculate Days Between Two Dates

📌 What You will Learn Working with the datetime module

String to datetime and vice versa

Date arithmetic and formatting

Time in milliseconds and weekdays

💡 Tip ✅ These are real-world practical examples of using date and time in Python applications like logs, timestamps, reports, and automation scripts.


📁 File Handling Exercises

A collection of beginner-friendly Python exercises focused on file handling. These exercises cover all the basic and intermediate operations like reading, writing, appending, copying, and deleting files — including working with both text and binary formats.


📘 Table of Contents

Exercise No. Title
✅ 01 Read a File
✅ 02 Read File Line by Line
✅ 03 Read Specific Lines From a File
✅ 04 Count Words From a File
✅ 05 Count Total Characters in File
✅ 06 Count Specific Word From a File
✅ 07 Write To a File
✅ 08 Append To a File
✅ 09 Copy a File
✅ 10 Read and Write Binary
✅ 11 File Existence Check
✅ 12 Get File Size
✅ 13 Rename a File
✅ 14 Delete a File
✅ 15 Replace In File

💡 What You’ll Learn Reading text and binary files

Line-by-line and selective reading

Writing and appending to files

File existence, size, and manipulation (rename/delete)

Real-world operations like replacing text in files

📂 Note on Files sample.txt, output.txt, demo.txt, copied_sample.txt, replaced_file.txt, input.bin, and output.bin are sample input/output files used for exercises.


🧠 Functions Exercise

This directory contains beginner-to-intermediate level exercises that help you understand how to define and use functions in Python. It includes practical examples of parameter types, lambda functions, recursion, higher-order functions, and more.


📘 Table of Contents

Exercise No. Title
✅ 01 Create a function in Python
✅ 02 Function with variable length of arguments
✅ 03 Return multiple values from a function
✅ 04 Create a function with a default argument
✅ 05 Create an inner function
✅ 06 Create a recursive function
✅ 07 Assign a different name to function and call it
✅ 08 Generate even numbers between 4 to 30
✅ 09 Find the largest item in a list
✅ 10 Call function using positional and keyword arguments
✅ 11 Create a function with keyword arguments
✅ 12 Modify a global variable inside a function
✅ 13 Recursive factorial function
✅ 14 Lambda function to square a number
✅ 15 Lambda with filter() to get even numbers
✅ 16 Lambda with map() to double each element
✅ 17 Lambda with sorted() to sort tuples by second element
✅ 18 Create a Higher-Order Function

💡 What You’ll Learn How to define and use Python functions

Working with default, keyword, and variable-length arguments

Recursive thinking and functional programming

Lambda expressions and built-in functional tools (map, filter, sorted)

Scope of variables (global, local, inner functions)


🔁 Python Loop Exercises

This folder contains 22 beginner-to-intermediate level Python exercises focused on mastering for and while loops, including nested loops and pattern printing.
A great way to strengthen your logic, problem-solving skills, and confidence with Python loops!


📚 Table of Contents

  1. Print first 10 natural numbers
  2. Pattern Printing
  3. Calculate sum of numbers from 1 to 10
  4. Print multiplication table of a number
  5. Display numbers from a list using loop
  6. Count total number of digits in a number
  7. Pattern Printing
  8. Print list in reverse order
  9. Display numbers from -10 to -1
  10. Use else block with a for loop
  11. Print all prime numbers within a range
  12. Fibonacci series up to 10 terms
  13. Find factorial of a given number
  14. Reverse an integer number
  15. Use continue statement inside loop
  16. Display cube of given numbers
  17. Find sum of series of numbers
  18. Pattern Printing
  19. Print full multiplication table (1 to 10)
  20. Print alternate numbers pattern
  21. Flatten a nested list
  22. Find largest and smallest digit in a number

Benefits of Testing:- ✅ Confirms your logic works as expected

✅ Helps catch edge cases

✅ Builds good coding habits for professional projects


💡 Topics Covered:- 🔁 Loops: for, while, nested loops

✅ Conditionals inside loops

✨ Pattern printing

🔢 Number processing (digits, factorial, prime, etc.)

📄 List and nested list handling


🔷 OOP Exercises in Python

This folder contains beginner-to-intermediate level exercises on Object-Oriented Programming (OOP) in Python. The exercises are designed to help you understand and apply the core OOP concepts like classes, objects, attributes, methods, inheritance, and more.


📘 Table of Contents

Exercise No. Title
✅ 01 Create a Class with Instance Attributes
✅ 02 Create a Vehicle Class Without Any Variables and Methods
✅ 03 Create a Child Class Bus That Inherits From Vehicle
✅ 04 Class Inheritance
✅ 05 Define a Property Shared by All Instances
✅ 06 Class Inheritance (Continued)
✅ 07 Check Type of an Object
✅ 08 Determine if School_bus is an Instance of Vehicle
✅ 09 Check if an Object is a Subclass of a Class
✅ 10 Calculate Area of Different Shapes Using OOP

OOP_Exercises_New

Exercise No. Title
✅ 01 Exercise01
✅ 02 Exercise02
✅ 03 Exercise03
✅ 04 Exercise04
✅ 05 Exercise05
✅ 06 Exercise06
✅ 07 Exercise07
✅ 08 Exercise08
✅ 09 Exercise09
✅ 10 Exercise10
✅ 11 Exercise11
✅ 12 Exercise12
✅ 13 Exercise13
✅ 14 Exercise14
✅ 15 Exercise15
✅ 16 Exercise16
✅ 17 Exercise17
✅ 18 Exercise18
✅ 19 Exercise19
✅ 20 Exercise20
✅ 21 Exercise21
✅ 22 Exercise22
✅ 23 Exercise23
✅ 24 Exercise24

🧠 Key OOP Concepts Practiced ✅ Classes & Objects

✅ Instance vs Class Attributes

✅ Inheritance & Method Overriding

✅ Type Checking (isinstance, issubclass)

✅ Object Properties and Shared Variables

✅ Encapsulation and Reusability

💡 Ideal For Beginners who are transitioning from procedural to object-oriented thinking.

Practicing real-world use cases like vehicles and shapes.

Strengthening core OOP fundamentals before diving into larger projects.


🐍 Python Basic Exercises for Beginners

Welcome to a beginner-friendly collection of 23 Python exercises designed to help you practice fundamental programming concepts like loops, conditionals, functions, strings, and numbers.

Whether you're just starting out or brushing up your Python skills, these mini-tasks are perfect for hands-on learning!


📚 Table of Contents

  1. Calculate the multiplication and sum of two numbers
  2. Sum of current number and previous number
  3. Print characters at even index positions
  4. Remove first n characters from a string
  5. Check if first and last number in list are the same
  6. Display numbers divisible by 5
  7. Count occurrences of a substring in a string
  8. Print a specific number pattern
  9. Check if a number is a palindrome
  10. Merge two lists with condition
  11. Get each digit of a number in reverse order
  12. Calculate income tax based on income
  13. Print multiplication table from 1 to 10
  14. Print downward half-pyramid of stars
  15. Calculate base raised to the power exponent
  16. Check palindrome number (alternate logic)
  17. Generate Fibonacci series up to 15 terms
  18. Check if a year is a leap year
  19. Print alternate prime numbers till 20
  20. Check if string contains digits using for loop
  21. Capitalize the first letter of each word in string
  22. Create a countdown timer using while loop

💡 What You'll Practice ✅ Loops (for, while)

✅ Conditional statements

✅ Functions

✅ String and list operations

✅ Pattern printing

✅ Number handling and logic building


📘 Python Dictionary Exercise

This folder contains 20 beginner-to-intermediate level exercises designed to help you master Python dictionaries — one of the most powerful data structures in Python. Each exercise focuses on a specific skill like accessing, modifying, sorting, or manipulating dictionaries and nested structures.


🗂️ Table of Contents

Exercise No. Title
✅ 01 Perform Basic Dictionary Operations
✅ 02 Perform Dictionary Operations
✅ 03 Dictionary from Lists
✅ 04 Clear Dictionary
✅ 05 Merge Two Dictionaries
✅ 06 Count Character Frequencies
✅ 07 Access Nested Dictionary
✅ 08 Get ‘history’ from Nested Dictionary
✅ 09 Modify Nested Dictionary
✅ 10 Initialize Dictionary with Default Values
✅ 11 Extract Specific Keys
✅ 12 Delete a List of Keys
✅ 13 Check if Value Exists
✅ 14 Rename Key
✅ 15 Get Key of Minimum Value
✅ 16 Change Nested Value
✅ 17 Invert Dictionary
✅ 18 Sort by Keys
✅ 19 Sort by Values
✅ 20 Check if All Values are Unique

💡 What You’ll Learn Basic dictionary creation and manipulation

Nested dictionary handling

Key/value operations: add, modify, delete, access

Merging, sorting, and inverting dictionaries

Real-world challenges like checking uniqueness or value conditions


📘 Python List Exercise

This folder contains 22 beginner-friendly Python exercises focused on mastering list operations. These hands-on challenges cover everything from basic list manipulations to working with nested lists and list comprehensions.


🗂️ Table of Contents

Exercise No. Title
✅ 01 Perform Basic List Operations
✅ 02 Perform List Manipulation
✅ 03 Sum and Average of List
✅ 04 Reverse a List
✅ 05 Square Every Item
✅ 06 Find Maximum and Minimum
✅ 07 Count Occurrences
✅ 08 Sort List of Numbers
✅ 09 Create a Copy of a List
✅ 10 Combine Two Lists
✅ 11 Remove Empty Strings
✅ 12 Remove Duplicates
✅ 13 Remove All Occurrences
✅ 14 List Comprehension (Numbers)
✅ 15 Access Nested Lists
✅ 16 Flatten Nested List
✅ 17 Concatenate Lists Index-Wise
✅ 18 Concatenate Lists by Pattern
✅ 19 Iterate Both Lists Simultaneously
✅ 20 Add Item After Specific Element
✅ 21 Extend Nested List
✅ 22 Replace Item with New Value

💡 What You’ll Learn Creating and updating Python lists

Slicing, indexing, and looping techniques

Sorting, copying, and filtering data

Handling nested lists

Real-world list manipulation challenges


🖥️ Python Input and Output Exercises

This folder contains 15 beginner-friendly Python exercises focused on input/output operations like taking user input, formatting strings, and working with files.

Some exercises are inside folders because they contain multiple files for practice or demonstration.


📚 Table of Contents

  1. Accept Numbers From User
  2. Format Output String
  3. Display Decimal Number to Octal using print()
  4. Display Float Number with 2 Decimal Places
  5. Accept a List of 5 Float Numbers From User
  6. Copy File Contents (Skip Line 5)
  7. Accept Three Strings in One Input Call
  8. Format Variables Using string.format()
  9. Check if File is Empty or Not
  10. Read Line Number 4 from File
  11. Display Percentage with Symbol
  12. Create an Interactive Menu
  13. Display Right-Aligned Output
  14. Tabular Output from Lists
  15. Padding Numbers with Zeros

🧠 Topics Practiced 🧾 Console input using input()

📄 File handling (read/write/check)

🧮 Formatting output with .format() and f-strings

📊 Displaying clean tabular data

🎯 Interactive menus


🎲 Random Data Generation Exercise

This folder contains 10 fun and practical Python exercises focused on generating random data using the random, secrets, and uuid libraries. These tasks are ideal for building your understanding of randomness, tokens, OTPs, and more.


📄 Table of Contents

Exercise No. Title
✅ 01 Generate 3 Random Integers
✅ 02 Random Lottery Pick
✅ 03 Generate 6-digit Secure OTP
✅ 04 Pick Random Character
✅ 05 Generate Random String
✅ 06 Generate Random Password
✅ 07 Calculate Multiplication (Random Quiz)
✅ 08 Generate Random Token and URL
✅ 09 Dice Roll
✅ 10 Generate Random Date

🧠 What You’ll Learn Using Python’s random, secrets, and uuid libraries

Generating secure passwords and OTPs

Creating random strings, characters, numbers, and dates

Simulating simple games like dice rolling and quizzes


🔤 Python String Exercise

This folder contains 18 hands-on Python string manipulation exercises. These cover common use cases such as indexing, slicing, replacing, filtering, counting, and modifying strings—perfect for beginners strengthening their string processing skills.


📄 Table of Contents

Exercise No. Title
✅ 01A Create string from first, middle, and last characters
✅ 01B Create string from middle three characters
✅ 02 Append string in the middle of another
✅ 03 Create new string from 3 characters of each string
✅ 04 Arrange characters: lowercase first
✅ 05 Count letters, digits, and symbols
✅ 06 Create mixed string based on rules
✅ 07 Check character balance between two strings
✅ 08 Find all substring occurrences (ignore case)
✅ 09 Sum and average of digits in string
✅ 10 Count character frequency in string
✅ 11 Reverse a string
✅ 12 Find last occurrence of substring
✅ 13 Split a string on hyphens
✅ 14 Remove empty strings from list of strings
✅ 15 Remove special characters from string
✅ 16 Keep only digits in string
✅ 17 Find alphanumeric words
✅ 18 Replace all symbols with #

🧠 What You’ll Learn Indexing and slicing strings

String formatting, filtering, reversing

Working with substrings and special characters

Creating new strings from multiple strings

Handling alphanumeric, empty, and symbol characters


🧪 Tests

All directory includes test coverage for selected exercises.

tests/
└── test_exercises.py

pytest tests/test_exercises.py

About

A beginner-friendly collection of Python practice exercises covering loops, functions, lists, strings, file handling, OOP, and more—based on PyNative challenges.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages