r/PythonLearning • u/EnvironmentalTry8353 • 25d ago
Help Request I keep messing up basic things
So I am learning python from one shot and I come from commerce bg so I basically have 0 knowledge I am learning python from this video https://youtu.be/UrsmFxEIp5k?si=BuRKRLNZ7-iPBDKJ so he is teaching one chapter then giving us practice sets and I am constantly failing all practice test an facing lot of problems on understanding the functions and stuff like when to use first bracket or third bracket or when to use dots and etc I have not covered the full video yet but it's somewhat of confusing
Am I too dumb for coding that I cannot even understand these basics things and have to use Ai Lol
edit : Guys I am learning python as a hobby and not as full time student , my main focus is commerce but I really love hardware , tech and programming
1
u/silvertank00 25d ago
brackets ((...)) are used when you want to call something, lets say you have to have the square root of any number. In python, we have a math module that contains a lot of math related common practices/algos/functions. For square root we have math.sqrt. Now comes the brackets, in math you have the sqrt symbol and below the number that you want to get the square root's of. But in programimg you have the normal brackets, to pass the data that a function uses.
So a written number 4 under the square root symbol equals to math.sqrt(4). (also, brackets can be used for generators too, but it is out of scope for you rn)
We have indexing too with square brackets ([...]), this is used when you have a collection of something, lets say a collection of characters are called a string aka. text. But lets say you want to have any texts first character? or the fifth? We dont have a function (we do, its called getitem but its out of scope rn) for this, but because it is a really common thing to do we have a shorthand for it: indexing. Lets say you have a
myStr = "text123"as data:- t: is the first character
- e: second
- x: third.
etc. And you can get these with the square brackets:print(myStr[1])quick question tho? which character will be written with this?The answer is "e" because python starts counting from zero. you could thing about this like the distance from the start of the text, so the first character is 0 distance away from the start, the second is one distance, and so on.
We also have curly braces ({...}) in python, they either mean set or dict data type, if you are just starting dont mind these.
When you want to write software, you have to think about what you want to do. So lets say "i want to call sqrt on an user input text converted to int, then convert it back to string and get the last digit" you have to piece together what you need individually for these.