r/learnpython

Looking for people to learn Python with

Hi I’m a beginner at Python and I’m currently looking for a few people to learn with. I am planning to start the sessions in September and run a couple hours a day subject to flexibility and rather than get stuck in “tutorial hell” I actually want to build projects. My time is GMT+0 so drop me a message if you’re interested.

reddit.com
u/ragazzoitalian0 — 1 day ago

Game automation

I'm new to programming. I specifically want to build projects around game automation with Python. What should my roadmap look like?

Thanks in advance!

reddit.com
u/S1mit — 1 day ago

Making a wordle program

Hi! I'm new to programming and, as a way to practice, I thought I would make a wordle program, the only issue is that it keeps marking letters as not in the wordle when they are; any help would be appreciated, I've included the problem section, as well as the whole code in case the problem is elsewhere. Thank you!

--------------------------------------------------------------------------------------------------------------

for x in range(5):

if guess[x] == answer[x]:

response[x] = "G"

guess[x] = ""

answer[x] = ""

print(response)

print(answer)

print(guess)

for x in range(5):

if guess[x] != "":

if guess[x] not in answer:

response[x] = "R"

guess[x] = ""

answer[x] = ""

print(response)

print(answer)

print(guess)

for x in range(5):

if guess[x] != "":

response[x] = "O"

answer[x] = ""

guess[x] = ""

print(response)

print(answer)

print(guess)

print("".join(response))

answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]

i+=1

--------------------------------------------------------------------------------------------------------------

from word import words

import random

key = random.randint(0, 5783)

answer_word = words[key]

answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]

i=1

while 1 == 1:

while i < 7:

print(answer_word)

guess_input = input().lower()

guess = [guess_input[0], guess_input[1], guess_input[2], guess_input[3], guess_input[4]]

response = [".", ".", ".", ".", "."]

used = []

if guess_input in words:

if guess_input == answer_word:

print("CORRECT")

i=7

else:

for x in range(5):

if guess[x] == answer[x]:

response[x] = "G"

guess[x] = ""

answer[x] = ""

print(response)

print(answer)

print(guess)

for x in range(5):

if guess[x] != "":

if guess[x] not in answer:

response[x] = "R"

guess[x] = ""

answer[x] = ""

print(response)

print(answer)

print(guess)

for x in range(5):

if guess[x] != "":

response[x] = "O"

answer[x] = ""

guess[x] = ""

print(response)

print(answer)

print(guess)

print("".join(response))

answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]

i+=1

else:

print("invalid input")

if i == 7:

print("Correct answer: " + answer_word)

again = input("Would you like to play again? Y/N ").lower

if again == "y":

i=1

key = random.randint(0, 5783)

answer_word = words[key]

answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]

else:

break

reddit.com
u/ZeddiiJay — 1 day ago
▲ 9 r/learnpython+2 crossposts

Is there a "TypeScript for Python"? What you do for type checking!?

