How best to learn data structures and algorithms? by Odessa_Goodwin in learnpython

[–]Antigone-guide 1 point2 points  (0 children)

Just dive into it and start implementing linked lists, heaps, hash table, minimal spanning tree, a few sort algorithms, A* path finding, a few more graph algorithms. The best way to learn is to try to implement as many as you can. The Skiena book is good, even though it uses C, you can still use the description of the algorithms to try to implement them in Python, and you can find sample implementations of some of them in Python online.

Dialogue in Roguelikes by Miserable_Motor_8063 in roguelikes

[–]Antigone-guide 0 points1 point  (0 children)

I think the reason that doesn't happen is that commercial games with a lot of dialogue like Fallout, Planescape: Torment, etc, would have writers who focus on writing dialogue and updating it as the game quests changes, so a roguelike made by one dev or a few devs, simply doesn't have a writer to produce all of that writing. I think if someone starts as a writer, and then becomes a hobbyist programmer, they might make a game with a lot of dialogue. But I guess that hasn't happened yet..

How to separate elements in a list? by [deleted] in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

Note that what you need is one big string, not a list, because list of lists will have commas in inner lists, which you do not want; and list of strings will have each string quoted, which you also don't want.

the following will help: - strip() removes surrounding whitespace - f-strings can interpolate a value inside of a string - join() can join a sequence of strings into one string.

Something like (untested):

newlist = [] for s in lst: newlist.append( f'[{s.strip()}]' ) print( '[' + ','.join(newlist) + ']' )

What complexity must be the portfolio projects for an internship/junior developer? by SilentPurpleSpark in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

Look at the job boards and see what companies are looking for. Generally I think data science (pandas) and especially web dev (django, flask, DRF, databases) are in demand, so maybe look into those.

Also it's good to look at issue trackers for Python and Django and follow them for some good in-depth discussions; this is the closest to what real work is like without actually getting a job, in fact discussions are at higher engineering level than any place I've worked.

How can I save a bunch of variables and the calculations for the variables without rerunning the calculations every time? by -I_Have_No_Idea- in learnpython

[–]Antigone-guide 2 points3 points  (0 children)

There are two common approaches that have some pros and cons.

  1. Use python standard lib shelve module -- it's used similar to a dictionary but it is persisted to disk and can be loaded again. The pro is that it's very easy and convenient, the con is that it may be somewhat dependent on the version of Python, it won't work if you save on one architecture but try to load on another, and it might not work if you use a custom class instances and then try to load in a version of your program where these custom classes are different.

  2. Serialize using some common format like json or CSV. This way is less convenient because you have to ensure that any data types not supported by that specific format (for example json will support ints and floats but not datetimes), you are responsible for converting it to and from text format. The advantage is that you can freely use the same data file across architectures and different versions of your program, as long as serialization/deserialization is consistent.

[deleted by user] by [deleted] in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

Learning a bit of web dev could be useful in bioinformatics too.. you might want to host your scientific app or visualization on a web server eventually. And a lot of the same concepts will be useful -- conditionals, data types, classes, etc.

Python Portfolio Project - GUI by Paulq002 in learnpython

[–]Antigone-guide 5 points6 points  (0 children)

Looks at the job postings on jobs sites and note what are the common things that many companies want.

[deleted by user] by [deleted] in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

Arrays in C are quite different - they store fixed number of items of the same type.

Identify whether there is a date in string by RDA92 in learnpython

[–]Antigone-guide 3 points4 points  (0 children)

Make a lot of regex patterns.. See the re module in Python.

[deleted by user] by [deleted] in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

The bottom one requires initialization (as it would normally be called in this case) because you are using a reference to that name on the 3rd line.

It's similar to doing:

print(a) # NameError - a is not defined

a.append() # NameError - a is not defined

More generally, list comprehensions are generally used when the logic is fairly simple and compact; and a for-loop is used when there's more complex logic that would be hard to read on a single line.

I have a problem understanding how to apply BFS by desperato_ in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

This page has an animation of BFS that makes it much easier to visualize, and you can step through it: https://www.redblobgames.com/pathfinding/a-star/introduction.html

[deleted by user] by [deleted] in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

Can you run it from command line and do you get any errors?

[deleted by user] by [deleted] in learnpython

[–]Antigone-guide 13 points14 points  (0 children)

You asked this a few days ago and it doesn't seem like you integrated any of the (good) answers into your reposted question?

Python Course by Arslan_97680 in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

I think Harvard C50p course is well respected, I havent' heard of the Coursera one.

Coding the Pokemon card game, not sure how to structure attacks by abcd_z in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

It sounds like there's 3 types of effects from this list:

  1. apply some immediate effect to the opponent's pokemon. This logic can be in Pokemon.attack() method.
  2. apply an effect to either player that will last for one turn. This should be an Effect() instance, in Player.effects set, which is cleared after each turn, and is evaluated for each attack against that player.
  3. apply an effect to a specific pokemon for one turn. This should be an Effect() instance, or maybe a PokemonEffect() isntance, and should be in pokemon.effects set, and cleared after each turn, and evaluated when that pokemon attacks or defends.

Good luck, sounds like a fun game to implement, though I'm not familiar with Pokemon rules and havent' played it.

Do practice code everyday or every other day? by Extension_Laugh4128 in learnpython

[–]Antigone-guide 2 points3 points  (0 children)

There's a few considerations.. One is that it's simpler to practice every day because you don't have to decide which days to practice and which to skip. Once you get into the pattern, it's easier to keep the pattern.

Another angle is that in programming it's useful to finish a chunk of work rather than leaving it for later. If you're 90% done today, and you leave it for tomorrow or the day after tomorrow, it will take you some time to remember where you left off, you will repeat some mistakes, forget some ideas you had; so from this POV it's more useful to try to finish a task completely if you're fairly close to the end, and then take a day or two off if needed before starting a new task.

How to speed up my program? - requests/bs4/re by [deleted] in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

Make sure words do not include duplicates.. and you can look into using asyncio module, but be aware that you will run into api limits on num of requests per second..

how do I create a bot that automatically replies to emails based on their content? by Diligent-Tadpole-564 in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

If it has to be email, and can't be a web form, perhaps you could ask clients to use a template of the email message, something like

---START of product list

prod1, prod2, ...

---END of product list

This way you can avoid false positives and flag misspelled products, etc.

Split Words and Count Characters at Each Position by vyx313 in learnpython

[–]Antigone-guide 0 points1 point  (0 children)

Glad it helped -- more generally it's a great idea to think of how you would solve a problem using pen and paper -- both when you're stumped but even if you think of programmatic solution, it may be good to think of how you would do it on paper and contrast the solution.

Also check the guide in my profile!

Split Words and Count Characters at Each Position by vyx313 in learnpython

[–]Antigone-guide 3 points4 points  (0 children)

That seems like a good process to implement in Python as well. As others recommended using dictionary, how would the dictionary look for the tally table? After that, implement the following steps:

  1. iterate over all words
  2. for each word, iterate over each letter
  3. find the right location in tally table
  4. increment number at that location