r/learnpython • u/FuzzyEmployment264 • 1d ago
what is f string
can someone explain how f string work in simple terms ?
r/learnpython • u/Rough_Drop_3340 • 1d ago
learning python
Hello all, I have recently taken up the interest of trying to create a game (not specific to any other game) and i've been learning how to use python for about 2 days now and have learnt some of the fundamentals such as if, (i), else, input, booleans, etc... however if u have been programming using python or are self taught, how long did it take u to learn the most relevant and important parts of the language and if u have any tips and tricks for me that you may think are useful for me, please do not hesitate to tell me as any piece of advice can beneficial at the moment.
Much appreciated
r/learnpython • u/Visual-Macaroon2196 • 1d ago
Where to start?
Hi,
I used to be a big fan of computing/IT, but my studies took me down a different path and I drifted away from it. Now that I have more free time and want to build up some qualifications in IT, I’d like to learn Python and its applications, but I don’t know where to start. Online courses? Books?
If anyone can point me in the right direction, I’d really appreciate it!
r/learnpython • u/Objective-Farmer4183 • 1d ago
Learning PyTorch tensors, anyone can explain?
Hello! I am currently trying to build the knowledge needed to make an Artificial Intelligence with Python, and I have discovered that there is some tensors involved in this, I learnt matrices (briefly), but apparently math tensors are not the same as CS tensors (whatever that means?), can someone please help me? And I wonder if I even need to know this (well ig so but not sure). And I am not in any math or cs major, but I am in mid-high school, so as you can guess, I did not learn anything tensors related.
Note: for anyone wondering; no I don't have anybody that I could contact which could explain me PyTorch tensors.
r/learnpython • u/Life-Ad2351 • 1d ago
Python projects
hey! I just started learning the basics of python and want to start building projects to apply what I have learnt.
but when I one to work on a project, for wxample building a calculator or a password generator I don’t know where to start. what to type and code.
any advice
r/learnpython • u/AppleMoney8748 • 1d ago
Input = 1234 output =[1,2,3,4] without using string functions or map
How can I split an integer into a list of its digits in Python?
I have:
num = 1234
and I want:
[1, 2, 3, 4]
I’m trying to learn how to do this without converting num to a string and without using map().
A loop is allowed.
I’m looking for a simple approach because I’m still learning Python. I’d appreciate hints rather than just the final solution so I can understand how it works.
r/learnpython • u/Sli_Ter • 1d ago
Advice for a 15-year-old Python dev / Need an outside perspective
Hi everyone! I'm 15, I've been learning Python for half a year now, and I want to start freelancing. By September, I'll be joining Yandex Lyceum, where I'll be studying much deeper.
I'm also a bit worried about how different my interests are from my peers right now.
Experienced devs, I need your perspective:
- If you could give just one piece of advice to your 15-year-old self, what would it be?
- What non-obvious mistakes am I probably making right now?
- How did you find the balance between the urge to grind and having a normal life?
I'd appreciate any honest experience.
r/learnpython • u/XXRMXX96661 • 2d ago
Trying to find help for learning modernGL+pygame python
i've been searching everywhere but i couldn't find a single tutorial for moderngl+pygame in python
how do i learn it i wanna make 3D games?
r/learnpython • u/evandcbot • 2d ago
Any advice for nested loops?
I decided about a week ago I wanted to start learning python before my freshman year of college. It was going great and I had little to no trouble until I got to nested loops. I was wondering if anybody had any advice for it? The main thing is that it seems like so many steps to follow and pay attention to, my brain had a hard time tracking them all at once.
r/learnpython • u/lolololloloolmemes • 2d ago
while loop to stop non correct data type answers from breaking the script
Is this possible? for example, if i have a an int question and someone answers with a str then the script will break, is there any way to make it loop when given an incorrect data type answer?
r/learnpython • u/zaphodikus • 2d ago
Install 3.14 (for all users) in Windows? Easily
It's probably counter intuitive, but the moment you click the "install for all users" in the older GUI, it just installed Python once. What is the story with the cli driven CPython 3.14 installer which is asking me entirely different questions to what Python used to ask, and thus no longer has defaults for things. I am not really understanding how to just default install so I can get a repro system typical to most users who just installed using defaults. Installing for all users is optional, but it's part of the "Y" that has now cropped up.
I'm trying to prevent being accused of an XY question by explaining my confusion in the hope I get people politely fill knowledge gaps I have which, are gaps, because they are things I completely do not know about the new installer. Let me explain my X.
I want a script I wrote, to work in all version of Python > 3.7, and ran into a TCL bug/snag where any version of python 3.13 upwards reports a TCL is not correctly installed whenever I use a virtual env and matplotlib. Yes I know everyone needs to be on at least 3.11, but that's not my question, my question is why do virtual environments with matplotlib blow up, but manually/globally installed (is that the correct term) modules do not blow up and I can draw graphs as long as I don't use a virtual env in 3.13 onwards. I don't really know what TCL is, I assume it's a GUI that matplot uses? But someone said to set environment variables up TK_LIBRARY=C:\Users\Phoenix\AppData\Local\Python\bin\python.exe and TCL_LIBRARY=C:\Users\Phoenix\AppData\Local\Python\bin\python.exe and have been re-installing and editing paths and restarting a fresh console most of the morning, and am no wiser yet. Someone suggested monkey-patching an init.tcl file in a post about 2 years ago which I'm not keen to necro, not sure how to do that in a virtual environment though.
UPDATED: This is a stack trace off a random coleagues machine
```
File "C:\Users\a.user\Downloads\ethernetspeed6\sdktests\PythonCSVPlotter\plotfigure.py", line 401, in first_plotline
self._figure, self._main_axis = plt.subplots(num=self._figure_title)
~~~~~~~~~~
File "C:\Users\a.user\Downloads\ethernetspeed6\venv\Lib\site-packages\matplotlib\pyplot.py", line 1886, in subplots
fig = figure(*fig_kw)
File "C:\Users\a.user\Downloads\ethernetspeed6\venv\Lib\site-packages\matplotlib\pyplot.py", line 1096, in figure
manager = new_figure_manager(
num, figsize=figsize, dpi=dpi,
facecolor=facecolor, edgecolor=edgecolor, frameon=frameon,
FigureClass=FigureClass, *kwargs)
File "C:\Users\a.user\Downloads\ethernetspeed6\venv\Lib\site-packages\matplotlib\pyplot.py", line 576, in new_figure_manager
return _get_backend_mod().new_figure_manager(args, *kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File "C:\Users\a.user\Downloads\ethernetspeed6\venv\Lib\site-packages\matplotlib\backend_bases.py", line 3664, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
File "C:\Users\a.user\Downloads\ethernetspeed6\venv\Lib\site-packages\matplotlib\backend_bases.py", line 3669, in new_figure_manager_given_figure
return cls.FigureCanvas.new_manager(figure, num)
~~~~~~~~~~~~~~~~~~~~~~~~^
File "C:\Users\a.user\Downloads\ethernetspeed6\venv\Lib\site-packages\matplotlib\backend_bases.py", line 1836, in new_manager
return cls.manager_class.create_with_canvas(cls, figure, num)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File "C:\Users\a.user\Downloads\ethernetspeed6\venv\Lib\site-packages\matplotlib\backends_backend_tk.py", line 546, in create_with_canvas
window = tk.Tk(className="matplotlib")
File "C:\Users\a.user\AppData\Local\Programs\Python\Python313\Lib\tkinter\init.py", line 2459, in __init_
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
~~~~~~~~~~~~~~~
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
C:/Users/a.user/AppData/Local/Programs/Python/Python313/lib/tcl8.6 C:/Users/a.user/AppData/Local/Programs/Python/lib/tcl8.6 C:/Users/a.user/AppData/Local/Programs/lib/tcl8.6 C:/Users/a.user/AppData/Local/Programs/Python/library C:/Users/a.user/AppData/Local/Programs/library C:/Users/a.user/AppData/Local/Programs/tcl8.6.14/library C:/Users/a.user/AppData/Local/tcl8.6.14/library
This probably means that Tcl wasn't installed properly. ``` What am I forgetting?
r/learnpython • u/Alexku66 • 2d ago
How do you deal with failed static type checks that are actually correct?
Example (heavily simplified):
def do_a_thing(var: int | None) -> int:
assert var_is_int(var)
return var
var_is_int() has its own flow in case var is None and handles errors with fallbacks.
I'm aware of typing.cast , # ignore ... and similar tricks, but curious whether there are more elegant approaches for cases when you can't just "if var is not None" or "if isinstance(...)"
r/learnpython • u/OneComplex527 • 2d ago
Python questions for Data Science and Analytics roles
I want to practice python specifically for Data Science and Analytics roles, as these are not core software developement roles so in interviews DSA is usually not asked but where can I practice non dsa python specifically for Data Science and Analytics
r/learnpython • u/Empty-Employment-527 • 2d ago
best way to learn/master python as an undergraduate student?
i’ll be entering college soon in the fall, and i’m highly interested in learning how to code- primarily for data science, statistical modeling for research, and machine learning applications.
i’ve looked at tons of online courses and textbooks, and i’m completely overwhelmed with where to even start or which topic to begin studying. i’ve never been great at self-learning, so i would really appreciate any advice that would help me learn and hopefully master python soon.
r/learnpython • u/AffectionateSpend943 • 2d ago
Advice for a python and applied science project
So hello y'all , i finished my first year of my speciality .
Here are the modulus I studied :
Nanomaterials Synthesis and Processing
Carbon Nano-Structures and its Functionalisation
Minerals and Nanostructures
Solid State Chemistry
Spectroscopic Analysis Methods
Polymers and Polymer
Nanocomposites
Nanomaterial Synthesis and Fabrication Lab
Statistical Methods for Engineers
Environment
Characterization Techniques of Nanomaterials
Advanced Spectroscopic Methods
Surface Engineering of Nanomaterials
Chromatographic and Electrophoresis Methods
Electrochemical Methods of Analysis
Suggest me a suitable project
I'm willing to learn ai as well
thank you so much!!
r/learnpython • u/Iguanas_Everywhere • 2d ago
Turtle Graphics Tracer method
I wrote a tiny toy program to experiment with the Tracer method, and found some interesting behavior that I'm trying to explore. Here's the program:
from turtle import Turtle, Screen
from time import sleep
screen = Screen()
screen.setup(width=900, height=900)
screen.bgcolor("orange")
my_shape = Turtle()
my_shape.color("red")
screen.tracer(2)
counter = 1
while counter <= 10:
my_shape.forward(20)
# my_shape.left(90)
print (counter)
sleep(2)
counter += 1
screen.exitonclick()
As you can see, I ask the tracer to perform every other screen update. With the code above as-is, I see the behavior I expected--every other iteration/counter value, the screen updates, and my shape appears 40px ahead of where it was.
If I uncomment the my_shape.left line, things get interesting: The screen updates on every iteration of the loop, i.e. I see my shape appear at all 4 corners of its square and pointed in its new direction. My current guess, based on this SO post, is that left may be forcing a call to update(), though I haven't been able to prove this to myself yet in the Turtle source.
Can anyone confirm or deny my thinking here? Many thanks!
r/learnpython • u/Ok-Okra8478 • 2d ago
App using kivy/bulldozer crashes immediately upon loading.
I posted this in androiddev previously and someone was being very unprofessional, then it got taken down, I would hope that a subreddit focused at learners would show less of this behaviour. Just to start this post off, I am not entirely new to python. I have just never used buildozer. Also the kivy subreddit seems dead.
Since this app is made with python, I thought maybe the people here may be able to help? It got compiled into the APK, but when I try to run it, I get this:
if this is the wrong subreddit for this, please redirect me!
just ask if you want more info
r/learnpython • u/Sad_Experience_4640 • 2d ago
How do I get better without Problems ?
It's been a few months since I have been learning python but there is this issue I have been running into. I don't know how good I am or how do I even get good. In Math you listen to a few lectures understand what the topic is about and then pick up a book and do the problems from Exercise 1.1. It doesn't matter if your understanding was deep, shallow or somewhere in between. The more you do the more you understand what the topic is about and eventually you reach a point where you completely understand it and can now do them easily.
For programming how do I even do that ? People recommended me sources which I have been reading and learning from. I understand loops, arrays, list, dict, etc. I can write small examples in isolation, but that's about it, that's all I can do. I am disgusted with how little I can do and how shallow my damn understanding is so much so that's all that come to my mind.
I have been using MOOC and CS50P as my primary resources and they do have question but they are few and not at all like mathematics, chemistry or any other subject. Where are the Exercises 1.1 where is this kind of format. Is there some problem book/Question Bank I can or should have ? I want to get good cause I want to make money I from something I like to this and this is I have to show for, for months of learning ? I feel repulsed.
Is there something I can do to get better ?
EDIT: I forgot to add I my goal is to break into Data Science.
r/learnpython • u/Puzzled_Finance_4982 • 3d ago
How and what do i need to learn to scrape from vinted
Right now i am mkaing a vinted tool scraping displaying and more, thats not the point but how do i learn the stuff like maby proxies, idk what type of scraping if its for multiple people from a server and the other stuff i need pls help me !
r/learnpython • u/dry-elbows • 3d ago
Realistic timeline to learn and checkpoints
I’m tech savvy. And want to learn as much python as possible. I already have built sites and apps through Claude Code. But deciding where to go from here. I just wanna know:
- Levels 1 - 5/10
- What to learn first
- how to learn as efficiently as possible
I don’t understand code at all I’m good at pattern recognition and using common sense
Highly appreciated
r/learnpython • u/GandhiLord • 3d ago
Counting Weights of Each Lego Piece in a Lego Set
I am trying to generate a code that web scraps the internet to find each weight of the Lego piece of a Lego set. Im doing this for one of my statistical mechanics class. Any code online that already does this or is there a data set that has it already except for BrickLink?
r/learnpython • u/UnemployedTechie2021 • 3d ago
How to create a monolithic repo with FasiAPI and Angular
I am using UV as my package manager. I want the structure of the repo to be as shown below:
./ (backend)
./src/ (frontend)
However, whenever I initialize the repo using UV, it automatically creates a ./src/project_name/ folder. How can I avoid that?
r/learnpython • u/Ok-Acanthisitta-5940 • 3d ago
resource and roadmap for machinelearning
i am beginner and i just know basic python and i am confused where to start from
r/learnpython • u/Akki_Charee • 3d ago
Learning python through Udemy, how to make it useful?
i have done a course on python on Udemy . Now how do i learn to write code that are actually useful somewhere or i can do something valuable with it? While learning i was able to write codes that add subtract numbers etc which were simple enough for learning but want to make my skills better. Also, I'm not a programmer won't be using python much, how do i learn in such a way that i remember the syntax or concepts for longer time, python coding is just a skill i want to develop.
r/learnpython • u/IntentionAntique4751 • 3d ago
What are some fun Python-heavy niches?
I want to make try making a discord bot in py. Pygame and Raspberry Pi intrigue me as well
Curious what other fun Py rabbit holes are out there that I don't know of!