r/learnpython • u/Ok-Direction-5650 • 2m ago
Inciante em python
Alguma dica pra aprender turtle? Sabe aqueles desenhos que fazem em python, realmente fazem do zero ou usam algum programa?
r/learnpython • u/Ok-Direction-5650 • 2m ago
Alguma dica pra aprender turtle? Sabe aqueles desenhos que fazem em python, realmente fazem do zero ou usam algum programa?
r/learnpython • u/rushaydotexe • 2h ago
I know a bit python but not tooo much. If I were to start python from scratch , where would I do that? Also , I need python for data sci and I want to learn a bit about web dev too so what all do I need to learn realistically.
Lastly , where do I get practice questions and projects to build that I can put directly in my portfolio??
r/learnpython • u/Joltik2007 • 5h ago
The subreddit doesn't let me attach an image so this is a vague rendition of what it looks like.
|
|---- -√2 β
|
|
|--↑-- 0 β
|
|-↑--↓- √2 β
My current idea is using horizontal bar charts with matplotlib.pyplot, but it doesn't have an x-axis and I'm struggling to create the y axis.
r/learnpython • u/Klutzy_Solid5200 • 8h ago
Like for example, you are working on a project where everything is running fine, but then you install a new package for a specific task, but it changes the version of an existing package like numpy or pandas, and suddenly, parts of your old code start throwing errors.
How do you usually fix these issues? Do you use virtual environments or follow any other approach to avoid package conflicts?
Would like to understand what's the common approach for this.
r/learnpython • u/Guilty-Question-6557 • 14h ago
Hi everyone,
I've been learning Python for about 5 months. I know basics like data types, lists and classes, but I still can't solve problems on HackerRank. When I get a problem, my mind often goes blank. Sometimes I also struggle to understand the statement in English.
I spent the last 3 years consuming a lot of mindless social media content. Now I find it hard to focus and stay disciplined, and reading documentation or books feels difficult.
I'd like advice on:
If you've been through something similar, what actually worked for you?
Honest feedback is welcome. Thanks!
r/learnpython • u/CandleShot7639 • 14h ago
I’m f(17) and I’ve tried to get into python numerous times but this time I want to actually be dedicated to it and eventually build my way up to harder languages.
Anyways please let me know some good YouTubers/sites to learn from as well as projects I could try out! I’m also hoping to make a few friends (close to my age) also learning python to make it more enjoyable.
I’m also open to any other information you think might help me out c:
r/learnpython • u/Terrible-Disaster774 • 16h ago
I hope this is perfect sub to post.
I need to build network performance monitoring and anomaly detection tool. I need to make something built with an admin dashboard and easy to set up , register a device and monitor easy to run on low resources.
the biggest challange is how to monitor and detect a registred device by an IP address(my be dynamic) is there any way?
which protocols i have to explore for detection and reporting ?
I'm a little bit familiar with python programming .
any advise or suggestion regarding workflow or implementation will be appreciated?
r/learnpython • u/Raging_demon3832 • 17h ago
So I am first year student in first sem currently knows the basics of normal python and hav good experience on nested loops never created projects and my clg is teaching me basics of numpy i wanna get into ml in future i wanna master numpy pandas and other libraries so can yall suggest me best resource to actually do this ?
r/learnpython • u/blackgarliccookie • 19h ago
I'm back again, hopefully with clearer information.
I have 19 boolean variables. Each one is labeled with the date of an election. Inside the variable has true/false. True is voted, False is didn't vote.
I want to create a voting history variable that has a few options.
Never voted, if all 19 are false.
Voted in the past 5 years, if any of the date variables in the past 5 years, aside from the recent midterm, have a vote.
Voted in the past 10 years, if no votes were cast in the past 5 but there were votes in the past 10.
And recently registered, which would involve the registration_dt variable which I feel more confident being able to implement.
I just really don't know how to turn these into one variable without losing information. Thanks so much :)
r/learnpython • u/South-Put-7948 • 1d ago
Guys, I am beginner. I have the python code and have saved in file. Now I want to place the file path in the terminal and run that code. I don't know what should I write before adding the file path? Please help!
r/learnpython • u/timepassr • 1d ago
so a little of context i have computer science as a subject in grade 12 , and in it i have to study python , sql , stack and python connectivity with sql . i have managed to study sql but im struggling with python all i know is print("hello world") , i dont know if this is the right place to post this but help will be really appreciated . also i cant give it much time sadly coz i have subjects like physics chem and maths hanging in my neck . max i can give is 45 mins a day and i have to do it in under a month .
these are all the topics i need to learn
if, elif, else) and loops (for, while, break, continue).math, random, and statistics.def).return statement) vs. void functions.global keyword.ZeroDivisionError, TypeError, ValueError, IndexError, KeyError, FileNotFoundError, IOError, etc.try, except, else, and finally clauses, along with raise and assert statements..txt), binary files (.dat), and CSV files (.csv).open(), close(), with statement, and file access modes (r, r+, w, w+, a, a+, rb, wb, ab, etc.).read(), readline(), readlines()), writing (write(), writelines()), and file pointer manipulation (seek(), tell()).pickle module (pickle.dump() and pickle.load()).csv module (csv.reader(), csv.writer(), writerow(), writerows()).push via append(), pop via pop(), peek/display, and underflow/overflow checks).mysql.connector.connect(), cursor(), execute(), parameterized queries (%s or .format()), commit(), fetchone(), fetchmany(), fetchall(), and rowcount.THANKS A LOT FOR READING
r/learnpython • u/No_Art7806 • 1d ago
I'm a social scientist who has primarily used R for my research, but would like to learn Python so that I can more effectively use LLMs. I completed the Python Programming MOOC, so I'm familiar with basic syntax, classes, etc. I then used Claude to create a textbook with exercises to cover topics such as making API calls, validation, tools, connectors, RAG, automation, eval testing, etc.
The problem I'm facing is that the code in each exercise goes well beyond what I learned in the MOOC, so I'm getting overwhelmed and feel stuck in the weeds. For instance, there are many packages being used that I've never encountered (pydantic, pytest, os, sys, threading, argparse, hashlib, pipeline, __future__) and concepts I haven't encountered (e.g., dataclasses).
- How important is it for me to understand these concepts if I want to use LLMs for scraping, classification, running OCR on large datasets? How much would I be missing if I used codex or Claude Code to simply code the files?
- How would you recommend proceeding? On one hand, I don't want to spend excessive time on more Python tutorials at the expense of doing research, but on the other, I don't want to be missing fundamentals.
- Are there any packages/concepts you would emphasize learning beyond learning basic Python syntax?
- Could you provide resources that provide a more gentle overview of how to use Python for the purpose of using LLMs?
Thanks!
r/learnpython • u/moomo7482819 • 1d ago
Hey all
I have an exam next week in my introductory python course. I have been doing the work, so I am not necessarily scared that I will fail, but I am terrified of making a dumb mistake because I forget basic syntax due to exam anxiety.
Mistakes such as suddenly forgetting how to remove an item from a list, despite having done it hundreds of times.
I have been writing notes myself on all the syntax I have used throughout the course, but I am scared I have missed something crucial.
Is the official python documentation best? I feel it’s a bit complex for an introductory course no?
Thank you in advance, I appreciate any feedback
r/learnpython • u/WitnessSpecialist899 • 1d ago
Hey everyone,
I'm at a point in my Python journey where I'd probably call myself "basic-intermediate," and honestly, I'm having a hard time telling if I'm actually learning or just spinning my wheels.
Whenever I look at my code, it just feels "young." It gets the job done, sure, but it looks very simple and basic compared to what I see other people writing. It makes me doubt whether I'm truly growing as a programmer or if I'm missing something big.
I'm also trying to find new coding friends or a small group around my level so I don't feel like I'm learning in a vacuum.
For those of you who have been through this stage:
Would really appreciate any advice or perspective. Thanks!
r/learnpython • u/False_Technician3903 • 1d ago
Hey everyone, I’m a high school student taking the Certiport (ITS) Python exam in a couple of days, and I need a 700 to pass.
I already have little Python knowledge, so I’m mostly looking for resources tailored to the actual exam format and tricky questions. Are there any specific YouTube videos, or practice tests that helped you pass? Any last-minute tips on what topics they test heaviest would be super appreciated!
r/learnpython • u/blackgarliccookie • 1d ago
I'm trying to turn these two variables, this is for homework so I'm gonna call it something else. I want to turn people1 and people2 into 1 variable.
people1 has two values, "not green" and "green". people2 has two values as well, "not purple" and "purple".
I want to make it so that everyone with "not green" and "not purple" are combined into one label, but only if they have both, not just one. I am struggling so bad :(
I am using pandas in python also. Thank you.
Edit: I want something like this: https://www.reddit.com/u/blackgarliccookie/s/xkzPCrmyrB
r/learnpython • u/Routine_Version7129 • 1d ago
Hey I need some help regarding programming python? Where am I supposed to begin? How to embrace the language? People say that you just dive in and you’ll start learning it, I tried but I go stuck, need serious help, please
r/learnpython • u/Joltik2007 • 2d ago
I'm combing two lists together into a dictionary, but when i print it also prints out the type of value(e.g float).
[-1.61803399 -0.61803399 1.61803399 0.61803399]
[[ 0.37174803 -0.60150096 0.60150096 -0.37174803]
[ 0.60150096 -0.37174803 -0.37174803 0.60150096]
[-0.37174803 -0.60150096 -0.60150096 -0.37174803]
[-0.60150096 -0.37174803 0.37174803 0.60150096]]
{np.float64(-1.6180339887498922): array([ 0.37174803, -0.60150096, 0.60150096, -0.37174803]), np.float64(-0.6180339887498947): array([ 0.60150096, -0.37174803, -0.37174803, 0.60150096]), np.float64(1.6180339887498942): array([-0.37174803, -0.60150096, -0.60150096, -0.37174803]), np.float64(0.6180339887498946): array([-0.60150096, -0.37174803, 0.37174803, 0.60150096])}
This is what I get as an output. Aside from the types being printed it's fine. The code I'm using to join the two together is
energy_levels = dict(zip(eigenvalues, eigenvectors))
where eigenvalues and eigenvectors are the two lists printed above and energy_levels is defined earlier on as empty dictionary.
r/learnpython • u/WheetabixLicker6767 • 2d ago
hello, I am kinda new to python and I am not sure if someone already answered this in another post but how do you fully shut down the windows running python? Like not just clearing them but getting rid of the whole window
Right so to clarify- Yes I know that the "x" exists im not blind I meant how to close the window without any pop-ups (In the actual code itself)
r/learnpython • u/One_Yellow_7849 • 2d ago
I’ve been learning how to code in python for a couple of months, and I know things like loops, conditionals, variables, functions, arrays and basic concepts of POO. I learned all those concepts reading books, watching YouTube videos and using Claude, but I’ve been trying to build automation scripts with no ia I feel like I still don’t know what I’m doing and when I ask Claude to make the script for me I don’t understand it completely. My question is: should I avoid using ia until I can build scripts or software by myself?
r/learnpython • u/Dragoran21 • 2d ago
I wish to alter a table/dataframe like this one:
| Type | Alpha | Type | Beta | Type | Gamma |
|---|---|---|---|---|---|
| A | 100 | A | 80 | A | 90 |
| B | 20 | B | 40 | B | 30 |
| C | 1 | C | 1 | C | 0 |
| X | 1 | Y | 2 | Z | 1 |
Into something looking like this one:
| Type | Alpha | Beta | Gamma |
|---|---|---|---|
| A | 100 | 80 | 90 |
| B | 20 | 20 | 30 |
| C | 1 | 1 | 0 |
| X | 1 | nan | nan |
| Y | nan | 2 | nan |
| Z | nan | nan | 1 |
To combine data based on shared values so it is easier to compare different types.
How could I do this with Python?
EDIT: I followed Likh-98's advice but I ran into an issue.
import pandas as pd
df0=pd.read_csv('Table of Test.txt', sep='\t')
df1=df0.iloc[:,0:2]
df2=df0.iloc[:,2:4]
df3=df0.iloc[:,4:] #works
df1.rename(columns={'Alpha':'Value'}, inplace=True)
df2.rename(columns={'Type.1':'Type','Beta':'Value'}, inplace=True)
df3.rename(columns={'Type.2':'Type','Gamma':'Value'}, inplace=True)
df1=df1.assign(Source=['Alpha','Alpha','Alpha','Alpha']) #They were unclear how to fill the new column
df2=df2.assign(Source=['Beta','Beta','Beta','Beta'])
df3=df3.assign(Source=['Gamma','Gamma','Gamma','Gamma'])
frames=[df1, df2, df3]
result=pd.concat(frames)
result.pivot(index='Type', columns='Sourge', values='Value')
#Here I got "ValueError: Index contains duplicate entries, cannot reshape", when result was:Type Value Sourge
0 A 100 Alpha
1 B 20
2 C 1
3 X 1
0 A 80 Beta
1 B 40
2 C 1
3 Y 2
0 A 90 Gamma
1 B 30
2 C 0
3 Z 1
EDIT2: Here are a few ways to do it.
One:
import pandas as pd
df0=pd.read_csv('Table of Test.txt', sep='\t')
df1=df0.iloc[:,0:2]
df2=df0.iloc[:,2:4]
df3=df0.iloc[:,4:]
df2.rename(columns={'Type.1': 'Type'}, inplace=True)
df3.rename(columns={'Type.2': 'Type'}, inplace=True)
x=pd.concat([d.set_index('Type') for d in [df1, df2, df3]], axis=1)
print(x)Two:
df = pd.read_csv('Table of Test.txt', sep='\t')
type_cols = df.columns.str.startswith('Type')
# Check type column names correctly positioned
assert all(value is not bool(i % 2) for i, value in enumerate(type_cols))
frames = [
df.iloc[:, [i, i+1]].set_index(df.columns[i])
for i in np.flatnonzero(type_cols)
]
df_new = pd.concat(frames, axis=1)
print(df_new)There, solved!
PS: Is it just me, or are you also getting double text when you post to a code block?
r/learnpython • u/Glittering-Olive-404 • 2d ago
I’m sorry, this is probably a really dumb question but I’m picking up python as a hobby to learn between work and classes. I’ve never coded before and I’m not interested in doing it career-wise or anything like that. I just want to be able to understand the fundamentals of it. I’ve gone through many online courses as well as YouTube tutorials. I always get it in theory, when they explain the strings, integers, and whatnot, but when I actually go to write lines of code, I always find myself getting error codes, even when I follow the tutorial exactly, which honestly baffles me.
Does anybody have any tricks on how to deal with this learning curve? Something that might be extremely common knowledge to everybody else that I’m missing? Or any resources they could provide? I really want to learn how to code, I’m just not sure how I begin troubleshooting something that I don’t understand, if that makes sense.
r/learnpython • u/cheriieriot • 2d ago
same stuff on every venue site. name, date, price, ticket link. but each one hides it somewhere else, a table on one, cards on another, and a couple only fill in after the js runs so those go through playwright
so now theres a parser per site, and when a venue redesigns i find out because my list goes quiet
do people just live with one parser per layout or is there a way to describe the fields once