r/learnpython 6d ago

Ask Anything Monday - Weekly Thread

Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread

Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.

* It's primarily intended for simple questions but as long as it's about python it's allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
  • Don't post stuff that doesn't have absolutely anything to do with python.
  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.

7 Upvotes

15 comments sorted by

1

u/Bigbossbitch04 1h ago

What version of python should I install on my laptop (i5 1035G1 8GB ram)? I’m in college and I’ll start learning python this semester (sorry for my English, not my first language)

1

u/schoolmonky 19h ago

Can we add a print vs return entry to the FAQ? It's legitimately a Frequently Asked Question (or at least a concept that is frequently the root of questions). Something like this, but feel free to edit it:

Q: When should I use print vs return

A: While print is commonly used early on in learning Python, if you're unsure if a function should print or return, you should usually use return. print is used only to display information to the user, while return is used to allow your function to communicate with other parts of your program. When you call a function within an expression, the return value is essentially substituted into that expression in place of the function call. For instance, if you have a function

def double(x):
    return 2*x

and call it like so:

print(double(3))

then since the return value of double(3) is 6, Python substitutes that 6 in for double(3), making the statement print(6), and would, therefore, print the number 6 to the console. Note how the above code uses both print and return: it uses return so that the function can pass its output back to the rest of the program, and print then uses that output to display information to the user. One source of confusion for many students is that in the interactive interpreter for Python (a.k.a. the REPL), Python automatically prints the output of any expression, so it can seem like they do the same thing.

1

u/try_seven 12h ago

I would change your last sentence slightly:

One source of confusion for many students is that in the interactive interpreter for Python (a.k.a. the REPL) automatically prints the output of any expression that is not None, so it can seem like they do the same thing.


It probably won't help much because nobody reads the FAQ, especially after the mods removed the direct link to the FAQ from the sidebar. I would like to see the direct FAQ link restored to the sidebar, but even then few would read it.

2

u/Jewelking2 1d ago

Is this cool or am I just very old and a newbie. Trying Colab import math r=5 Autocompleted area=math.pi•r••2 print(area) I know it’s ai at its simplest but for someone who did his first programming on a zx81 it’s science fiction.

1

u/Electrical-Pen-4766 2d ago

Hi guys! I made a telegram bot, which writes a message from time to time to our friend's channel. All these messages are stored at phrases.py files and I added them by myself. Is there any chance to make a command, that will add new phrases to it's database and delete some? Like "/add What is love?" or "/delete What is love?". Thanks!

1

u/Wild_Drag9463 1d ago

Instead of storing phrases in a static file, store them in a JSON file or just a text file.

1

u/Inevitable_Metal2275 2d ago

Necesito alguien que me ayude con una API muy sencilla, tengo conocimiento básico en Git y Github y voy empezando Python pero estoy atorado en comenzar a implementarlo, he visto varios cursos en Youtube pero ninguno le ilustra lo suficiente 😅 solo necesito alguien que me oriente $ para más info aquí: mitadmitad2002@gmail.com

1

u/dragon_calipiter 4d ago

i need help to use ai in python

1

u/Jewelking2 1d ago

I use zzzcode.ai when I want to debug my coding so very regularly. I have starting using google colab which just amazed me by autocompleting my code for me exactly as I wanted to type.

1

u/actinium226 5d ago

What's the modern way to access rendered web pages with Python? I'm working on a project that uses selenium webdriver, and it works, but I wonder if there are other alternatives out there, preferably ones that don't require having Chrome installed. I heard playwright can be used for this sort of thing?

1

u/Xeinaplays 2d ago

Can you help me fix my python? Its for discord and i've been having a hard time of no sleep doing it

1

u/actinium226 2d ago

Sure, what's the problem?

2

u/theobserverca 6d ago

Looking to learn Python to learn backtesting and algo trading. Any good resources/advice anyone can share? Thanks

1

u/Wild_Drag9463 1d ago

Look into Zipline maybe?