diff --git a/03_tuple.py b/03_tuple.py new file mode 100644 index 0000000..cc8859d --- /dev/null +++ b/03_tuple.py @@ -0,0 +1,3 @@ +a = (1,45,342,3424,False, "Rihan", "Nihal") +print(a) +print(type(a)) diff --git a/4tuple_methods.py b/4tuple_methods.py new file mode 100644 index 0000000..5930e6e --- /dev/null +++ b/4tuple_methods.py @@ -0,0 +1,7 @@ +a-(1,22,3,45,False,"RIhan") +print(a) +no = a.count(45) +print(no) +i=a.index(3424) +print(i) +print(len(a)) diff --git a/Chapter 1 - PS/Problem1.py b/Chapter 1 - PS/Problem1.py deleted file mode 100644 index 992e0a7..0000000 --- a/Chapter 1 - PS/Problem1.py +++ /dev/null @@ -1,24 +0,0 @@ -print(''' Twinkle, twinkle, little star, -How I wonder what you are! -Up above the world so high, -Like a diamond in the sky. - -When the blazing sun is gone, -When he nothing shines upon, -Then you show your little light, -Twinkle, twinkle, all the night. - -Then the trav'ller in the dark, -Thanks you for your tiny spark, -He could not see which way to go, -If you did not twinkle so. - -In the dark blue sky you keep, -And often thro' my curtains peep, -For you never shut your eye, -Till the sun is in the sky. - -'Tis your bright and tiny spark, -Lights the trav'ller in the dark: -Tho' I know not what you are, -Twinkle, twinkle, little star.''') \ No newline at end of file diff --git a/Chapter 1 - PS/Problem2.py b/Chapter 1 - PS/Problem2.py deleted file mode 100644 index a3e6d65..0000000 --- a/Chapter 1 - PS/Problem2.py +++ /dev/null @@ -1 +0,0 @@ -# Done using REPL \ No newline at end of file diff --git a/Chapter 1 - PS/Problem3.py b/Chapter 1 - PS/Problem3.py deleted file mode 100644 index 5a7823a..0000000 --- a/Chapter 1 - PS/Problem3.py +++ /dev/null @@ -1,4 +0,0 @@ -import pyttsx3 -engine = pyttsx3.init() -engine.say("Hey I am good") -engine.runAndWait() \ No newline at end of file diff --git a/Chapter 1 - PS/Problem4.py b/Chapter 1 - PS/Problem4.py deleted file mode 100644 index a0a3457..0000000 --- a/Chapter 1 - PS/Problem4.py +++ /dev/null @@ -1,10 +0,0 @@ -import os - -# Select the directory whose content you want to list -directory_path = '/' - -# Use the os module to list the directory content -contents = os.listdir(directory_path) - -# Print the contents of the directory -print(contents) diff --git a/Chapter 2/rules for variable.py b/Chapter 2/rules for variable.py new file mode 100644 index 0000000..be112fb --- /dev/null +++ b/Chapter 2/rules for variable.py @@ -0,0 +1,12 @@ +a = 23 + +aaa = 435 + +Rihan = 34 + +sameer = 45 + +_samerr = 34 + +# @sameer = 56 # Invalid due to @ symbol +# s@meer # Invalid due to @ symbol diff --git a/FileExplorer.Py b/FileExplorer.Py new file mode 100644 index 0000000..c144d4b --- /dev/null +++ b/FileExplorer.Py @@ -0,0 +1,19 @@ +import os # 📦 Import the built-in 'os' module to interact with the operating system + +# 📂 Select the directory whose contents you want to list +directory_path = '/' +# '/' means the root directory (top-most folder of the file system) +# On Windows, this may raise an error. Example alternative: 'C:\\' or '.' (current folder) + +# 🧠 Use the os module to list the directory contents +contents = os.listdir(directory_path) +# os.listdir(): +# - Reads all files and folders inside the given directory +# - Returns the result as a Python list of strings +# - Each string is a file or folder name +# - It does NOT give file sizes or details, only names + +# 🖨️ Print the contents of the directory +print(contents) +# print(): +# - Displays the list of files and folders on the screen diff --git a/README.md b/README.md index a9086a0..fee90e2 100644 --- a/README.md +++ b/README.md @@ -1,121 +1,14 @@ -# The Ultimate Python Course +## Python Learning & Practice Repository -Welcome to [**The Ultimate Python Course!**](https://youtu.be/UrsmFxEIp5k) +This repository is forked from CodeWithHarry's Python course. +I use it to learn Python by rewriting examples, +adding my own practice, notes, and small improvements. -This course is designed to take you from a beginner to an advanced Python programmer. The repository contains all the source code, projects, problem sets, and additional resources to supplement your learning. -This is a part of my video The Ultimate Python Couse. Refer to this [video](https://youtu.be/UrsmFxEIp5k) to watch my Python course +### What I am doing here +- Rewriting course code in my own way +- Adding comments and explanations +- Creating small practice programs +- Learning Git and GitHub workflow -## Table of Contents - -- [The Ultimate Python Course](#the-ultimate-python-course) - - [Table of Contents](#table-of-contents) - - [Introduction](#introduction) - - [Chapters](#chapters) - - [Projects](#projects) - - [Problem Sets](#problem-sets) - - [Additional Resources](#additional-resources) - - [How to Use This Repository](#how-to-use-this-repository) - -## Introduction - -This repository is part of **The Ultimate Python Course** created by [CodeWithHarry](https://www.codewithharry.com/). The course aims to provide a comprehensive guide to learning Python programming. - -## Chapters - -The course is divided into several chapters, each focusing on different aspects of Python programming: - -- **Chapter 1: Modules, Comments & pip** - - Writing the first Python program - - Understanding modules - - Using pip for package management - - Using Python as a calculator - - Comments in Python -- **Chapter 2: Variables and Data Types** - - Defining variables - - Different data types in Python - - Rules for choosing an identifier - - Operators in Python - - Using `type()` function and typecasting - - `input()` function -- **Chapter 3: Strings** - - String slicing - - Slicing with skip values - - String functions - - Escape sequence characters -- **Chapter 4: Lists and Tuples** - - List indexing - - List methods - - Tuples in Python - - Tuple methods -- **Chapter 5: Dictionary & Sets** - - Properties of dictionaries - - Dictionary methods - - Sets in Python - - Properties and operations on sets -- **Chapter 6: Conditional Expression** - - `if`, `else`, and `elif` statements - - Relational and logical operators -- **Chapter 7: Loops in Python** - - `while` loop - - `for` loop - - `range()` function - - `for` loop with `else` - - Break, continue, and pass statements -- **Chapter 8: Functions & Recursions** - - Defining and calling functions - - Recursion in Python -- **Chapter 9: File I/O** - - Reading and writing files - - Working with directories -- **Chapter 10: Object-Oriented Programming** - - Classes and objects - - Methods and attributes -- **Chapter 11: Inheritance & More on OOPs** - - Inheritance - - Polymorphism - - Operator overloading -- **Chapter 12: Advanced Python 1** - - Newly added features in Python - - Walrus operator - - Advanced type hints - - Match case - - Dictionary merge & update operators - - Exception handling enhancements - - Global keyword and enumerate function - - List comprehensions -- **Chapter 13: Advanced Python 2** - - Virtual environments - - Lambda functions - - String methods: `join` and `format` - - Functional programming: `map`, `filter`, and `reduce` - -## Projects - -- **Project 1: Snake Water Gun Game** - - A fun and interactive game where the player competes against the computer in a variation of Rock-Paper-Scissors. -- **Project 2: Guess The Number** - - A guessing game where the player tries to guess a randomly generated number within a certain range. -- **Mega Project 1: Jarvis Virtual Assistant** - - A voice assistant application capable of performing various tasks such as playing music, and providing information. -- **Mega Project 2: AI AutoReply Bot** - - An AI-based bot designed to automatically reply to messages, enhancing communication efficiency. - -## Problem Sets - -Each chapter contains problem sets to test your understanding and to practice coding. The problem sets include various challenges and exercises relevant to the chapter's content. - -## Additional Resources - -- **[Download the Handbook](https://github.com/CodeWithHarry/The-Ultimate-Python-Course/blob/main/The%20Ultimate%20Python%20Handbook.pdf)** -- **[Download the Handwritten Notes](https://www.codewithharry.com/notes)** -- **[Download the Ultimate Python Cheatsheet](https://www.codewithharry.com/blogpost/python-cheatsheet/)** - -## How to Use This Repository - -1. **Clone the repository** to your local machine using: - ```sh - git clone https://github.com/CodeWithHarry/The-Ultimate-Python-Course.git - ``` -2. **Navigate through the chapters** to find the relevant lessons and code examples. -3. **Complete the problem sets** provided at the end of each chapter to solidify your understanding. -4. **Work on the projects** to apply your knowledge in real-world scenarios. +### Status +Ongoing learning (updated weekly) diff --git a/access content direct through os module.py b/access content direct through os module.py new file mode 100644 index 0000000..7b62529 --- /dev/null +++ b/access content direct through os module.py @@ -0,0 +1,9 @@ +import os + +#select the directory whose content you wnat to list +directory_path = '/' + +#use the os module to list the directory content +contents = os.listdir(directory_path) +#print the contents of the directory +print(contents) diff --git a/age_eligibility.py b/age_eligibility.py new file mode 100644 index 0000000..fd5388d --- /dev/null +++ b/age_eligibility.py @@ -0,0 +1,12 @@ +a = int(input("Enter your age: ")) + +# If else statement +if(a>=18): + print("You are above the age of consent") + print("Good for you") + +else: + print("You are below the age of consent") + + +print("End of Program") diff --git a/avgfunction.pty b/avgfunction.pty new file mode 100644 index 0000000..080d77c --- /dev/null +++ b/avgfunction.pty @@ -0,0 +1,5 @@ +a = 12 +b = 34 +c = 56 +average =(a + b + c)/3 +print(average) diff --git a/calcualte_bmi.py b/calcualte_bmi.py new file mode 100644 index 0000000..84d597f --- /dev/null +++ b/calcualte_bmi.py @@ -0,0 +1,9 @@ +# BMI 🏋️‍♀️ + + +weight = 92.3 +height = 1.86 + +bmi = weight / (height**2) + +print(bmi) diff --git a/diconary.py b/diconary.py new file mode 100644 index 0000000..a8ef581 --- /dev/null +++ b/diconary.py @@ -0,0 +1,6 @@ +d={} #empty dictonary +marks= { + "Rihan":100, + "Nihal":99, +} +print(marks["Rihan:"]) diff --git a/fvarible{},py b/fvarible{},py new file mode 100644 index 0000000..475792d --- /dev/null +++ b/fvarible{},py @@ -0,0 +1,2 @@ +name = input("enter your name") +print(f"Good morning,{name}") diff --git a/inches_to_cm.py b/inches_to_cm.py new file mode 100644 index 0000000..83e745a --- /dev/null +++ b/inches_to_cm.py @@ -0,0 +1,4 @@ +def inch_to_cm(inch) + return inch * 2.54 +n = int(input('enter value in inches: ")) +print(f"the corresponding vlaue in cms is (inches_to_cms(n)}") diff --git a/list.py b/list.py new file mode 100644 index 0000000..2f705aa --- /dev/null +++ b/list.py @@ -0,0 +1,6 @@ +purchase list = ["Apples","Orange",5,43.5,False,"Aakash","ROhan"] + +prints(friends[0]) +friends[0]="Grapes" #unlike list strings are mutable +print(friends[0]) +print(friends[1:4]) diff --git a/list_methodft.wwe.py b/list_methodft.wwe.py new file mode 100644 index 0000000..790723c --- /dev/null +++ b/list_methodft.wwe.py @@ -0,0 +1,11 @@ +candidates = ["John cena","undertaker","Roman Reings",5,4.45,True] +prints(candidates) +candidates.append("The Rock") +l1=[1,23,54,67,32,12] +Ranks=[1,23,54,67,32,12] +#l1.sort() +#l1.reverse() +#l1.insert(2,22222) +disqualified= Ranks.pop(3) +print(disqualified) +print(Ranks) diff --git a/my_practice/README.md b/my_practice/README.md new file mode 100644 index 0000000..ee05f86 --- /dev/null +++ b/my_practice/README.md @@ -0,0 +1,3 @@ +This folder contains my own Python practice, +rewritten examples, and experiments. + diff --git a/my_practice/Student Management System.cpp b/my_practice/Student Management System.cpp new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/my_practice/Student Management System.cpp @@ -0,0 +1 @@ + diff --git a/my_practice/datatypes.py b/my_practice/datatypes.py new file mode 100644 index 0000000..b6abe6a --- /dev/null +++ b/my_practice/datatypes.py @@ -0,0 +1,9 @@ +a = 1 # a is an integer + +b = 5.22 # b is a floating point number + +c = "Harry" # c is a string + +d = False # d is a boolean variable + +e = None # e is a none type variable diff --git a/my_practice/practice-loops b/my_practice/practice-loops new file mode 100644 index 0000000..31be453 --- /dev/null +++ b/my_practice/practice-loops @@ -0,0 +1,58 @@ +# My Data Analysis Practice: Loops +# This script shows how to process data lists using loops. + +def analyze_data(): + + # --- PART 1: The 'For' Loop (Iterating through an Array/List) --- + # Scenario: I have a list of daily sales figures. I want to print each one. + print("1. Reading Daily Sales Data:") + daily_sales = [150, 200, 350, 400, 500] + + # "sale" is a variable that holds one number at a time from the list + for sale in daily_sales: + print("Processing sale amount: $", sale) + + print("-" * 30) + + # --- PART 2: Filtering Data (Loop with Condition) --- + # Scenario: I only want to count days where sales were high (above 300). + print("2. Filtering High Sales (> 300):") + + count = 0 + for sale in daily_sales: + if sale > 300: + print("Found high sale:", sale) + count = count + 1 + + print("Total high revenue days:", count) + + print("-" * 30) + + # --- PART 3: The 'While' Loop (Data Cleaning) --- + # Scenario: removing '0' or bad data until the list is clean. + print("3. Cleaning Data (Removing Zeros):") + raw_data = [10, 0, 50, 0, 20] + + # While '0' exists inside the raw_data list, remove it + while 0 in raw_data: + raw_data.remove(0) + print("Removed a zero... Current data:", raw_data) + + print("Final Cleaned Data:", raw_data) + + print("-" * 30) + + # --- PART 4: Break and Continue --- + # Scenario: Searching for a specific error value (like -1). + print("4. searching for Errors:") + dataset = [12, 45, -1, 60, 100] + + for value in dataset: + if value == -1: + print("Error found! Corrupted data detected. Stopping analysis.") + break # Stops the loop completely + print("Checking value:", value) + +# Run the analysis function +if __name__ == "__main__": + analyze_data() diff --git a/my_practice/pyjokes.py b/my_practice/pyjokes.py new file mode 100644 index 0000000..898c87f --- /dev/null +++ b/my_practice/pyjokes.py @@ -0,0 +1,7 @@ +import pyjokes + +# print("printing jokes") + +# this prints a random jokes +joke=pyjokes.getjokes() +print(jokes) diff --git a/negative_slicing.py b/negative_slicing.py new file mode 100644 index 0000000..3cf0307 --- /dev/null +++ b/negative_slicing.py @@ -0,0 +1,8 @@ +name="Rihan" +print(name[0:3]) + +print(name[-4:1]) +print(name[1:4]) + +print(name[:4]) + diff --git a/operators.py b/operators.py new file mode 100644 index 0000000..a9d4776 --- /dev/null +++ b/operators.py @@ -0,0 +1,38 @@ +# Arithmetic Operators +a = 7 +b = 4 +c = a + b +print(c) + +# Assignment Operators +a = 4-2 # Assign 4-2 in a +print(a) +b = 6 +# b += 3 # Increment the value of b by 3 and then assign it to b +b -= 3 # Decrement the value of b by 3 and then assign it to b +print(b) + +# Comparison Operators + +d = 5==5 + +print(d) + + +# Logical Operators + +e = True or False + +# Truth table of 'or' +print("True or False is ", True or False) +print("True or True is ", True or True) +print("False or True is ", False or True) +print("False or False is ", False or False) + +# Truth table of 'and' +print("True and False is ", True and False) +print("True and True is ", True and True) +print("False and True is ", False and True) +print("False and False is ", False and False) + +print(not(True)) diff --git a/pythagorean theorem.py b/pythagorean theorem.py new file mode 100644 index 0000000..6205949 --- /dev/null +++ b/pythagorean theorem.py @@ -0,0 +1,4 @@ +a=int(input("enter a:")) +b=int(input("enter b:")) +c=(a**2 + b**2)**0.5 +print(c) diff --git a/remainder.py b/remainder.py new file mode 100644 index 0000000..ac85fa7 --- /dev/null +++ b/remainder.py @@ -0,0 +1,3 @@ +a=43 +b=34 +print("Remainder when a is divided by b", a % b) diff --git a/set_methods and operations.py b/set_methods and operations.py new file mode 100644 index 0000000..fe481bb --- /dev/null +++ b/set_methods and operations.py @@ -0,0 +1,25 @@ +# Corrected and commented set examples + +# Create a set. Sets are unordered collections of unique items. +s = {1, 2, 3, 4, 5, 68, 42, "harry"} # mixing ints and strings is allowed but uncommon +print("Initial set:", s, "Type:", type(s)) + +# Add an element to the set +s.add(566) +print("After add(566):", s) + +# Remove an element safely +# .remove(x) raises KeyError if x not present. .discard(x) does not raise. +s.discard(1) +print("After discard(1):", s) + +# ---------------------------------------------------------------- # +# SET OPERATIONS: UNION and INTERSECTION +s1 = {1, 45, 6, 78} +s2 = {7, 8, 1, 78} + +# union: all unique elements from both sets +print("s1 union s2:", s1.union(s2)) + +# intersection: elements common to both sets +print("s1 intersection s2:", s1.intersection(s2)) diff --git a/table.py b/table.py new file mode 100644 index 0000000..4fccfe6 --- /dev/null +++ b/table.py @@ -0,0 +1,3 @@ +print=int(input("enter number") +for i in range(1,11): # common mistake use always synatx in loops +print(f"{i} * {n} = { n * i) ")#f string via we can call values for inputed value diff --git a/tabspaceandneline.py b/tabspaceandneline.py new file mode 100644 index 0000000..d43d0f8 --- /dev/null +++ b/tabspaceandneline.py @@ -0,0 +1,2 @@ +letters= dear sir, \n\tHello, nice to meet you. My work was evaluated through my GitHub profile during an off-campus review.\n Thanks! +print(letters) diff --git a/typecast.py b/typecast.py new file mode 100644 index 0000000..d0e5fab --- /dev/null +++ b/typecast.py @@ -0,0 +1,2 @@ +a=input("enter value of a;") +print(type(a)) diff --git a/usertypetable.py b/usertypetable.py new file mode 100644 index 0000000..d9bfd2a --- /dev/null +++ b/usertypetable.py @@ -0,0 +1,3 @@ +n= int(input "enter the number ;")) +for i in range (1,11): + print(f"{n}*{11} = {n*(11)}")