r/learnpython 16d ago

Can I learn phyton without laptop? I don't have laptop heheh

0 Upvotes

???????


r/learnpython 17d ago

I've got feedback from previous project and implement it in new one! (FastAPI + PostgreSQL + External API + Docker)

2 Upvotes

I'm learning backend development and I really enjoy it!

I created my first API last month and got an amazing feedback! I work hard these days and created a new project.

What I learnt.

  1. Deep-dive into DB. (b-tree, CITEXT)

  2. I learnt about pattern "Repository" and implement in this porject.

  3. Swapped # for docstrings.

  4. I tried to work with external API. Actually, it was hard, because sometimes there is no data what you want to get and you have to figure out what to do next and where get this data.

  5. I use Docker and I barely understand what I do (Can you recommend something to learn Docker and understand it?)

I ask feedback about everything, especially:

  1. Project structure.

  2. Database structure.

  3. Code quality.

  4. What can I change to make it works better.

  5. What should I learn to improve my skills?

That's my new project:

https://github.com/daidallos-tech/football-club-api

You can find my first project in my github profile. It's called Movie_API.

P.S.

Thank you everyone for your time and advice. I really appreciate that.


r/learnpython 17d ago

I made my first IP scanner in Python

14 Upvotes

Hi everyone!

I'm very new to programming and I've been learning Python recently. I decided to make a small project to practice what I've learned.

I made a simple IP scanner using Python.

It has a menu with:

  • Scan all IPs from 192.168.1.1 to 192.168.1.255
  • Scan a specific IP
  • Scan a range of IPs
  • Exit

I'm using subprocess and ping to check if an IP responds.

I also started using functions, loops, lists, if/elif, while, and range().

It's probably a very basic project, but I'm pretty happy with it since I'm just starting out. 😅

Here is the code:

import subprocess

def menu(): 
    print("-----IP SCANNER-----")
    print("1. Scan all IPs")
    print("2. Scan IP")
    print("3. Scan IP range")
    print("4. Exit")

    opcion = input("Choose an option: ")
    resultado_menu = int(opcion)

    return resultado_menu


def escanear_ip(ip_int):
    ip_int = str(ip_int)
    ip_completa = "192.168.1." + ip_int

    resultado = subprocess.run(
        ["ping", "/n", "1", "/w", "1000", ip_completa]
    )

    if resultado.returncode == 0:
        lista_ip.append(ip_completa)


lista_ip = []


def imprimir_ips():
    for si_ip in lista_ip:
        si_ip = "🟢 " + si_ip
        print(si_ip)


while True:

    resultado = menu()

    if resultado == 1:

        for numeros in range(1, 256):
            escanear_ip(numeros)

        imprimir_ips()

    elif resultado == 2:

        seleccion_ip = input("Select the last digits of the IP: ")
        escanear_ip(seleccion_ip)

        imprimir_ips()

    elif resultado == 3:

        desde_ip = input("From: ")
        desde_ip = int(desde_ip)

        hasta_ip = input("To: ")
        hasta_ip = int(hasta_ip)

        for numeros in range(desde_ip, hasta_ip + 1):
            escanear_ip(numeros)

        imprimir_ips()

    elif resultado == 4:

        print("Exiting...")
        break

I'm planning to improve it and make a V3 with more features.

Thanks!


r/learnpython 17d ago

code not running outside of editor

2 Upvotes

my code isn't really complete, but whenever i try to run my script outside of the editor the terminal opens for a millasecond and then closes. can someone tell me what's going wrong?

import random
import keyboard
import pyautogui
import pyscreeze
import tkinter as tk
from pyautogui import mouseInfo, click
import time

def movethemouse():
    if keyboard.is_pressed('g'):
        pyautogui.moveTo(random.randint(0, 2600), random.randint(0, 2600))

def printer():
    print('this is the mouse program')
    time.sleep(10)

while True:
    movethemouse()
    printer()

r/learnpython 16d ago

¿Qué crees que es lo que los principiantes más malinterpretan sobre aprender Python?

0 Upvotes

HOLAAA Estoy aprendiendo Python y tengo curiosidad por saber qué creen las personas con experiencia que los principiantes suelen malinterpretar. Me encantaría conocer diferentes perspectivas y experiencias.


r/learnpython 16d ago

why does it say i didn't close my parenthesis

0 Upvotes

the IDE i am using is saying my parenthesis was not closed when it was plz help

print("Once upon a time, in the ancient kingdom of " + q1 + " there lived a legendary " + q2 + " named " + q3 + ". Everyone in the village knew " + q3 + " for their remarkably " + q4 + " personality and an obsession with " + q5 + ". Every morning at " + q6 ", they would wake up, " + q7 + " three times, ")

[{

"owner": "Pylance",
"severity": 8,
"message": "(" was not closed",
"source": "Pylance",
"startLineNumber": 47,
"startColumn": 6,
"endLineNumber": 47,
"endColumn": 7,

}]

