Skip to content

Commit ab16fbc

Browse files
committed
Merge branch 'searchengine' of github.com:Xceptions/geekcomputersPython into searchengine
bringing in the commit from origin
2 parents cd605e1 + 0086f72 commit ab16fbc

25 files changed

+1772
-69
lines changed

Laundary System/README.md

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Laundry Service Class
2+
3+
## Overview
4+
The LaundryService class is designed to manage customer details and calculate charges for a cloth and apparel cleaning service. It provides methods to create customer-specific instances, print customer details, calculate charges based on cloth type, branding, and season, and print final details including the expected day of return.
5+
6+
## Class Structure
7+
### Methods
8+
1. `__init__(name, contact, email, cloth_type, branded, season)`: Initializes a new customer instance with the provided details and assigns a unique customer ID.
9+
- Parameters:
10+
- `name`: String, name of the customer.
11+
- `contact`: Numeric (integer), contact number of the customer.
12+
- `email`: Alphanumeric (string), email address of the customer.
13+
- `cloth_type`: String, type of cloth deposited (Cotton, Silk, Woolen, or Polyester).
14+
- `branded`: Boolean (0 or 1), indicating whether the cloth is branded.
15+
- `season`: String, season when the cloth is deposited (Summer or Winter).
16+
17+
2. `customerDetails()`: Prints out the details of the customer, including name, contact number, email, cloth type, and whether the cloth is branded.
18+
19+
3. `calculateCharge()`: Calculates the charge based on the type of cloth, branding, and season.
20+
- Returns:
21+
- Numeric, total charge for cleaning the cloth.
22+
23+
4. `finalDetails()`: Calls `customerDetails()` and `calculateCharge()` methods within itself and prints the total charge and the expected day of return.
24+
- Prints:
25+
- Total charge in Rupees.
26+
- Expected day of return (4 days if total charge > 200, otherwise 7 days).
27+
28+
## Example Usage
29+
```python
30+
# Example usage:
31+
name = input("Enter customer name: ")
32+
contact = int(input("Enter contact number: "))
33+
email = input("Enter email address: ")
34+
cloth_type = input("Enter cloth type (Cotton/Silk/Woolen/Polyester): ")
35+
branded = bool(int(input("Is the cloth branded? (Enter 0 for No, 1 for Yes): ")))
36+
season = input("Enter season (Summer/Winter): ")
37+
38+
customer = LaundryService(name, contact, email, cloth_type, branded, season)
39+
customer.finalDetails()
40+
41+
42+
markdown
43+
Copy code
44+
# Laundry Service Class
45+
46+
## Overview
47+
The LaundryService class is designed to manage customer details and calculate charges for a cloth and apparel cleaning service. It provides methods to create customer-specific instances, print customer details, calculate charges based on cloth type, branding, and season, and print final details including the expected day of return.
48+
49+
## Class Structure
50+
### Methods
51+
1. `__init__(name, contact, email, cloth_type, branded, season)`: Initializes a new customer instance with the provided details and assigns a unique customer ID.
52+
- Parameters:
53+
- `name`: String, name of the customer.
54+
- `contact`: Numeric (integer), contact number of the customer.
55+
- `email`: Alphanumeric (string), email address of the customer.
56+
- `cloth_type`: String, type of cloth deposited (Cotton, Silk, Woolen, or Polyester).
57+
- `branded`: Boolean (0 or 1), indicating whether the cloth is branded.
58+
- `season`: String, season when the cloth is deposited (Summer or Winter).
59+
60+
2. `customerDetails()`: Prints out the details of the customer, including name, contact number, email, cloth type, and whether the cloth is branded.
61+
62+
3. `calculateCharge()`: Calculates the charge based on the type of cloth, branding, and season.
63+
- Returns:
64+
- Numeric, total charge for cleaning the cloth.
65+
66+
4. `finalDetails()`: Calls `customerDetails()` and `calculateCharge()` methods within itself and prints the total charge and the expected day of return.
67+
- Prints:
68+
- Total charge in Rupees.
69+
- Expected day of return (4 days if total charge > 200, otherwise 7 days).
70+
71+
## Example Usage
72+
```python
73+
# Example usage:
74+
name = input("Enter customer name: ")
75+
contact = int(input("Enter contact number: "))
76+
email = input("Enter email address: ")
77+
cloth_type = input("Enter cloth type (Cotton/Silk/Woolen/Polyester): ")
78+
branded = bool(int(input("Is the cloth branded? (Enter 0 for No, 1 for Yes): ")))
79+
season = input("Enter season (Summer/Winter): ")
80+
81+
customer = LaundryService(name, contact, email, cloth_type, branded, season)
82+
customer.finalDetails()
83+
Usage Instructions
84+
Create an instance of the LaundryService class by providing customer details as parameters to the constructor.
85+
Use the finalDetails() method to print the customer details along with the calculated charge and expected day of return.
86+
87+
88+
Contributors
89+
(Rohit Raj)[https://github.com/MrCodYrohit]
90+
91+

Laundary System/code.py

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
id=1
2+
class LaundryService:
3+
def __init__(self,Name_of_customer,Contact_of_customer,Email,Type_of_cloth,Branded,Season,id):
4+
self.Name_of_customer=Name_of_customer
5+
self.Contact_of_customer=Contact_of_customer
6+
self.Email=Email
7+
self.Type_of_cloth=Type_of_cloth
8+
self.Branded=Branded
9+
self.Season=Season
10+
self.id=id
11+
12+
def customerDetails(self):
13+
print("The Specific Details of customer:")
14+
print("customer ID: ",self.id)
15+
print("customer name:", self.Name_of_customer)
16+
print("customer contact no. :", self.Contact_of_customer)
17+
print("customer email:", self.Email)
18+
print("type of cloth", self.Type_of_cloth)
19+
if self.Branded == 1:
20+
a=True
21+
else:
22+
a=False
23+
print("Branded", a)
24+
def calculateCharge(self):
25+
a=0
26+
if self.Type_of_cloth=="Cotton":
27+
a=50.0
28+
elif self.Type_of_cloth=="Silk":
29+
a=30.0
30+
elif self.Type_of_cloth=="Woolen":
31+
a=90.0
32+
elif self.Type_of_cloth=="Polyester":
33+
a=20.0
34+
if self.Branded==1:
35+
a=1.5*(a)
36+
else:
37+
pass
38+
if self.Season=="Winter":
39+
a=0.5*a
40+
else:
41+
a=2*a
42+
print(a)
43+
return a
44+
def finalDetails(self):
45+
self.customerDetails()
46+
print("Final charge:",end="")
47+
if self.calculateCharge() >200:
48+
print("to be return in 4 days")
49+
else:
50+
print("to be return in 7 days")
51+
while True:
52+
name=input("Enter the name: ")
53+
contact=int(input("Enter the contact: "))
54+
email=input("Enter the email: ")
55+
cloth=input("Enter the type of cloth: ")
56+
brand=bool(input("Branded ? "))
57+
season=input("Enter the season: ")
58+
obj=LaundryService(name,contact,email,cloth,brand,season,id)
59+
obj.finalDetails()
60+
id=id+1
61+
z=input("Do you want to continue(Y/N):")
62+
if z=="Y":
63+
continue
64+
elif z =="N":
65+
print("Thanks for visiting!")
66+
break
67+
else:
68+
print("Select valid option")
69+
70+
71+
72+
73+
74+
75+

News_App/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
solara == 1.26.1
1+
solara == 1.32.2
22
Flask
33
gunicorn ==22.0.0
44
simple-websocket

Password Generator/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
colorama==0.4.6
2-
inquirer==3.2.1
2+
inquirer==3.2.4

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Feel free to explore the scripts and use them for your learning and automation n
5353
39. [space_invader.py.py](https://github.com/meezan-mallick/space_invader_game) - Classical 2D space invader game to recall your childhood memories.
5454
40. [Test Case Generator](https://github.com/Tanmay-901/test-case-generator/blob/master/test_case.py) - Generate different types of test cases with a clean and friendly UI, used in competitive programming and software testing.
5555
41. [Extract Thumbnail From Video](https://github.com/geekcomputers/Python/tree/ExtractThumbnailFromVideo) - Extract Thumbnail from video files
56+
42. [How to begin the journey of open source (first contribution)](https://www.youtube.com/watch?v=v2X51AVgl3o) - First Contribution of open source
5657
<hr>
5758

5859
_**Note**: The content in this repository belongs to the respective authors and creators. I'm just providing a formatted README.md for better presentation._

TowerOfHanoi.py

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from inorder_successor import inorder_successor
2+
# The above line imports the inorder_successor function from the inorder_successor.py file
3+
def delete_node(root,val):
4+
""" This function deletes a node with value val from the BST"""
5+
6+
# search in the left subtree
7+
if root.data < val:
8+
root.right = delete_node(root.right,val)
9+
10+
# search in the right subtree
11+
elif root.data>val:
12+
root.left=delete_node(root.left,val)
13+
14+
# node to be deleted is found
15+
else:
16+
# case 1: no child leaf node
17+
if root.left is None and root.right is None:
18+
return None
19+
20+
# case 2: one child
21+
if root.left is None:
22+
return root.right
23+
24+
# case 2: one child
25+
elif root.right is None:
26+
return root.left
27+
28+
# case 3: two children
29+
30+
# find the inorder successor
31+
IS=inorder_successor(root.right)
32+
root.data=IS.data
33+
root.right=delete_node(root.right,IS.data)
34+
return root
35+
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def inorder_successor(root):
2+
# This function returns the inorder successor of a node in a BST
3+
4+
# The inorder successor of a node is the node with the smallest value greater than the value of the node
5+
current=root
6+
7+
# The inorder successor is the leftmost node in the right subtree
8+
while current.left is not None:
9+
current=current.left
10+
return current
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def inorder(root):
2+
""" This function performs an inorder traversal of a BST"""
3+
4+
# The inorder traversal of a BST is the nodes in increasing order
5+
if root is None:
6+
return
7+
8+
# Traverse the left subtree
9+
inorder(root.left)
10+
11+
# Print the root node
12+
print(root.data)
13+
14+
# Traverse the right subtree
15+
inorder(root.right)

binary_search_trees/insert_in_bst.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from tree_node import Node
2+
def insert(root,val):
3+
4+
""" This function inserts a node with value val into the BST"""
5+
6+
# If the tree is empty, create a new node
7+
if root is None:
8+
return Node(val)
9+
10+
# If the value to be inserted is less than the root value, insert in the left subtree
11+
if val < root.data:
12+
root.left = insert(root.left,val)
13+
14+
# If the value to be inserted is greater than the root value, insert in the right subtree
15+
else:
16+
root.right = insert(root.right,val)
17+
return root

binary_search_trees/main.py

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
from tree_node import Node
2+
from insert_in_bst import insert
3+
from delete_a_node_in_bst import delete_node
4+
from search_in_bst import search
5+
from inorder_successor import inorder_successor
6+
from mirror_a_bst import create_mirror_bst
7+
from print_in_range import print_in_range
8+
from root_to_leaf_paths import print_root_to_leaf_paths
9+
from validate_bst import is_valid_bst
10+
11+
12+
def main():
13+
14+
# Create a BST
15+
root = None
16+
root = insert(root, 50)
17+
root = insert(root, 30)
18+
root = insert(root, 20)
19+
root = insert(root, 40)
20+
root = insert(root, 70)
21+
root = insert(root, 60)
22+
root = insert(root, 80)
23+
24+
# Print the inorder traversal of the BST
25+
print("Inorder traversal of the original BST:")
26+
print_in_range(root, 10, 90)
27+
28+
# Print the root to leaf paths
29+
print("Root to leaf paths:")
30+
print_root_to_leaf_paths(root, [])
31+
32+
# Check if the tree is a BST
33+
print("Is the tree a BST:", is_valid_bst(root,None,None))
34+
35+
36+
# Delete nodes from the BST
37+
print("Deleting 20 from the BST:")
38+
root = delete_node(root, 20)
39+
40+
# Print the inorder traversal of the BST
41+
print("Inorder traversal of the BST after deleting 20:")
42+
print_in_range(root, 10, 90)
43+
44+
# Check if the tree is a BST
45+
print("Is the tree a BST:", is_valid_bst(root,None,None))
46+
47+
48+
# Delete nodes from the BST
49+
print("Deleting 30 from the BST:")
50+
root = delete_node(root, 30)
51+
52+
# Print the inorder traversal of the BST after deleting 30
53+
print("Inorder traversal of the BST after deleting 30:")
54+
print_in_range(root, 10, 90)
55+
56+
# Check if the tree is a BST
57+
print("Is the tree a BST:", is_valid_bst(root,None,None))
58+
59+
# Delete nodes from the BST
60+
print("Deleting 50 from the BST:")
61+
root = delete_node(root, 50)
62+
63+
# Print the inorder traversal of the BST after deleting 50
64+
print("Inorder traversal of the BST after deleting 50:")
65+
print_in_range(root, 10, 90)
66+
67+
# Check if the tree is a BST
68+
print("Is the tree a BST:", is_valid_bst(root,None,None))
69+
70+
71+
print("Searching for 70 in the BST:", search(root, 70))
72+
print("Searching for 100 in the BST:", search(root, 100))
73+
print("Inorder traversal of the BST:")
74+
print_in_range(root, 10, 90)
75+
print("Creating a mirror of the BST:")
76+
mirror_root = create_mirror_bst(root)
77+
print("Inorder traversal of the mirror BST:")
78+
print_in_range(mirror_root, 10, 90)
79+
80+
if __name__ == "__main__":
81+
main()
82+
83+
84+
85+

binary_search_trees/mirror_a_bst.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from tree_node import Node
2+
def create_mirror_bst(root):
3+
""" Function to create a mirror of a binary search tree"""
4+
5+
# If the tree is empty, return None
6+
if root is None:
7+
return None
8+
9+
# Create a new node with the root value
10+
11+
# Recursively create the mirror of the left and right subtrees
12+
left_mirror = create_mirror_bst(root.left)
13+
right_mirror = create_mirror_bst(root.right)
14+
root.left = right_mirror
15+
root.right = left_mirror
16+
return root

0 commit comments

Comments
 (0)