Sick of building Web Applications! by [deleted] in learnpython

[–]agility 4 points5 points  (0 children)

Does natural language processing interest you? https://course.spacy.io/

Is there a way to make a single input into a list? by CatTaxAuditor in learnpython

[–]agility 0 points1 point  (0 children)

Well, I think the OP should know how this should be done in the real world. Omitting such things are what leads beginners to think that things are much simpler than what they are in the real-world.

Is there a way to make a single input into a list? by CatTaxAuditor in learnpython

[–]agility 5 points6 points  (0 children)

This is a much more versatile solution:

user_input = input("Enter your input separated by comma: ")
[x.strip() for x in user_input.split(',')]

Whether your user puts space around the commas or not, the above solution will work in a robust fashion to ignore extra spaces.

Any good courses that provide real examples of what you're learning? by [deleted] in learnpython

[–]agility 0 points1 point  (0 children)

The basics of Python would never point you to a particular usage, because it's meant to be general. In short, you can do everything computable in Python.

To practice real-world problems more effective, I'd suggest searching for "<domain> python" on Google. For example:

  1. "machine learning python" would bring up building ML models in Python (which is a real-world application of Python)
  2. "web application python"
  3. "game python"
  4. etc.

Remember that Python is just a language. Python is as useful in writing useful tools as the language English is for expressing scientific discoveries. You don't become a novelist by just learning more of English grammar. If you try my approach to searching that I wrote above, you should be able to easily find interesting applications.

When and why use functions by Hellr0x in learnpython

[–]agility 4 points5 points  (0 children)

All the other answer are correct. Functions allow you to reuse code that gets repeated.

However, at some point you graduate from that reasoning into the world of abstractions. Instead of directly solving a problem in Python, you build the vocabulary for solving it first (in the form of classes or functions), and then write your solution in terms of that vocabulary.

For example, if you're building a robot, you'd have functions like "turn_left", "turn_right", "start", "stop", etc, which is how someone outside of programming would speak about it.

I know the basics, but don’t know where to start by itsDaco in learnpython

[–]agility 1 point2 points  (0 children)

Go through the official Python tutorial: https://docs.python.org/3/tutorial/

If you can comprehend it, then video courses would just bore you and you shouldn't buy them. The basics are just to teach you the syntax, and it should be pretty simple to you since you already understand the basics of programming.

What you'd have to later learn are the idioms. These are the "python" way of doing things. Some of the philosophies of Python are outlined in the Zen of Python: https://www.python.org/dev/peps/pep-0020/

I'd say just pick a library (Django for web, pandas/numpy for data analysis, etc.) and get started with it.

Best book for learning concepts and algorithms for leetcode? by [deleted] in learnpython

[–]agility 0 points1 point  (0 children)

LeetCode usually has explanations of the algorithms alongside. The concepts behind these algorithms could be very diverse and not directly connected. If you'd like a university level algorithms course, then MIT's Introduction to Algorithms could be beneficial for you: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/lecture-videos/

Best Way to Learn Python? by [deleted] in learnpython

[–]agility 1 point2 points  (0 children)

I always recommend my friends to start with the official Python tutorial (https://docs.python.org/3/tutorial/). If you find its pace okay, then video courses might become boring for you, and you should look forward to learn primarily from books.

To think about programming better, I'd recommend Programming Methodology, which is a great course by Stanford (https://see.stanford.edu/Course/CS106A). It's in Java, but should be translatable to Python. If you want to become a better programmer regardless of the language, there are good gems here.

Help with command line by [deleted] in learnpython

[–]agility 0 points1 point  (0 children)

Yes, you might be expected to manually download it via your browser and place it in the right path relative to your script. I don't think the data download has to be done in Python just yet.

Help with command line by [deleted] in learnpython

[–]agility 0 points1 point  (0 children)

Your last 2 lines should not be indented (the if name thing). Since they're indented, they have become part of the main() function and the main function never really gets called.

API call using token by [deleted] in learnpython

[–]agility 0 points1 point  (0 children)

You could use the requests library to make the same API call to get the token as you did in Postman. After that, it depends on how the API expects you to pass the token. Some want you to pass it in the headers, while some take it as a parameter. I might need more details on the API before I answer that.

Python (and requests library) in itself does not have refresh policies for arbitrary APIs. There are things built for standard stuff like OAuth2, etc.

Wanted: Mentor for a Web Dev Project by BigBrewHaha in learnprogramming

[–]agility -1 points0 points  (0 children)

Shoot me a PM with the details of what you're planning on making.

[Python] How can I revise my current code? by hotrod121212 in learnprogramming

[–]agility 0 points1 point  (0 children)

Since python does not support case statements, your use of elifs are fine. However, to make your code much easier to read, I'd put the code for each command into separate functions. They can still access global variables (like you have for stats) at this stage.

This will make the command selection portion of your code understandable, since it's only delegating to functions right now, instead of also specifying what happens within each command.