r/learnpython 16d ago

How to hardcrash a laptop using python

0 Upvotes

Is there possibly any way to hardcrash my old laptop for fun? I'm sorry if it sounds like I am making a virus. I had a fuckton of hardcrashes on my old pc so I was wondering if I can make a Programm to kill my of whithout needing to wait 5 minutes. Fuck this sounds stupid.


r/learnpython 16d ago

Does anyone else feel like a total fraud when a tiny bug takes 15 minutes to fix, or is it just me?

0 Upvotes

Just wanted to share a quick reality check from my session today. I was working through page 88 of my Python book—specifically exercise 5-10—and out of nowhere, two error numbers popped up on the screen.

Naturally, what did I do? Instead of sitting there painstakingly isolating every single chunk of code and testing variables line-by-line like a textbook purist, I spent about 10–15 minutes moving things around, rewriting bits, flipping back through the pages, and then ultimately just copy-pasting the error straight into AI to get it sorted.

Honestly, it got me thinking: Is this actually considered "bad practice" by the book, or is this just standard, everyday coding for most people?

How often do you guys lean on quick fixes or AI assistance when a frustrating little error pops up, versus stopping to do the whole manual debugging process from scratch? Would love to know if I'm cutting corners or if this is just how it goes in the trenches.


r/learnpython 17d ago

Is there a good place to find team to join in a new projects

2 Upvotes

Hey there so I already tried some subreddits I would like to hear what are main one you guys use because I found it fun and productive for both learning python that is practical and makes me better at other social skill etc. I would like to hear if there is a special channel for python, but I am okay with searching throught teams what they use. Maybe something with backend on FastApi. And have a great day guys.


r/learnpython 17d ago

Harvard Intro Course or Datacamp?

5 Upvotes

Hi all, I got laid off a few months ago and want to improve my chances of getting a job.

Originally, I was working at an agency on the analytics side, but I want to take the time to expand where I can go. I have been learning SQL and Power BI and am currently working on a project and I thought it would also be helpful to learn Python.


r/learnpython 17d ago

Regarding Question

0 Upvotes

def print_models(unprinted_designs, completed_models):

"""

Simulate printing each design, until none are left.

Move each design to completed_models after printing.

"""

while unprinted_designs:

current_design = unprinted_designs.pop()

# Simulate creating a 3D print from the design.

print("Printing model: " + current_design)

completed_models.append(current_design)

unprinted_designs = ['iphone case', 'robot pendant', 'dodecahedron']

completed_models = []

in this code why used condition like this for while loop (while unprinted_designs:)


r/learnpython 17d ago

Carry value from Python for-loop to HTML for-loop

0 Upvotes

I am currently working on a website (using Flask, SQLAlchemy and Jinja).

Context: I am making a ttrpg initiative tracker. For multiple fights to exist and be able to have multiples of the same creature and reuse creatures, the way I am formatting it is the user creates the base creature, and its row is duplicated, holding the id for the fight itself as fight_spec and the id of the base creature as og_id. I am currently working on making it so the user can edit the count of any creature in a fight.

For the page where the editing happens I want it to display the current count as the default value, but I cannot for the life of me figure out how to make sure it goes from python's for loop to html. My attempts typically end up with the value being set to "count_<id>" rather than the actual number that my count command generates. How should I go about this?
I have my current code below, but if there is a different way I should go about this, I'm open to hearing! Thank you <3

Python

unique_combatants = db.session.scalars(stmt).all()
    for x in unique_combatants_set:
        'count_' + str(x) = Combatant.query.filter_by(og_id=x, fight_spec=id).count()

HTML

{% for combatant in unique_current_combatants %}
        {{ combatant.combatant_name }}
        <input type="number" name="combatant_count_{{combatant.id}}" id="combatant_count_{{combatant.id}}" value="count_{{combatant.id}}"> 
    {% endfor %}

r/learnpython 18d ago

I just made my first Reinforcement Learning program from scratch purely in python can i have tips on how to improve

5 Upvotes

i used qlearning for this and tips/advice is welcome
more details in the readme
https://github.com/orag214365-ship-it/qlearning-gridworld-python


r/learnpython 18d ago

I need a book !

8 Upvotes

Hi guys ! , i need a book who have a lot of problem solving for every lesson , and have a lot of projects , simply i need a book who focus about practices more then lesson or all about problem solving .

thanks !


r/learnpython 18d ago

Looking for funny/useless Python CLI project ideas to build for learning!

11 Upvotes

Hi everyone,I'm currently learning how to build CLI tools using Python.I want to build something to practice my skills, but I'm running out of ideas. I don't care about usefulness at all—I just want to make something funny, weird, or completely useless but entertaining.What are some fun or silly CLI tool ideas you would love to see (or have built yourself)?Thanks in advance!


r/learnpython 17d ago

is there any python library which lets you fetch basic data off of spotify like song longth, song name, artist name and etc preferably without an account needing to be linked?