Conclusion: Thanks for the comments, everyone has been so helpful and generous with the suggestions. I realized that I did not asked my question properly and my main problem went unseen... (Well I'm at fault by opening the conversation by Is there a "TypeScript for Python"?).
I will create a new post with the right problem statement, but let me thank u/ProsodySpeaks, and u/JamzTyson which gave me idea on what to do next.

Cheers!

Hi, sorry for the basic question. I'm coming from strongly/statically typed languages (Kotlin, Go, Rust, etc.), and I was aware that Python is dynamically typed, but given how popular Python is, I expected its typing utilities (type hints + static type checkers) to provide something closer to TypeScript.

I'm working on an ml framework where the main interface has to be Python, and I ran into a magnitude of problem I was not expecting...

Requirements:

  • Type checking before a pipeline runs (no values exists yet, just type hints/annotations)
  • Type checking during the pipeline run (value and type hints/annotation should match)
  • The type hints are used to decide if pipeline components are compatible (similar to LangChain or similar frameworks)
  • Require as little setup as possible, so even junior engineers can use the framework safely.

I spent some time trying to implement this using Python's existing typing mechanisms. A few thousand lines of code later, I ended up with a type checker for my specific pipeline system:

https://github.com/trained-by-humans/ml-pipes/blob/main/packages/core/src/ml_pipes/validation.py

And my own type checking utilities:

https://github.com/trained-by-humans/ml-pipes/blob/main/packages/core/src/ml_pipes/_typing/annotation.py

But now I'm wondering:

Am I going way too far here? Is there a much more idiomatic Python approach that I'm completely missing?

And just to be clear: this is only the pre-run check so far. Runtime type checking doesn't exist yet.

Update1: Thanks for highlighting Pydantic, I've considered to use it for runtime since it covers enforcing type hint/annotation on values.

Update2: The TS or other "typing languages", would essentially help with highlighting the compatibility, they answers questions like is input of type A is assignable to parameter of type B, which is very very important for pipeline validation before running the pipeline.

Update3: The type of type checking I need is this, imagine a pipeline like this:

Pipeline([
    Resize((640, 640)),
    Store("resize_transform", source=1),
    Pick(0),
    Normalize(),
    Infer(model_path),
    Extract("output0", as_="preds"),
    Squeeze("preds"),
    Transpose("preds"),
    Slice("preds", slice(None, 4), as_="boxes"),
    Slice("preds", slice(4, None), as_="scores"),
    ArgMax("scores", as_="classes"),
    GatherRows("scores", "classes"),
    ConvertBoxFormat(from_="cxcywh"),
    NMS(conf_threshold=conf_threshold),
    Recall("resize_transform"),
    ProjectBoxes(),
    ToDetections(),
])

I need to make sure the upstream operator output is compatible with downstream input. You can find out more about it in the page (Validation.md under the operator compatibility section)

Please save me from implementing another few thousand lines of code. 😭

u/tenkei_01 — 1 day ago

I’ve completed these beginner Python projects should I build more before starting NumPy/Pandas?

Hi everyone,

I’ve studied Python multiple times before, but I didn’t do much practical coding. Recently, I started building small projects to improve my practical Python skills.

So far, I’ve completed:

- Quiz Game

- Number Guessing Game

- Rock Paper Scissors

- Password Manager

- Pig Game

- Mad Libs Generator

My goal is to move towards Machine Learning.

I haven’t learned NumPy or Pandas yet.

My question is: Are these projects enough to move on to NumPy and Pandas, or should I build a few more Python projects first?

If I should build more projects, what kind of projects would you recommend before starting NumPy/Pandas? I’m mainly looking for projects that would actually help with the transition to data/ML, rather than making many more small games.

Would appreciate advice from people who have already followed a Python → NumPy/Pandas → ML path.

reddit.com
u/purvigupta03 — 1 day ago

Free website to learn

I got some programing experience. but not with python, with C#
and i want to learn python, whats a free site / app i can learn from?

reddit.com
u/Yuvalda45 — 1 day ago

Type Error: 'bool' object is not iterable - what is this error and how can I solve it?

I have some code with a function restock_warehouse, that adds to the current stock 5 times while the current stock is smaller than the target stock. My question is, how can I fix the function so that the code works properly with and the print() call is displayed in the terminal?

The error message I have been receiving is:

```

Traceback (most recent call last):

File "file_name", line 15, in <module>

final_stock = restock_warehouse(10, 25)

File "file_name", line 5, in restock_warehouse

for i in range(5) and current_stock < target_stock:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TypeError: 'bool' object is not iterable

```

I have already tried wrapping the conditional part of the loop in parentheses, but it hasn't worked and I don't exactly understand the error message.

Version information: I'm on Python 3.9.6

def restock_warehouse(current_stock, target_stock):
    print("Starting warehouse restock system...")


    # We want to keep adding items until we reach our target stock
    for i in range(5) and current_stock &lt; target_stock:
        print(f"Current inventory level: {current_stock}")


        current_stock == current_stock + 5


    print("Warehouse restock complete!")
    return current_stock



# Start with 10 items, target goal is 25 items
final_stock = restock_warehouse(10, 25)
print(f"Final stock total: {final_stock}")
reddit.com
u/Dense_Quarter_5374 — 1 day ago

¿Cuál fue la parte más difícil de aprender Python que no esperabas?

HOLAA Estoy aprendiendo Python y tengo curiosidad por conocer las dificultades que las personas no esperaban cuando empezaron. Me encantaría conocer tu experiencia

reddit.com
u/intentado_aprender — 1 day ago

Should i go for web dev or data analyst or ui/ux designer course without cs desgree(i have bsc biology)?

I want to do online course which one should i choose web dev or data analyst or ui/ux design Also i only have bsc biology degree. Want to do work from home job/online job. Kindly give ur suggestion

reddit.com
u/Worldly-Fun-4281 — 1 day ago

Why? return statement didn't gave me of all output of arg ..

In this code, I want to get the output of all the numbers in the for loop. I can do this using print(arg), but when I use a return statement, I only get the output of a single number. How can I modify the code so that return gives me all the numbers from the for loop?

print(func1(80, 30, 40)) def func1(*args):
  for arg in args:    
    # print(arg, end=" ") 
    return arg

# output using print = 80 30 40 None
# output using return = 80        

print(func1(80, 30, 40))
reddit.com
▲ 266 r/learnpython+36 crossposts

Mid level Data scientist MAANG

i want to prepare for sr data scientist in MAANG companies. My background is in  core ML, deeplearning, nlp etc. 

I plan to target in around a year from now.

Does someone have any idea about the interview preparation or someone in these companies who would like to share some experience?

Interviewprep resource:

PracHub: Company specific interview questions

DataLemur: SQL Interview and Data Science Interview questions

StrataScratch: SQL and Python interview

u/FlatwormAdmirable610 — 2 days ago

¿Qué te enseñó aprender Python que no tuviera nada que ver con programar?

HOLAA Estoy aprendiendo Python y tengo curiosidad por saber qué aprendieron las personas durante el proceso aparte de programación. Me encantaría conocer tu experiencia.

reddit.com
u/intentado_aprender — 1 day ago

Best Python books from beginner to advanced?

I’m learning Python and looking for a good book path from beginner to advanced.

I want books that teach Python properly, including clean code, real projects, testing, project structure, and advanced concepts.

What books would you recommend, and in what order?

reddit.com
u/harunnoir — 2 days ago

What is the most effective way to learn python from scratch, i am a beginner, should i take a course?

Hi, i need your advice on how i can learn python as a beginner as i want to learn in a way where i get to practically apply the same and practice, i just dont want to learn concepts theoretically. Should I take a course or should i learn via youtube. What do you think will be the best way? Also when you learnt it how did you approach it and if i take a course how i will it add value to my cv?

reddit.com
u/Wonderful_Yam_4725 — 1 day ago

How to upload multiple image in FastAPI swagger UI?

I'm using this as my function annotation

@router.post("/")
async def create_story(images: list[UploadFile]): ...

but the swagger UI show a list of string not images with no choose file button

It works fine when I switch the list[UploadFile] to UploadFile and shows the Choose file button

reddit.com
u/bahmed5 — 1 day ago
▲ 1 r/learnpython+1 crossposts

CUAL ES LA MEJOR GUIA PARA APRENDER UN LENGUAJE DE PROGRAMACION?

como principiante tengo esa duda ya que quisueira no perderme de nada y aprender de la mejor a programar

reddit.com
u/Resident_Habit_749 — 2 days ago

How do I learn programming logic?

I’m learning Python, but my main problem isn’t the syntax. I understand concepts when someone explains them, but when I’m given a basic problem and told to write a program, I just don’t know where to start or how to arrange the code.

Is there a good book, course, or YouTube channel that teaches how to think through programming problems step by step, recognize patterns, and build the logic, kind of like how you learn methods and patterns in math?

I don’t want to just memorize Python syntax. I want to actually learn how to think like a programmer.

reddit.com
u/RipPersonal1643 — 3 days ago