Skip to content

Commit

Permalink
Merge pull request #776 from Polqt/my-new-branch
Browse files Browse the repository at this point in the history
Blind Auction by Pol Hidalgo
  • Loading branch information
Mrinank-Bhowmick authored Aug 11, 2024
2 parents df0ecef + 805d1ae commit c90b8d6
Show file tree
Hide file tree
Showing 11 changed files with 1,036 additions and 0 deletions.
8 changes: 8 additions & 0 deletions projects/Blind Auction/.pythonlibs/bin/flask
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
from flask.cli import main
if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit(main())
8 changes: 8 additions & 0 deletions projects/Blind Auction/.pythonlibs/bin/normalizer
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
from charset_normalizer.cli.normalizer import cli_detect
if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit(cli_detect())
8 changes: 8 additions & 0 deletions projects/Blind Auction/.pythonlibs/bin/replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
from replit.__main__ import cli
if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit(cli())
14 changes: 14 additions & 0 deletions projects/Blind Auction/.replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
entrypoint = "main.py"
modules = ["python-3.10:v18-20230807-322e88b"]

hidden = [".pythonlibs"]

[nix]
channel = "stable-23_05"

[unitTest]
language = "python3"

[deployment]
run = ["python3", "main.py"]
deploymentTarget = "cloudrun"
1 change: 1 addition & 0 deletions projects/Blind Auction/.upm/store.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":2,"languages":{"python-python3-poetry":{"specfileHash":"2d4d777e9c247f7151bfd5e9ce3ae966","lockfileHash":"a2a165a61ae2d57ed0868ca40de88728","guessedImports":["replit"],"guessedImportsHash":"2f1d64f65aaeefd4f2a4b8cf6714035c"}}}
41 changes: 41 additions & 0 deletions projects/Blind Auction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Blind Auction

Click "Open Preview" above to see this file rendered with the markdown.

# Instructions

The objective is to write a program that will collect the names and bids of different people. The program should ask for each bidder's name and their bid individually.

```
Welcome to the secret auction program.
What is your name?: Angela
```
```
What's your bid?: $123
```
```
Are there any other bidders? Type 'yes' or 'no'.
yes
```
If there are other bidders, the screen should clear, so you can pass your phone to the next person. If there are no more bidders, then the program should display the name of the winner and their winning bid.

```
The winner is Elon with a bid of $55000000000
```

Use your knowledge of Python dictionaries and loops to solve this challenge.


# My console doesn't clear!

This will happen if you’re using an IDE other than replit (e.g., VSCode, PyCharm etc). Similar to how we used the "random" module previously, in this project we will use the "replit" module. The `clear()` function is available here via the replit module without any extra configuration.

**I’ll cover how to use PyCharm and import modules on Day 15**. That said, you can write your own `clear()` function or configure your IDE like so:

[Udemy Q&A Answer](https://www.udemy.com/course/100-days-of-code/learn/lecture/19279420#questions/16084076)


# Solution

[https://replit.com/@appbrewery/blind-auction-completed](https://replit.com/@appbrewery/blind-auction-completed?v=1)
13 changes: 13 additions & 0 deletions projects/Blind Auction/art.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
logo = '''
___________
\ /
)_______(
|"""""""|_.-._,.---------.,_.-._
| | | | | | ''-.
| |_| |_ _| |_..-'
|_______| '-' `'---------'` '-'
)"""""""(
/_________\\
.-------------.
/_______________\\
'''
31 changes: 31 additions & 0 deletions projects/Blind Auction/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from replit import clear
#HINT: You can call clear() to clear the output in the console.

from art import logo
print(logo)

bids = {}
bidding_finished = False

def find_highest_bidder(bidding_record):
highest_bid = 0
winner = ""
for bidder in bidding_record:
bid_amount = bidding_record[bidder]
if bid_amount > highest_bid:
highest_bid = bid_amount
winner = bidder
print(f"The winner is {winner} with a bid of ${highest_bid}.")

while not bidding_finished:
name = input("What is your name? ")
bid = int(input("What is your bid? $"))
bids[name] = bid

should_continue = input("Are there any other bidders? Type 'yes' or 'no': ").lower()
if should_continue == "no":
find_highest_bidder(bids)
bidding_finished = True
elif should_continue == "yes":
clear()

887 changes: 887 additions & 0 deletions projects/Blind Auction/poetry.lock

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions projects/Blind Auction/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[tool.poetry]
name = "python-template"
version = "0.1.0"
description = ""
authors = ["Dr Angela Yu"]

[tool.poetry.dependencies]
python = ">=3.10.0,<3.11"
replit = "^3.5.0"

[tool.pyright]
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md
useLibraryCodeForTypes = true
exclude = [".cache"]

[tool.ruff]
# https://beta.ruff.rs/docs/configuration/
select = ['E', 'W', 'F', 'I', 'B', 'C4', 'ARG', 'SIM']
ignore = ['W291', 'W292', 'W293']

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
2 changes: 2 additions & 0 deletions projects/Blind Auction/replit_zip_error_log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"error":".zip archives do not support non-regular files","level":"error","msg":"unable to write file .cache/replit/modules/python-3.10","time":"2024-08-01T13:42:25Z"}
{"error":".zip archives do not support non-regular files","level":"error","msg":"unable to write file .cache/replit/modules/replit","time":"2024-08-01T13:42:25Z"}

0 comments on commit c90b8d6

Please sign in to comment.