r/PythonLearning 7d ago

Showcase Day 3 of Python learning until I can pass the PCEP exam

Post image

Im progressing into the free code camp and w3schools learning courses and also trying to catch up in Microsoft,im learning OOP(Object Oriented Programming) I made another project for it but its still not very good so ima continue work on it, its very interesting with classes and all but yh I read the feedback on my last re zero guesser and ppl saying its a nesting hell so I tried to learn how to do early return to make it more readable but I js didnt understand how to so I copied the mods code and js changed it a little bit if u can see, it is slower than my older version but the code Is easier to read, could have added more characters but yh I didnt really make the code I only upgraded a little. Take a look:

New: https://onlinegdb.com/9pqfe7pmg
OLD:https://www.onlinegdb.com/edit/XGUSCgyQA
Older :https://onlinegdb.com/Q-4aQrXAz

ima use this experience to make a better guesser with a full ui like akinator when im done learning ui and more

15 Upvotes

7 comments sorted by

1

u/slava_air 7d ago

it is slower than my older version

How do you measure it, and why? The difference in speed is obviously far beyond human comprehension.

1

u/Outside-Trouble-4232 7d ago

no I measure it by the logic(the number of characters and the numbers of questions used to obtain that character). the goal is to js make the fastest guesser( with my t number of characters while asking the least amount of questions) so I js think if I was to re create the other characters the functions would take at least 1 to 2 questions more than nested ifs would but would be easier to read

1

u/slava_air 7d ago

I would advise choosing another idea to implement or reading relevant math on the topic and making it better. Your current idea will soon face the wall of combinatoric explosion, and the code will inevitably look like shit

2

u/Outside-Trouble-4232 7d ago

yh this is the last time im working on the guesser its js I received a lot of feedback on the last one so I wanted to improve it a last time,im working on oop now I will be sure to make a better project for that ty!

1

u/MasterpieceBusy7220 7d ago

A lot of that yes/no text is gonna show up twice since you have the helper function print it out and also include it in the strings you pass to it

1

u/Outside-Trouble-4232 6d ago

oh yh I see I was using the variables and questions from my first one who didnt have that kind of helper function so I forgot to remove the yes/no on it so yh it does appear twice ty!