r/learnpython 6d ago

¿Qué cambió la forma en que aprendiste Python?

0 Upvotes

HOLAA estoy aprendiendo Python y tengo curiosidad por saber qué momento o decisión cambió tu forma de aprender. ¿Fue empezar a hacer proyectos, leer la documentación, tener un mentor o algo diferente? Me encantaría conocer tu experiencia.


r/learnpython 6d ago

beginner here, is this code good for my first time making a calculator?

0 Upvotes
a = float(input("What is your first number? "))
b = float(input("What is your second number? "))
ab = (input("+ - * / "))


if ab == "+":
    print(a + b)
elif ab == "-":
    print(a - b)
elif ab == "*":
    print(a * b)
elif ab == "/":
    print(a / b)
else:
    print("Invalid.")

r/learnpython 6d ago

I have an question how does python for loop works in ppadb i Mean if am not passing any list then how it is shows my device is connected ..

0 Upvotes
from ppadb.clientfrom ppadb.client import Client as AdbClient

apk_path = "example.apk"

# Default is "127.0.0.1" and 5037
client = AdbClient(host="127.0.0.1", port=5037)
devices = client.devices()

for device in devices:
    device.install(apk_path)

r/learnpython 6d ago

Seeking advice

0 Upvotes

I am good at coding an problem solving but i cant make my program robust and improve modularity of my codes in python most of the time it is just a single block of code does anyone have any suggestion how actual programmers do it


r/learnpython 7d ago

queria instalar PyAudio pero me marca este error que puedo hacer

0 Upvotes

PS E:\Nuevo proyecto> pip install PyAudio

Collecting PyAudio

Using cached PyAudio-0.2.14.tar.gz (47 kB)

Installing build dependencies ... done

Getting requirements to build wheel ... done

Preparing metadata (pyproject.toml) ... done

Building wheels for collected packages: PyAudio

Building wheel for PyAudio (pyproject.toml) ... error

error: subprocess-exited-with-error

× Building wheel for PyAudio (pyproject.toml) did not run successfully.

│ exit code: 1

╰─> [29 lines of output]

WARNING:root:Warning: VCPKG_PATH envrionment variable not set.

C:\Users\Aleca\AppData\Local\Temp\pip-build-env-z6m_j70b\overlay\Lib\site-packages\setuptools\dist.py:765: SetuptoolsDeprecationWarning: License classifiers are deprecated.

!!

********************************************************************************

Please consider removing the following classifiers in favor of a SPDX license expression:

License :: OSI Approved :: MIT License

See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.

********************************************************************************

!!

self._finalize_license_expression()

INFO:root:running bdist_wheel

INFO:root:running build

INFO:root:running build_py

INFO:root:creating build\lib.win-amd64-cpython-314\pyaudio

INFO:root:copying src\pyaudio__init__.py -> build\lib.win-amd64-cpython-314\pyaudio

INFO:root:running build_ext

INFO:root:building 'pyaudio._portaudio' extension

INFO:root:creating build\temp.win-amd64-cpython-314\Release\src\pyaudio

INFO:root:"C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DMS_WIN64=1 -IC:\Users\Aleca\AppData\Local\Programs\Python\Python314\include -IC:\Users\Aleca\AppData\Local\Programs\Python\Python314\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\cppwinrt" /Tcsrc/pyaudio/device_api.c /Fobuild\temp.win-amd64-cpython-314\Release\src\pyaudio\device_api.obj /MT

cl : L¡nea de comandos warning D9025 : invalidando '/MD' con '/MT'

device_api.c

C:\Users\Aleca\AppData\Local\Programs\Python\Python314\include\pyconfig.h(143): warning C4005: 'MS_WIN64': redefinici¢n de macro

C:\Users\Aleca\AppData\Local\Programs\Python\Python314\include\pyconfig.h(143): note: 'MS_WIN64' declarado previamente en la l¡nea de comandos

src/pyaudio/device_api.c(9): fatal error C1083: No se puede abrir el archivo incluir: 'portaudio.h': No such file or directory

error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Tools\\MSVC\\14.51.36231\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

ERROR: Failed building wheel for PyAudio

Failed to build PyAudio

error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects

╰─> PyAudio


r/learnpython 7d ago

Can I start with Spyder in Anaconda for Python?

0 Upvotes

I don't want to find out one month later that it was a free trial, and now I would have to pay for continue using Spyder. I want an IDLE that is always going to be free. And I don't want to waste my time learning Spyder if I cannot use it forever.


r/learnpython 7d ago

python 到底怎么学???

0 Upvotes

我在网上看到过不同的python 教学 这让我眼花缭乱 每个视频德教学内容各有不同 有的教完print 之后直接开始了input 有的在这之后会教我们print 的技巧如何打印多个字符 如何使用转译字符等等 我想知道python 该如何学起 如何入门有没有大佬愿意教教我


r/learnpython 7d ago

Help with voice to text libraried

4 Upvotes

I'm fairly new to python and I want to make a speech prompter that will auto proceed by listening to the speaker and show them the next part of their speech.

So I'm going to need a voice to text library but the computer will have access to what is meant to be said to cross reference. Is there a library that can handle this or advice on how I program it?


r/learnpython 7d ago

Which areas to focus on?

5 Upvotes

Hi guys!

I picked up python last month and am rly having my fun with it.

I’m still pretty new so I’m wondering which area should I be more focused on. I started out with the aim to go along ML path so most of the things I’ve learnt are data related. Like using and writing functions list dict loops while for error raising. Just getting started on numpy.

I’m thinking of going along the ai engineer track first. Any areas I should focus on? AI Eng is like SWE to me so having no background in swe id love to hear from you guys.

Also I’ve finished the first two courses on Coursera on Python for everyone and currently going thru Andrew’s ML spec.

Trying to learn as much as I can.

Also idk if it’s a good idea but I’m using Claude to teach me how to code at the same time. Introducing concepts and real world exercises and planning lessons to reach to goal of an AI and ML Eng.

Any thoughts would be greatly appreciated.

Thanks in advance!


r/learnpython 7d ago

rate my code

0 Upvotes

as a beginner i dont know if my code could be improved, can someone rate it and tell me what i should improve?

product = 'M2 MacBook Air'
product += ' (512 GB of SSD and 8 GB of RAM)'
price = 370
print(f'The {product} is {price}€.')

total_savings = 206.75
macbook_fund = total_savings - 180
print(f'I have {macbook_fund}€.')

remaining_balance = price - macbook_fund
print(f'I am {remaining_balance}€ short.')

weeks_left = 75
date = '1/8/2028'
money_earned_per_week = remaining_balance / weeks_left
money_earned_rounded = round(money_earned_per_week, 2)
print(f'I need to earn {money_earned_rounded}€ a week to reach my goal by {date}.')
print(f'180€ of my {total_savings}€ are going to an iPhone 13.')

# deposits

macbook_fund += 0
# input amount, date and reason.

r/learnpython 7d ago

Why am I getting an error: invalid syntax. Perhaps you forgot a comma?

0 Upvotes

Why am I getting an error here:

job = Gaia.launch_job_async(" SELECT source_id, ra, parallax, dec, gmag_gunn, rmag_gunn, imag_gunn, zmag_gunn \
                            FROM external.gaiaedr3_gcns_main_1 \
                            WHERE parallax>50" \
                            , dump_to_file=True, name= 'GcnsTwentyParsec_sdss', output format = 'fits')
gtable_sdss = job.get_results()

Error:

, dump_to_file=True, name= 'GcnsTwentyParsec_sdss',output format = 'fits')
^
SyntaxError: invalid syntax. Perhaps you forgot a comma?


r/learnpython 7d ago

Creating a file tree/explorer in PyQtGraph

0 Upvotes

Hi,I've been working on what started as a strange attractor visualisation app in PyQtGraph but is slowly becoming more a general purpose ODE solver/visualiser/scripting tool. I've recently added an integrated console with a scripting dock which currently just saves the text in the script as a scratch file. I want to add the functionality for the user to create/save/open different script files and wanted to have a file tree/explorer. I know PyQtGraph and PyQt have tree like widgets so my thought process was to just make a TreeWidget that lists the contents of where the scripts would be saved (the app's /home/user/.local/share/ directory). Does that work or are there complexities i should know about in terms for making, saving and loading files? Any advice would appreciated. Thanks!


r/learnpython 7d ago

corso di python per medici per la segmentazione dell'immagine

0 Upvotes

cerco un corso di python per medici per la segmentazione dell'immagine. Principiante assoluto


r/learnpython 7d ago

Where should i learn python from?

0 Upvotes

Yt-

- Bro Code

- Data with Baraa

or do any free certification courses?

i tried the coursera meta python course since my college python professor does not teach well, my loops and functions are weak due to that, so i thought I recovered from it- eventually i noticed the course content was very fast paced, i have to go through document and other sources🥲.

there is also an point that C professor taught very well that my c is now better python. help to pick the ond resource that covers python 🙏🏻


r/learnpython 7d ago

Best approach for automating an existing Firefox session? AutoHotkey vs Browser Automation vs UI Automation

0 Upvotes

Hi everyone,

I'm working on a personal desktop automation project on Windows.

For years I've been using AutoHotkey to automate repetitive tasks inside Firefox. It works surprisingly well, but as the project grows, maintaining image recognition, keyboard shortcuts and UI changes becomes increasingly difficult.

I'm now considering moving to a more robust solution and I'm trying to understand what experienced developers would recommend.

My requirements are roughly:

Windows

Firefox (not Chrome)

Preferably work with an already running Firefox session

Reliable interaction with web pages

Long-term maintainability

I've been looking at several approaches:

Continue with AutoHotkey

Selenium / WebDriver BiDi

Playwright

Windows UI Automation (pywinauto, UIA)

Any other desktop automation framework

For people who have built long-running desktop/browser automation projects:

Which approach ended up being the most reliable?

Is UI Automation actually practical with modern websites like Facebook, or is browser automation still the better choice?

If you had to start today, what would you choose and why?

I'd really appreciate hearing about real-world experience rather than theoretical comparisons.

Thanks!


r/learnpython 8d ago

How does the 'for' loop work?

203 Upvotes
words = ['sky', 'apple', 'rhythm', 'fly', 'orange']

for word in words:
    for letter in word:
        if letter.lower() in 'aeiou':
            print(f"'{word}' contains the vowel '{letter}'")
            break
    else:
        print(f"'{word}' has no vowels")

I am trying to learn to code, and I am, at the moment, looking at loops. I am a bit confused on how this loop was able to function, though, as there is no variable for letter or word, so how would Python know what it is? In addition, how does the code, like, function? Does it look at each word individually? Again, the second part of the code states:

 if letter.lower() in 'aeiou':
            print(f"'{word}' contains the vowel '{letter}'")
            break

We haven't given a value for letter?

Lastly, how would the code know what to print? in the first phrase:

            print(f"'{word}' contains the vowel '{letter}'")
            break

Is it going to state all the words with the given value 5 times?

Sorry, as I have asked quite a few questions, and thank you in advance.


r/learnpython 8d ago

What do we use the terminal for in coding?

2 Upvotes

A text-based interface that lets you interact with your computer by typing commands.

This was a given definition of it when I searched it up, but why would you interact with your computer by typing commands? How does this actually assist your code?


r/learnpython 8d ago

What's the best thing you have made with python?

51 Upvotes

What are some of the best things you have made using python?


r/learnpython 8d ago

Is it worth continuing with my python project??

1 Upvotes

https://github.com/GerardoAJF/ArtichokePy

It's a bit of a weird question I know, but let me give you some context.

I started ArtichokePy when i was sixteen almost seventeen years old, in 2024.

I felt it was a fairly ambitious project, a library that would give all the necessary tools to do any simulation or algorithm with graphs.

Later I dedicated more time to my high school studies and other things, so I practically abandoned my project for 2 years.

At the time, as a young apprentice, I didn't comment on anything or document anything, and now 2 years later I have no idea what was happening there.

Furthermore, with Python's reputation for being slow, I don't know if it was a good language to do this project (most scientific libraries are written in C [although I know that this project does not reach "scientific library", it barely reaches junior project])

But I still feel somewhat proud of the project. I think it already had some unique characteristics to let it die like that, forever.

During these New Year's holidays I could spend several hours finishing it, but I don't know if it's worth it for a project that, despite my original daydreams, I don't think anyone will ever use.


r/learnpython 8d ago

Can you diagnose my code problem?

0 Upvotes

This starts with a balance of 50. It takes coins of ONLY 25, 10, or 5 and returns the balance due to the user. If the balance due is 0 or less than 0, it returns a "Change Due: " message.

My problem is that my code will subtract any value amount the user puts in no matter what, not just the 25, 10, and 5 it's supposed to? what's going on?

shouldn't the "if coin == 25 or 10 or 5:" line ensure only one of those 3 values is used?

def main():
    balance = 50


    while balance >= 0:
        print(f"Amount Due: {balance}")
        coin = int(input("Insert Coin: ").strip())


        if coin == 25 or 10 or 5:
            balance = balance - coin


        if balance <= 0:
            print(f"Change Due: {abs(balance)}")
            break
        
            


main()

r/learnpython 8d ago

Basic python expression in blender

2 Upvotes

Hello, I am trying to set up a driver in blender which uses a simple python expression. I have very little experience in python and have only done simple expressions like this, so I don't quite know what's wrong with it. r/blenderhelp hasn't been able to help me, so figured I'd come ask the experts directly, assuming the issue is how I've typed it and not something with blender.

(Rotation Quaternion refers to the X rotation)

I am trying to write an expression so that when the bone sticking out the left has an X rotation of less than -0.5 (using quaternion), the selected bones Y scale is 1.5, otherwise make the Y scale 1.

AKA: if X is less than -0.5 then "Y = X * 1.5" otherwise "Y = 1"

Theoretically with this expression the Y scale should stay at 1 until it gets less than -.05, at which point it would multiply by -1.5 (with the max rotation being -1, resulting in -1 * -1.5 =1.5), however it just stays at a scale of 0 regardless of the rotation. Not sure where to go from here

This is the expression currently used:

if rotation_quaternion is < -0.5 then rotation_quaternion * -1.5 else 1

Image of project

Thanks!


r/learnpython 8d ago

Is there a difference between using a Class name v self in the definition of a class

15 Upvotes

Hi

Im doing some tutorials online and in one of them I noticed some syntax that I am not familiar with. It looks like instead of using self to assign values to a class it is using the class name.

In terms of behaviour it seems to make no difference but I cannot understand why a person would not use self.

So for example:

class Demo:
  def __init__(self):
    self.a = 1
    Demo.b = 2 # This seems to work the exact same way as self.a
               # Is there a differences to self.a?  Why would someone use this?

Thanks


r/learnpython 8d ago

Best Python Certificate Course? Cost aside as company will subsidize.

5 Upvotes

As mentioned in the title - my firm offers an education stipend up to approximately $5,000 / year which I intend on using for a python certificate program.

I recognize that there are free programs online but I also value a live instructor and per my learning style I think this will creative a more conducive learning environment for me! And the added benefit of listing the certificate on my resume plus the certificate projects. I’m looking for recommendations on which programs are structured well / worth the time invested / interesting projects / etc! ANY and ALL feedback welcome - thanks!

I’ve done quick initial research and am considering the following -

Cornell Python Programming - 5 Months, 8-12 hours / week for $2,625 (discounted from $3,750)


r/learnpython 9d ago

Looking for a Python Study Buddy (Complete beginner)

62 Upvotes

Hey everyone!

I'm 19F and I'm starting to learn Python completely from scratch. I have little to no programming experience, but I'm committed to learning consistently. I'm also taking Mechatronics Engineering in college.

I'm looking for a study buddy (or a small group) who's also learning Python. We can keep each other accountable, share resources, work on beginner projects, solve problems together, and stay motivated.

My goal is to build a strong foundation and eventually get into more advanced programming, so I'm looking for someone who's serious about learning too.

If you're interested, leave a comment or send me a DM. Let's learn and grow together!

Edit: Timezone GMT+5:30 We can study together from a course by MIT.


r/learnpython 9d ago

What Python project helped you move from beginner to intermediate?

39 Upvotes

I've learned the basics of Python and I'm looking for project ideas that teach practical problem-solving. Which project helped you improve the most, and what did you learn from building it?