The Silent Auction project is a Python script that allows users to participate in an auction by submitting their bids anonymously. After all bids are submitted, the program determines the highest bidder and announces the winner without revealing the identities of the other participants.
https://en.wikipedia.org/wiki/First-price_sealed-bid_auction
https://replit.com/@AntuSarder/Silent-Auction-A-Python-Dictionaries-Project?v=1
Silent.Auction.mp4
- Anonymous Bidding: Users can submit their bids without revealing their identities.
- Winner Determination: The program automatically determines the highest bidder and announces the winner while keeping other participants' identities confidential.
- User-Friendly Interface: Clear prompts and instructions make it easy for users to participate in the auction anonymously.
-
Clone the repository to your local machine:
git clone https://github.com/Himel-Sarder/Silent-Auction--A-Python-Dictionaries-Project.git
-
Navigate to the project directory:
cd Silent-Auction--A-Python-Dictionaries-Project
-
Run the script:
python Silent Auction.py
- Python Dictionaries
- Loop
- Function
- If/Else
- Enter your bid amount when prompted.
- Continue bidding or type 'no' when asked if there are any other bidders.
- The program will announce the winner and their bid amount without revealing other participants' identities.
-
Start the Program: Run the Silent Auction program by executing the
Silent Auction.py
script. -
Join the Auction: Enter your name and the amount you want to bid when prompted. Your bid will remain anonymous, so feel free to bid any amount you're comfortable with.
-
Continue Bidding: After submitting your bid, you have the option to continue bidding or to stop. If you choose to continue, the program will prompt you to enter another bid.
-
End Bidding: When you're finished bidding, type 'no' when asked if there are any other bidders. This will signal that you're done bidding and ready to see who the winner is.
-
Winner Announcement: Once all bids have been submitted, the program will determine the highest bidder and announce the winner. The winner's identity will be revealed, along with the winning bid amount. Other participants' identities will remain confidential.
-
Enjoy the Victory: If you're the highest bidder, congratulations! You've won the auction. If not, better luck next time!
-
Play Again: If you enjoyed the auction, feel free to play again by restarting the program and joining a new auction.
- Bid Strategically: Consider the value of the item being auctioned and bid accordingly. Remember, the highest bidder wins, so bid wisely.
- Stay Informed: Keep track of other participants' bids if possible, but remember that their identities are confidential. Use your bidding strategy to your advantage.
- Have Fun: Silent auctions are meant to be enjoyable experiences. Relax, bid confidently, and have fun participating!
Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.
Coded by--
- Himel Sarder
- Dept. of Computer Science and Engineering
- BSFMSTU, Jamalpur, Bangladesh
This project is licensed under the MIT License.
Python dictionaries are unordered collections of data in key:value pairs. They are similar to real-world dictionaries, where you look up a word (the key) to find its definition (the value). In Python, dictionaries are extremely versatile and can hold various types of data, including numbers, strings, lists, or even other dictionaries.
You can create a dictionary in Python using curly braces {}
and separating key:value pairs with commas. Here's an example:
# Creating a dictionary
my_dict = {"name": "John", "age": 30, "city": "New York"}
You can access the values in a dictionary by referring to its key within square brackets []
or by using the get()
method. If the key does not exist, accessing it directly will raise a KeyError
, while get()
will return None
or a default value if specified.
# Accessing values
print(my_dict["name"]) # Output: John
print(my_dict.get("age")) # Output: 30
print(my_dict.get("gender", "Male")) # Output: Male (default value)
You can add new key:value pairs to a dictionary or modify existing ones.
# Adding a new item
my_dict["job"] = "Engineer"
# Modifying an existing item
my_dict["age"] = 31
You can remove items from a dictionary using the del
keyword or the pop()
method.
# Removing an item using del
del my_dict["city"]
# Removing an item using pop()
job = my_dict.pop("job")
Python dictionaries come with various built-in methods to perform operations on them.
Returns a view of all the keys in the dictionary.
Example:
my_dict = {"name": "John", "age": 30, "city": "New York"}
keys_view = my_dict.keys()
print(keys_view) # Output: dict_keys(['name', 'age', 'city'])
Returns a view of all the values in the dictionary.
Example:
my_dict = {"name": "John", "age": 30, "city": "New York"}
values_view = my_dict.values()
print(values_view) # Output: dict_values(['John', 30, 'New York'])
Returns a view of all the key-value pairs in the dictionary as tuples.
Example:
my_dict = {"name": "John", "age": 30, "city": "New York"}
items_view = my_dict.items()
print(items_view) # Output: dict_items([('name', 'John'), ('age', 30), ('city', 'New York')])
Removes all items from the dictionary.
Example:
my_dict = {"name": "John", "age": 30, "city": "New York"}
my_dict.clear()
print(my_dict) # Output: {}
Updates the dictionary with the key-value pairs from another dictionary or iterable.
Example:
my_dict = {"name": "John", "age": 30}
new_data = {"city": "New York", "job": "Engineer"}
my_dict.update(new_data)
print(my_dict) # Output: {'name': 'John', 'age': 30, 'city': 'New York', 'job': 'Engineer'}
Returns a shallow copy of the dictionary.
Example:
my_dict = {"name": "John", "age": 30}
copy_dict = my_dict.copy()
print(copy_dict) # Output: {'name': 'John', 'age': 30}
Returns the number of items in the dictionary.
Example:
my_dict = {"name": "John", "age": 30, "city": "New York"}
print(len(my_dict)) # Output: 3
These methods provide useful functionalities for working with dictionaries in Python, making it easier to manipulate and retrieve data stored in dictionaries.
You can iterate over a dictionary using loops. By default, looping over a dictionary traverses its keys.
# Looping through keys
for key in my_dict:
print(key, my_dict[key])
# Looping through values
for value in my_dict.values():
print(value)
# Looping through key-value pairs
for key, value in my_dict.items():
print(key, value)
Like lists, dictionaries also support comprehensions for creating dictionaries in a concise manner.
# Dictionary comprehension
squares = {x: x*x for x in range(1, 6)}
# Output: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
Nested dictionaries are dictionaries within dictionaries, creating a hierarchical structure to represent more complex data. Here's an example to illustrate nested dictionaries:
# Nested dictionaries example
nested_dict = {
"person1": {
"name": "John",
"age": 30,
"address": {
"city": "New York",
"zip": "10001"
}
},
"person2": {
"name": "Alice",
"age": 25,
"address": {
"city": "Los Angeles",
"zip": "90001"
}
}
}
In this example, nested_dict
contains two key-value pairs, each representing information about a person. Each person's information is stored as another dictionary with keys for name
, age
, and address
. The address
key further contains a dictionary with keys for city
and zip
.
You can access nested dictionary values using multiple square brackets to traverse through the layers:
# Accessing nested dictionary values
print(nested_dict["person1"]["name"]) # Output: John
print(nested_dict["person2"]["address"]["city"]) # Output: Los Angeles
Similarly, you can modify or add elements to nested dictionaries:
# Modifying nested dictionary
nested_dict["person1"]["age"] = 35
nested_dict["person2"]["address"]["city"] = "San Francisco"
# Adding to nested dictionary
nested_dict["person1"]["address"]["street"] = "123 Main St"
Nested dictionaries are useful for representing structured data, such as hierarchical relationships or complex objects, and are commonly used in various programming scenarios.
Python dictionaries are fundamental data structures that offer fast and efficient lookup operations. They are widely used in various Python programs for storing and manipulating data in a flexible manner.