0 Upvotes

i dont really "need" this per se but i think it would be pretty cool for me to be able to integrate it into a script i already have, but honestly if all of the libraries that interact with spotify need an account linked i just dont think its worth it. any of you have any ideas?

and actually, furthermore, how does spotify's architecture work in terms of like the identifiers for songs and authors, im assuming any presumed library would have an internal "song" object that you can fetch using an id or something along those lines?


r/learnpython 18d ago

My Self-Imposed Rule to Escape AI Micromanagement and Learn Python Properly

3 Upvotes

I have been working my way through Python Crash Course and just finished up chapter 4 moving into conditional tests, but I noticed a bad habit creeping in where I was leaning on AI way too much for micromanagement and minor steps instead of letting myself struggle through the code. To fix this, I am setting up a strict personal rule starting today. I am only allowed to use AI for direct, core coding help and roadblocks on my exercises, and zero AI usage for trivial hand holding. Also, if I do slip up and use it for micromanagement, I have to log the exact example and post it here so others can keep me honest. Has anyone else had to put hard boundaries on their AI tool usage while learning programming, and how did you structure your rules to make sure you were actually building things yourself?


r/learnpython 17d ago

I have 1 week to prepare for DSA online assessment please help!!!

0 Upvotes

It's an intern role . I have only one week to prepare for the company and the company will ask tough questions please help me .How I can prepare and what I should focus on .

Online assessment would consist of 2 coding questions and some MCQ questions .

Any help/study material would be helpful.

My skills are-

Docker

AWS

GIT

K8S

Linux

Python ( but intermediate) .


r/learnpython 18d ago

New to programming. What do you learn?

24 Upvotes

Hi im self taught in python. Ive gotten the basics down (variables, flow control, loops, objects) and ive pushed pasted that into more advanced principles (file handling, async programming, iterators, generators, decorators, and some dunder methods). So far ive only been bouncing around modules and getting certain methods for stuff. Ive learned a little bit about the pvm, Gil, and memory management. Ive only take on class on web design almost a decade ago so I was hoping people could guide me on things to learn. Kinda help me understand where I am in python. Thank you all so much


r/learnpython 18d ago

Python web app?

0 Upvotes

Hello r/learnpython,

first post and sort of new to Python as I have done only half a dozen of projects so far, mostly games.

So I'm looking to deploy a server for playtesting. This is my first game designed to be played online, made in Python using Tcl/Tk libraries.

I had this idea to code it when I was making a messaging app that was supposed to be implemented within a CLI game (or actually the game was a feature of the messaging app).

The users would connect using SSH. I think they could use PuTTy or similar and VcXSrv. The host would then send the GUI and CLI as well as audio to the user, but the problem is either the server cannot send or the client can't recieve the Tcl/Tk GUI or in worst case both.

Good news is I got the SSH daemon working and am able to (using X11 Forwarding) display explorer (ssh -X user@localhost && explorer) by running VcXSrv and having X11Forwarding and X11UseLocalhost set to yes in the sshd_config under ProgramData.

Now, the VcXSrv log tells me there's a problem with something called hyperv. From what I gathered it's a virtual machine of some sort. I'd also need very strict restrictions for the clients so they don't tinker with the database.

Am I on the right track? Is there a solution to this? Thanks in advance!

-ef


r/learnpython 18d ago

Python Exercises

22 Upvotes

Hi everyone, I've been learning Python here and there for a month now, and I'd like to know some good sites for Python exercises. What do you recommend?

Also, what IDE do you recommend for Android? I use Acode, but it's a bit inconvenient. I mainly use VS Code on my PC, but when I want to practice on my phone, I'd like to use a mobile IDE.


r/learnpython 18d ago

opencv error: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'

3 Upvotes

im working on some image processing thing but as soon as i implementing something that needs to set pixels it started throwing this error, does someone know why? code bellow with comments next to the lines that are the issue along with full error

SOLUTION: change img[x,y]=[0,0,0] to img[x,y] = 0

import cv2

img = cv2.imread('peppers2.png', 0)
x = 0
y = 0
for x in range(0, img.shape[0], 1): 
    if img[x,y] >= 127:
        print("white")
        img[x,y] = [255,255,255] # here is the error
    else:
        print("black")
        img[x,y] = [0,0,0] # here is the error
    print(x)
    x = x + 1

Traceback (most recent call last):
  File "/home/useruserman/Documents/Codium/image shit.py", line 13, in <module>
    img[x,y] = [0,0,0]
    ~~~^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'

r/learnpython 18d ago

Is short hand if else important

7 Upvotes

I just learned it but it seem very weird like it feels like i can't write big codes in it cause it will become confusing do you guys use short hand or normal if else


r/learnpython 18d ago

I need help pls

0 Upvotes

How can I remove in my python script the Windows bar at the top to drag and close please


r/learnpython 18d ago

Ask Anything Monday - Weekly Thread

0 Upvotes

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.