Skip to content

complete workshop 1-5#9

Open
prudak13 wants to merge 1 commit intoCodersLab-CZ:masterfrom
prudak13:master
Open

complete workshop 1-5#9
prudak13 wants to merge 1 commit intoCodersLab-CZ:masterfrom
prudak13:master

Conversation

@prudak13
Copy link

@prudak13 prudak13 commented Feb 3, 2024

No description provided.

"""
pc = random.randint(1,100)
while True:
try:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ten try je lepsi udelt mensi a obalit jen tu cast, kde cekas ten error

from random import shuffle

def user_turn():
user_list = []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pouzij set

def pc_turn():
pc_list = list(range(1,49))
shuffle(pc_list)
return sorted(pc_list[:6])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taky by bylo lepsi set

return sorted(pc_list[:6])

def hit(a,b):
intersection_set = set(a) & set(b)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protoze kdyzbys mel dva sety je tady z tech list nemusis zbytecne delat


def lotto():
user = user_turn()
if user is None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proc by mel byt user None?


if x == 10:
print("Don't cheat!")
if user in answer:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tohle je lepsi udelat pres negtivni podminku abyses zbytecne nezanoroval


@app.route("/", methods=["GET", "POST"])
def index():
global min_value, max_value, guess

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

globalni prommene nejsou dobra praxe. To se neuc pouzivat. To je hack. Neni to potreba, nainicializuj si je normalne uvnitr


if parts[1] != "D":
print("Invalid dice Type")
sys.exit()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uf sys.exit asi ne e. proc ne proste return? nebo vyhod vyjimku kterou jste se ucili

result = (random.randint(1,int(dice_type)))
total += result

if len(parts) >= 5:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mas tu celkem komplikovanou logiku celeho toho parsovani a neni to ani spravne. Umozni to zadat nesmysl jako kupr toto roll_the_dice("2D6-1QQQQQQQQ") coz by ten od mel zachytit jako chybny vstup.

To parsovani se typicky dela pres regexy. Tahle je to prilis komplikovane a je to mess. Ja jsem kdyztak nahraval ven svoji vetev tak se muzes podivat jak se to parsuje aby to bylo citelne.

Citelnost je v pythonu dulezita.

Ale jinak jako Good Job.

Je videt ze se snazis a mas potencial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants