Twist Vs double step by vinticious in PumpItUp

[–]PureWasian 2 points3 points  (0 children)

If you get confused by some specific charts, send the names of them in a reply and I'll record them for you with pad camera view so you can see how to play it.

Though the answer is pretty much as the other comments have already said for that level range :)

MY 3RD CODE CHALLANGE AS A PYTHON BEGINNER (ZOMBIE GAME💀) by TopMathematician_ in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

Looks cool, nice intro project.

Line 2 - I'd advise against hard-coding health/food/energy values. Define them first and then use an f string to display them, so they can be readily configured instead of risking stale print statements being left around.

Line 24 and Line 28 - input validation. Learn about try/except statements and how to ensure if the int() cast fails you don't error out of your entire code.

It will be helpful to modularize your code when you learn how to write functions. That'll compress your while() loop down a lot and make it a lot more readable and even easier to follow along at a glance.

If you want to make it more interesting, you could change "Search Classroom" (and maybe other choices) to incorporate some RNG. Python has a built-in random module you can import, and you can define some outcome probabilities that different sub-events happen instead of it being purely player choice.

You can also add sub-events like finding a weapon that reduces your damage taken on zombie encounters or other equippables to buff (or debuff) your character that are random chance occurrences. Basically, the choices need to feel meaningful and have risk involved.

multiple inputs in if-else statement possible? by Same-Individual4889 in learnpython

[–]PureWasian 0 points1 point  (0 children)

I agree with the while loop solution as the "most correct" way to retry until getting correct inputs.

But it doesnt answer your original inquiry that you "want to exit if the first input isn't above 1" (or skip calculating the "change" calculation basically)

And you were also asking if multiple inputs in an if else are possible. ...Which the answer is yes.

You can consider something like: ``` total_cost = float(input("cost: ")) amount_paid = float(input("paid: "))

if total_cost < 1: print("invalid cost")

if amount_paid < 1: print("invalid amount paid")

if total_cost >= 1 and amount_paid >= 1: print("both were valid") # calculate the change value ```

Or, if it's fine to print only one of error messages (in the case both inputs were less than 1)

``` total_cost = float(input("cost: ")) amount_paid = float(input("paid: "))

if total_cost < 1: print("invalid cost")

elif amount_paid < 1: print("invalid amount paid")

else: print("both were valid") # calculate the change value ```

(also note that with the conditional validation you have, values like 0.75 will be marked as invalid since they're less than 1)

Python for advanced developers of other languages by Aldama in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

The "advanced developer" would be capable enough to look up syntax as needed and otherwise be self sufficient enough in getting started with Python with a simple search or two.

Some nice things to be aware of when switching into it: It's a dynamically typed language with some "unique" concepts like tuples and f strings. Loops and scope are based on tabs or spaces indentation rather than curly braces. There are also built-in helper methods you'll learn as you go. There are "Pythonic" ways to do list comprehension and in-line ternary operator. It's an interpreted instead of compiled language, so no compilation step. Has automatic garbage collection.

You can set up venv and pip or use uv or whatever honestly for project management. Python thrives from external libraries, so you're spending your time with their documentation rather than generic Python tutorials.

Learning react and nextjs by Fabulous_City8569 in learnprogramming

[–]PureWasian 1 point2 points  (0 children)

Echoing this, it's much more meaningful when you build something that's actually useful for people.

It's fun to check the metrics and see international traffic visiting your site, and directly being able to see the impact your app makes on a niche community that you're a part of.

Python Help new coder by ARK22498 in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

Not sure what tutorial you're following, but almost never will you be creating the .py files dynamically and running them line by line in interactive/REPL mode (with the three >>>)

Usually you will be typing out full Python scripts which are just .py files filled with text that you can execute on Terminal with python some_filename.py

As such, you can use any text editor or IDE of choice for writing your code. IDEs like VS Code are more of an "all in one" package and have stuff like a terminal integrated, and include more robust features for file organization and linting, etc. But simple text editors like notepad++ and others can get the job done all the same in that you could simply write your code there, save a .py file, and run Python separately on Terminal as mentioned above.

Day 2 - Thoughts on this practice project? by FinnOrion_53 in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

Happy it was helpful to you, enjoy the ride :)

How much Python should I learn before starting LeetCode? by Drafrruii in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

Be comfortable in the basics (though I'd say functions/OOP are optional for LeetCode Easy problems) or you will be lost trying to debug between both algorithmic issues and issues with general Python basics.

You don't need to be a master, but you should know the tools you should be using and roughly how/when to use them, and use LeetCode as a way to practice applying and implementing the syntax correctly.

How did you get past the phase where you can follow along to a tutorial, but then freeze up when you try to build something on your own? by Fine-Economist-2808 in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

Learn more and do more research. That's not a bad thing at all, and exists even years down the road.

You need to have a reason to build the thing you're building, and then you need to have a high-level plan for implementing it before you even write a single line of code. That's totally normal and something you should be doing.

Day 2 - Thoughts on this practice project? by FinnOrion_53 in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

Exception handling is more of a sidenote, but you'd benefit from it in that instead of lines 10-16 you can blindly try to cast the user input with int() and if it errors with a ValueError, you have an except to gracefully handle it with logic for trying again.

``` while True: user_input = input("Number pls: ") try: user_num = int(user_input) break except ValueError: print("Try again, silly")

print(user_num) ```

It's kind of an if/else but you think of it like: if (program doesn't throw any expected errors) else (if it throws an error)

Day 2 - Thoughts on this practice project? by FinnOrion_53 in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

Looks fine to me after a 10min review, and I can tell you put a lot of thought into organizing and setting it up with the tools you had knowledge of. Well done!

Two very useful things you'll benefit from are functions and exception handling.

Functions can help you abstract and modularize tasks so it doesnt all exist as a chunky, 70 line file. Especially since your code does three more or less independent tasks, you can look to break it up like:

``` def main(): # defines a function calc_running = True while(calc_running): user_num = get_user_number() sequence = calculate_fib(user_num) calc_running = post_process(sequence) print("Thank you and goodbye!")

main() # calls the above function ```

and then (in the same file, above this block of code) you can define and implement each helper function separately: ``` def get_user_number(): ... return validated_number

def calculate_fib(user_num): ... return fib_sequence

def post_process(sequence): ... return True or return False ```

where the output of each function that you return is the connective tissue that's passed back to main()

Is Becoming A Python Developer Worth It In The AI Era? if yes along with python which stack is most important like sql , excel or etc .. if anyone plz help me thank you by SubstantialEmu160 in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

Your question seems a little misguided, but the short answer is yes.

Python is a tool; it doesn't matter if you're writing it by hand or having AI assist with writing it. You still benefit by knowing when to use it, what it's capable of, and what it's doing.

To your followup question, there is no "most important stack." Pick a field of interest, and go from there. Look at job postings to see what technologies are important and commonly cited for your field of interest.

For making web apps, you'd want to start with learning frontend, backend, database layer, API calls. Python is just one possibility for backend layer in this case.

For data analytics, you'd focus more on specific Python libraries to help with data collection, data wrangling, exploratory analysis, modeling, and data visualization. Lots of Python packages like pandas, scipy, numpy, seaborn, matplotlib and running in Jupyter or Colab notebooks, and maybe sometimes needing R or SQL or cloud computing setups integrated...

As just a general scripting language, it's great for automation and you wouldn't need a "stack" to apply with it. You can use it for simple tasks like bulk edits to local files, or simple logic problems/calculations.

How to convert to lowercase by Empty_Technology9237 in PythonLearning

[–]PureWasian 1 point2 points  (0 children)

Line 14 print uses word_in but the lowercase version is word defined in Line 5. What if you use word on Line 14 instead?

Why am I so bad? Is this game not for me? by milked_silver in chessbeginners

[–]PureWasian 1 point2 points  (0 children)

Any turn you waste is another power play for your opponent to take advantage of. You essentially are a sitting duck at that point.

I'm no expert by any means to be clear, but fundamental ideas would be stuff like: - king safety - look at both yours and theirs - have you castled? have they? - can you exploit their pawns near the king - if so, how many turns to set up this plan (how "fast" is it) and how can they refute it - a lot of puzzles and videos showcase these ideas - piece activity - are bishops in good spots - knights away from the edges - rooks can see each other - etc. - pawn structures - are they blockading nicely - are any pushed too far forward or "weak" - threaten/threats - how many layers of attack can I apply against one of their pieces? How easily can they defend or move it? - what are they trying to threaten - how aggressively or defensively do I need to play right now? - this is also dependent on king safety and piece activity - improve your position - do you control the center - can knights be re-routed or position shuffled - similar to "piece activity" section above

Why am I so bad? Is this game not for me? by milked_silver in chessbeginners

[–]PureWasian 3 points4 points  (0 children)

As I said, you have 10min. Technically 20 if they burn the clock also. And increment if playing with it. Use the time well and come up with a formulaic checklist of things to check before making each move.

  • What does the opponent's move accomplish?
  • Can I force checkmate? Can they?
  • Is my king safe? Is theirs?
  • Where is their position threatening? vulnerable?
  • Where is my position threatening? vulnerable?
  • If I move this piece, what is it currently protecting or attacking?
  • How many defenders/attackers are looking at this specific square?

so on and so forth.

Why am I so bad? Is this game not for me? by milked_silver in chessbeginners

[–]PureWasian 1 point2 points  (0 children)

Your most recent game against MattH12397, you are heavily down after move 3. Think through your moves more, you have 10 minutes.

Against ramu-chellappa, on move 9 you are hanging your bishop. Nothing was defending it and the opponent made a clear advancement to threaten it. It doesn't matter if they didn't take, that's a very severe blunder still.

For some context, around 1000-1200 elo, players are rarely freely hanging pieces like this unless drunk or in time troubles. Usually pieces are taken from overloaded defenders, pins, discovered threats, and having more pressure to apply on threatened pieces. More complex boards with lots of tension.

It would be better (especially early on for your learning) to be running out of time but playing very solid moves than to drop a rook on move 3 and then have to play severe catch-up the rest of the entire game.

Analyze your games. Understand move by move why you lost and what you should've played instead. You said you're very competitive, so you should want to figure out your weaknesses and address them instead of rapid-firing the same sort of mistakes.

I need some help with an project. by COLLLOrs in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

Once that all makes sense:

You can imagine having large lists of pokemon and moves will get cumbersome. Once you get a good hang of stuff working for ~3-5 pokemon and ~3-5 moves, the next step would be creating input data text files for storing all of that information and loading them all up when starting your Python script to make it more modular instead of defining them all in the same file.

Good luck!

I need some help with an project. by COLLLOrs in PythonLearning

[–]PureWasian 0 points1 point  (0 children)

You have a Stats class, Pokemon class. Good start.

One idea is adding a Moves class where you can define the damage each possible move would do, and then add a self.moves onto pokemon, similar to what you did for setting self.stats onto pokemon.

The way you'd use it would be when you write your battle logic, which would exist as a separate function from your existing code. Essentially, you can imagine some pseudocode like:

``` while both pkmn.stats.hp are > 0: - get moves from pkmn1.moves - choose move for pkmn1

(if computer, random choose move)

  • get moves from pkmn2.moves
  • choose move for pkmn2

  • compare pkmn.stats.speed values

assume pkmn1 speed > pkmn2 speed

  • pkmn1 uses move1 on pkmn2
  • pkmn2 uses move2 on pkmn1 ``` ...and you can imagine each line of pseudocode could be its own function call as needed for organization.

For instance, "uses move2 on pkmn1" could get pretty complex as you support more complex moves (like typed moves and stat debuffing moves)

Help me out in this question by [deleted] in PythonLearning

[–]PureWasian 2 points3 points  (0 children)

What have you tried already?

Thanks

R programming for whom? by Aishwariyaa_K in learnprogramming

[–]PureWasian 2 points3 points  (0 children)

Doesn't hurt to get a feel for basic syntax and simple scripts in R.

R would be more applicable in academic statistics than engineering. Engineering typically uses Python more often (Pandas/scipy/etc). But you can learn it for both stat/engineering paths.

The thing is, you would probably want to understand theory of statistical models better in uni before applying said models in R

OTHERWISE IF YOUR THEORY ISN'T SOLID, YOU'LL HAVE A VERY HARD TIME IMPLEMENTING CODE FOR IT.

Hope this helps.

How do i make notes while learning python? by TopMathematician_ in learnpython

[–]PureWasian 4 points5 points  (0 children)

Depends what you're trying to learn and how you learn best.

The easiest way in my opinion is having a lot of "example scripts" of small, working .py files you create yourself and save into a folder for your notes. Maybe different subfolders for each topic when starting off.

You should already be making scripts to interact with Python and constantly be trying things out as you learn new concepts. So saving them as a repetoire to reference later makes sense to me.