r/learnpython • u/Lost-_-swordsman • Sep 30 '23
I don't understand what python or coding even does
Trying to learn Python as a total beginner. Tried to watch a bunch of youtube tutorials but they just kind of ramble on and show what you can type like. Int -2777 float 2.7 string "hello" bool true1 or false0 print("hello world!") print ("hello", "end", 87, False, end="\n") moves to the next line with the n
For instance. and it literally means nothing to me. Can someone link a video or just explain to me what coding even is? right now it feels like i am just typing in random words into a text file. And i need to grasp the concept before i can begin to learn anything so i am just stuck. Please help
EDIT: Alright it seems https://www.youtube.com/watch?v=8mAITcNt710&ab_channel=freeCodeCamp.org was is the best way to get started, thanks everyone :D
16
u/jacobvso Sep 30 '23
Just start with CS50x. They explain it from the beginning.
3
u/Chuck5874 Sep 30 '23
I second this. I have tried several books and YouTube tutorials over the years. I have learned more in three weeks with CS50 than all of the others combined.
1
u/Lost-_-swordsman Sep 30 '23
seems to be the smart choice, 24 hour video.. LET'S GO
1
1
u/jacobvso Sep 30 '23
You can't just watch the videos. The problem sets are the important part :-)
1
u/Lost-_-swordsman Oct 01 '23
Yeah i am having a hard time finding the right ones for some reason
1
u/jacobvso Oct 01 '23
Go to https://cs50.harvard.edu/x/2023/
It's all there...
1
u/Lost-_-swordsman Oct 01 '23
that says CS50x 2023. this lecture if from 2021 and the 2021 lecture does not have the same youtube video to it so i wonder what is what
1
1
u/Chuck5874 Sep 30 '23
Agreed. Along with trying to implement the concepts in my own mini projects afterward as well.
4
u/Kureteiyu Sep 30 '23
Think of a calculator; you give it an input (2+2) and your get an output (4).
Now what if you need more complexity, being able to store values and results in variables, editing a variable only in some conditions, repeating operations, etc?
Well similarly, coding allows you to get an output from some input, with a set of rules (the algorithm).
0
u/Lost-_-swordsman Sep 30 '23
yeah but how does that information in the "calculator" become a website.
1
u/Kureteiyu Sep 30 '23
What exactly are you trying to learn? And what do you want to learn programming for? Programming is a large realm with a lot of different technologies to learn, so before starting, you should know where to start from.
If you want to learn web development, Python may not be what you want to start with. I could explain you how a website works but it is a whole other question (though Iâm sure there is plenty of videos on YouTube which explain how the web works). Anyway, if that is what you want to learn, you should first learn HTML and CSS, and then JS, to know how to lay out a web page.
1
u/Lost-_-swordsman Sep 30 '23
I am not sure what is required, but i want to make it my career i suppose. the only thing left to try. and loads of people say python is the best to learn first shrug
1
u/Kureteiyu Sep 30 '23
Alright. Well itâs true Python is good to start with. But prior to learning a programming language, you should understand what it is for.
Know that languages are divided in paradigms. There are declarative and imperative languages.
Declarative languages are only information, used to describe data (for example HTML; it doesnât do anything, it just describes what a web page should look like, so your web browser can display it).
Imperative languages are languages that take input, do a set of actions (instructions) and return output (for example Python). As others mentioned, think of it as a recipe, that take as input [eggs, flour, butter and sugar], and allows you to tell the computer what to do with it in order to return a cake.
Now you want to learn an imperative language (you have to learn one, because you canât do much with declarative languages alone), but which one?
âLow-levelâ languages (C, Assembly) are close to the machine and require you to do everything by yourself
âHigh-levelâ languages (Python) are closer to the human language and offer more abstraction, offering functions which do things you would have to program yourself in low-level languages. Hence most people recommending Python for beginners.
Last but not least, know that some languages are good for things and bad for other things. If you want to make a video-game, youâll rarely use Python as it offers bad performance (cost of its ease of use). Youâll never see a developer use R for something other than math. Web servers are not written in C. No one ever makes a Discord bot in Assembly (I would love to see it though!). If you want to see an overview of some programming languages and their uses, this article seems quite good.
At the end of the day, do start with Python as itâs one of the easiest imperative programming languages (and very useful in some fields). But know what it can be useful for, and what it doesnât do. This question (about what the language does) has already been answered in various ways in other comments, let us know if there is something unclear in those explanations.
3
u/Lost-_-swordsman Sep 30 '23
cheers m8. i went ahead and went with the "Harvard CS50 full course" on youtube instead. it really opened my eyes to what i am actually doing. only 1 hour in but has done a lot
1
1
1
Sep 30 '23
Python has pros and cons. I chose Python for the programming component of my course because I need students to be able to hack up reusable pieces of code that streamline their workflow. However, the Teacher who teaches software engineering principles chooses C# and C.
That being said, you can do most things in Python that you can in C or C# and vice versa.
However, your problem isn't language. Most programming languages are similar enough that most people who've learnt one language can fumble around others. Your program is learning how to build a basic model of what programming is inside your head - and that will come with time and practice.
1
Sep 30 '23
Well, it depends and even the easy answer is only "easy" and probably not useful for you.
Personally, I found the hardest part of learning how to program the early steps where everything is a 'toy problem' and nothing relates to anything I wanted to do.
Educators use toy problems to teach parts or sub-parts of the problem because the whole problem is actually dozens or even hundreds of little problems.
1
u/xiongchiamiov xiongchiamiov Sep 30 '23
This is why I really dislike intro to programming that starts with math. I had one of those, too, and I also was like "so what?".
If you want to make websites specifically, I really think you should set aside python for the moment and work on making simple static webpages with html. Then you'll start to run into some problems that can be solved with css, so you add that. Then other problems that can be solved with JavaScript, so you add that. And then you'll start to run into the problems that could use python, and that provides a good time to start learning it, because you have real use cases. Otherwise you'll just be going for a while through these very basic things without knowing where you're going or why you should stick with it.
At my university, they now do an introductory course that uses a lot of prebuilt tooling and scaffolding to introduce basic programmatic concepts into something where you can make stuff (music or simple video games, or I forget what else). And then only after a quarter of that do you go back to basics in a class that teaches you the foundations, once you understand why you'd care about it. I wish more things were structured this way.
2
u/CraigAT Sep 30 '23
I am slightly confused why you are taking time to learn Python, if you don't why or what it does? (Unless you have to for College/Uni)
Python is just one type/flavour of programming language, many other exist (Java, C, etc.). They are used to create programs, apps or websites that perform some kind of function - usually involves at least one of collecting data, processing data or outputting data.
Python like any language (including English) has a vocabulary and structure, it takes some time to learn both well. Probably starting out consistency is good, so pick a recommended course or method of learning and stick at it for a bit (if it doesn't work or feel right feel free to try another source). Eventually you will get the flow of things and be able to mix and match what you have learnt.
1
u/Lost-_-swordsman Sep 30 '23
I think it started with me seeing that data scientist made the most money out of the programmer type jobs that you could do from home. and then a bunch of people recommended python to start with shrug After seeing comments here though i went with the harvard CS50 course on yt now. to learn the actual basics
1
u/CraigAT Sep 30 '23
It is good to have something to aim for and the CS50 is an excellent course to get you started on your journey. There's quite a gap from knowing nothing to a career in data science, but if you have the right attitude and are willing to put in the time to learn and practice, then it is certainly possible. Good luck.
2
u/Lost-_-swordsman Sep 30 '23
Thank you. currently 40 minutes into the course and it feels like i am seeing for the first time in my god damn life. this shit is wild
19
Sep 30 '23
If you've ever used a computer, then you've interacted with software. Everything you're doing on a computer, software is doing for you.
Writing code in Python is how you can create software to do tasks that you determine, and that others can use.
7
u/Bobbias Sep 30 '23
You are writing instructions in a special language to the computer.
It's a bit like a recipe for cooking. You write each step down in the order they need to be completed, and ask someone to follow them from start to finish, with the end goal being a cooked dish of some sort.
A computer program is made up of code which are instructions just like a recipe, but they're written in a different language with precise rules about what everything means, because computers are dumb.
When a program on your computer is run, all the computer is doing is reading a list of instructions and doing what those instructions tell it to do millions of times per second.
Python is one such language which has specific rules about how to write those instructions for the computer.
What they are teaching are some of the basic concepts about programming, variables, types, and basic functions you can use.
The print function is how you instruct your computer to write some text to the screen, for example. A variable is how you instruct the computer to remember some piece of information. Python has a concept of different kinds of information, like numbers, text, true and false, etc. And these are called "types".
There are several other concepts: conditions (if x is true, do something, etc), loops (different ways to repeat the same instructions based on a condition), and functions (ways to group a set of instructions together) that make up the basic things you will find in basically every coding language.
Once you have those ideas, you can write instructions to tell your computer to do just about anything (well, there are problems computers cannot calculate, but that's an advanced topic, and not so easy to explain here).
6
u/yoknezupsa Sep 30 '23
Coding is magic mate. I am also new to programming and I asked my teacher, what does even python do? Because he had so many things to say about it, but nothing was relevant to me. Because it was my first week learning python.
Since I was thinking in the same way as you, I just couldn't figure out what python is even for. Than, I don't know I watched a random video on YouTube, where the guy was taking some random project from the Upwork and just started writing code based on the required instructions.
It was basically web scraping project. So, what python did in that scenario. There were like 20 posts on a web page and the Upwork guy wanted to copy everything in an excel sheet. Of course it could've been done by hand, and it would take couple of hours to do. But the YouTube dude made a script which could copy all the posts and relevant information in less than minute. Which was mind blowing to me.
Since than, I've been using Upwork for project inspiration and to me it feels like programming can be used to fix real life problems. And that's when I got hooked.
When I started learning python with the teacher, he just taught us for 2 weeks and I kept on thinking I don't like python, it's useless and I still never be able to learn. And now, 2 months in I'm in love with python. I've been learning how to automate stuff with python. Just for fun.
For example I made a telegram bot which can tell me weather or the population for a certain place. I know I can Google those stuff, but it feels so nice that you've built something. At the moment I'm learning how to automate things. And I'm pretty sure there is soooooo much out there.
In the beginning it can be overwhelming, and honestly when I watched those YouTube tutorials, I was like hmm why this and why that.. These whys will disappear once you'll do something fun for yourself.
It can be something so small like. E.g. Use python to open your chrome browser and than open your email and that's it. So you opened your email with just one click, rather than opening Google Chrome, than open your email, than add your email credentials and than finally you're in your in box.
I'm just using python like this and adding a new thing to my knowledge day by day.
Good luck with your journey and coding is magic mate, it's magic đ
1
Sep 30 '23
something i made is a tic tac toe game that has the computer use an algorithm to play the best spot against me to try to beat me. i have yet to beat the computer. i made it to understand some ML concepts to build a chess move recommender (since tic-tac-toe is very simple compared to chess). thatâs my current project.
1
u/Lost-_-swordsman Sep 30 '23
i should have clarified i know that code is used for games and stuff like that basically the whole modern world right. it's just the inbetweens. i wrote a bunch of code to do a function like my character moving right when pressing this and that etc.
how does that turn into a game lol
1
u/unruly_mattress Sep 30 '23
right now it feels like i am just typing in random words into a text file.
Sounds like you're missing a rather important part of the thing: actually running the code you wrote. Do you have Python installed on your computer?
1
u/Lost-_-swordsman Sep 30 '23
i do yes. and i write in pycharm. following tutorials they don't really show anything. then again i did find one from "programming with Mosh" that does have little things for you to do inbetween the lessons. this guy so far seems pretty decent.
1
u/ElNouB Sep 30 '23
I recommend you read the documentation rather than watching the tutorials, when a specific question arises you can watch a short tutorial on it.
1
1
Sep 30 '23
Why are you interested in learning to program? Is it a career move, out of curiosity, as a hobby, to solve a particular problem?
1
u/Lost-_-swordsman Sep 30 '23
I decided to make it my job. as i have a very hard time finding something so i decided that coding or at least a job that uses coding is the best for now. as i can work from home which is pretty much required
1
Sep 30 '23 edited Sep 30 '23
If you have no previous experience in programming, I suggest you first learn the basic concepts of programming. As another commented, have a look at the CS50 course. https://cs50.harvard.edu/python/2022/
1
u/Lost-_-swordsman Sep 30 '23
this seems to be the best one according to yall i'll give it another chance. cheers
1
u/ninedeadeyes Sep 30 '23
Programming is a tool and like a tool u would only use it if u want to build something from it. The easiest examples are games eventhough they arent the intended purpose of python.
1
u/Lost-_-swordsman Sep 30 '23
yeah i get that part. but not the connection between the two. while making a website let's say. and you write a bunch of code. where does that code go?
1
u/ninedeadeyes Sep 30 '23 edited Sep 30 '23
Coding makes the website interactive. For example here is a bunch of games I created using JavaScript.. Without the code you would not be able to provide any 'input' into these games to make any decision nor would it be able to respond to the input.
https://ninedeadeyes.github.io/JavaScript-Mini-Arcade/
You have to connect the JavaScript code to the HTML page within the script tag but I would focus on python as learning JavaScript is much more difficult than python in my opinion.
I actually written a small tutorial series of mini python games.. Hopefully they are small enough examples of understanding how code works.
https://github.com/Ninedeadeyes/15-mini-python-games-tutorial-series
1
u/jnorth81 Sep 30 '23
Reddit is a program that someone coded.
1
u/Lost-_-swordsman Sep 30 '23
Yeah i get that code is used. but the connection is lost on me. how does text in a box become reddit?
1
Sep 30 '23
What is your interest in learning Python?
Are you interested in coding, just to learn it, and never utilize it?
Are you looking to get into the programming field? Maybe to build applications, or possibly game programming?
Are you interested in automating tasks as an IT professional?
u/furious_cowbell gave a fantastic way to help with understanding what you can do with Python. And that's just the tip of the iceberg.
1
u/Lost-_-swordsman Sep 30 '23
I want to have it as my job basically. as i want to work from home lol. nothing admirable
1
u/pigpeyn Sep 30 '23
Try CS50 the online class. They cover the basics.
1
u/Lost-_-swordsman Sep 30 '23
he was using mac or something so it did not look the same and it threw me off.. guess i can try again. Currently started one from "programming with mosh"
1
u/pigpeyn Sep 30 '23
It doesn't matter what it looks like, computers operate the same at the base level. The class work is done inside a code space that will look the same on any OS and the terminal should look the same or close enough.
1
u/Lost-_-swordsman Sep 30 '23
his terminal just had a dollar sign mine had my computer files. but i guess that is just how it looks on windows :v i'll give it another shot
1
1
u/ThrowRA21458910 Oct 01 '23
I dont get why any programming languages are literally different languages to begin with. If computers, operating systems, programs, etc are all just human made by english speaking people to begin with -- why arent programming languages just developed as commands in normal comprehensive English? Why does it have to be cryptic? I remember the old text based computer games for example, which i know is obviously nothing alike, but i mean why wasnt programming developed using this same sort of principle?
I guess my question is a bit like metatheory. Ive always been curious about this, pardon my ignorance.
1
u/Lost-_-swordsman Oct 01 '23
yeah it is kind of weird. at least only use 1 cryptic language for everything why the need for 50 different coding programs lol.
people came together and decided what the different combinations of 0 and 1 would mean already so it's not like people didn't come up with it together.
1
Oct 01 '23
How's it going?
1
u/Lost-_-swordsman Oct 01 '23
I sat through the first lecture last night. but i couldn't find the correct homework for it :v
2
Oct 02 '23
Isn't this it "Problem Set 0" at this link?
https://cs50.harvard.edu/x/2023/weeks/0/2
u/Lost-_-swordsman Oct 02 '23
the youtube video that is linked is not the same as the one i watched.
but i'll go through the problem sets and hope it lines up
2
3
u/shiftybyte Sep 30 '23
coding is what someone does to create a program.
You are using reddit website, someone wrote code to create this website, to make it function, to show you posts by others, to remember what you posted, etc...
This website is displayed in a program called "browser" it allows you to see many different websites, someone created that program, using CODE and programming.
What you are starting to learn is the basic building blocks of how to create your own programs that can do whatever you want them to do.
3
u/Green-Sympathy-4177 Sep 30 '23
Well, at the beginning those tutorials are teaching you the basics, the building blocks that make up python:
What the native types are (int, float, bool, string)
print is a function, it displays stuff to the console (pretty useful to get an answer back
Then you'll learn about conditions, loops, and "advanced" types like list and dict.
And as crazy as it sounds, just with that you can already do a truckload of things. But they're also the building blocks that enables you to do even more advanced things.
All of that is really abstract until you start feeding it real life data and start extracting valuable information from it and automating boring tasks.
I guess it's like maths, on its own it is utterly useless, but once you use it to solve problems it enables you to do things you weren't able to do before, it makes some takes that were previously impossible possible, it's magic in a way.
Now for some examples of what coding is/does:
Reddit and every websites is "coded", the structure is made in html, the styles in css, and the reactivity (when you click shit happens) is made in javascript.
Games are coded as well, let's take a something like flappy birds to keep things simple: You have a bird, when you click it jumps, otherwise it keeps falling, you also have objects that the bird can't go through, the screen is moving forward and if the bird falls you die. All that logic is handled in code.
Google: From its website to the way it recommends and ranks pages based on your query? coded :)
AI: ChatGPT? a bunch of lines of code that take in a crapload of data and outputs a reply
SpaceX rockets aren't driven by people, they're driven by code, those fancy landings? All code :D
Now imagine if google wasn't coded and when you made a query some dude had to go fetch the right webpages... Yeah that'd be bad to say the least.
Landing rockets without code? Forget it lol
In its essence, coding is giving your a computer a set of instructions (and computers are really really dumb, but really fast).
If you want something "easy" that you could do right now (or relatively soon) that is "somewhat useful", because just barely knowing the basics do limit you a bit, you can probably already make something like a Body Mass Index calculator.
The problem: Given a weight and a height calculate the BMI of a person and output it
To caculate the BMI:
bmi = weight (in kg) / (height (m))^2The code (put that into a file called bmi.py):
# Ask the user to enter their height and weight
# Input by default outputs a string, so we use float to get it as numbers
height = float(input("Enter your height in meters: "))
weight = float(input("Enter your weight in kilograms: "))
# Calculate the BMI
bmi = weight / height**2
# Print the BMI
# Note the 'f' before the string, google what a f-string is in python
# Or guess it from seeing how it's declared and what it ends up doing
print(f'Your body mass index is: {bmi}')And now you can run it with:
python bmi.pyIt will ask you your height then your weight, and then it will print your BMI.
Once you learn about condition you can add more to it:
if bmi < 18.5:
print("You are underweight")
elif 18.5 <= bmi < 25:
print("Your weight is normal")
elif 25 <= bmi < 30:
print("You are overweight")
elif 30 <= bmi:
print("You are obese")
else:
print("Something went terribly wrong somewhere :o")I hope that helped a bit :)
Coding is like learning a new language, so be "ok" with the fact that you're gonna suck at it and that most of it will sound like black magic at first.
And I guess to finish, why python? Python is life, python is love, python does everything, python is pretty and readable. It's okay to start with it as first language. Just know that it will be hard and that it does require some motivation to go through all there is to learn (and there's a boatload of stuff to learn). Just know what you're getting into, and why. And at the end of that endless tunnel there are some very profitable careers :) Python pays my bills because I solve lots of problems with it and people who don't code think I'm some sort of wizard. So I love it, lol.
3
u/Green-Sympathy-4177 Sep 30 '23
Random reply, but after running that bmi code for fun... I ended up signing up to the gym...
See that's the magic of python ! * cries in fat *
2
Sep 30 '23
Have you ever followed a recipe to cook a meal? Followed instructions to assemble some furniture?
The challenging first step with programming is abstraction - you are moving from the real world (actually preparing ingredients, etc) to something happening entirely inside a computer and on the console (the window you are working in).
All the software you use every day, including this website, youtube, netflix, etc are similarly abstract. It does take a while to become comfortable with the abstraction and start to see how to represent real world problems of interest to you in a computer.
I help kids in local schools learn to programme. I find for many, physical computing resonates for them much more easily. To this end, you might like to read a few copies of the Raspberry Pi Foundation official magazine, MagPi - free to download in PDF form. Seeing the sorts of the things you can do with the small single board computers, and the code used to achieve it, can be very inspiring.
3
u/51dux Sep 30 '23
"And I need to grasp the concept before I can begin to learn anything so I am just stuck."
That's exactly the approach you should not take in my humble opinion. Coding is more about repeating mistakes until at some point you understand what the full code does.
Each time you'll make a mistake and fix it you will know why such problem happened and you will keep on building your knowledge from there.
1
u/zutari Sep 30 '23
Just gonna recommend the udemy course by Angela Yu. You can get it for under 20$ and it explains how and what to do for total beginners. Iâm about 1/5 through it and itâs helped me understand so much
1
u/SarthakTyagi15 Sep 30 '23
Try telusko YT playlist and can try r/30daysofpython sub to engage with others.
1
u/Allmyownviews1 Sep 30 '23
Okay.. I think I understand your question.. from reading your other comments. Think of code as simply directions to a destination. Turn left after x distance. Stop for the traffic lights on road y and turn left at this roundabout etc.
We. Can provide this instruction to get to our destination. There are probably different routes we could take (equivalent to the different platforms (standalone executable, app on a device, within the confines of a specific software terminal)), then you could have different modes of transport such as walk, drive, cycle etc, that would be equivalent to the software language. And finally the destination is the final task you want to achieve and equally diverse.
All tasks that a computer or electronic device does, relies on some code be it Python, C++ etc.
Python is a very good language to learn with as it has numerous uses and has a syntax which works more intuitive than others.
On a basic level, you could use your new code to compute a solution to a problem which is math based, making a small program to convert files, make a game, sort your accounts, tidy emails any number of tasks.
All these courses do are try and show the way to type the instructions using common syntax and then suggest simple tasks that will utilise them.
My suggestion is to look at something you need to do which you find difficult or monotonous on your computer and then look to perform it by your code.
1
1
Oct 01 '23
#It's automating maths.
print("Hello World!") # send the string Hello World! to the screen
x = 5 # assign 5 to the variable x
y = x + 2 # assign x + 2 to y
print(y) # send the number value of y to the screen
#of course you can do a lot more complex things.
for i in (range(1,11)): # print the numbers 1 to 10 on the screen
print(i)
# this is python
-2
0
Sep 30 '23
[deleted]
2
u/Lost-_-swordsman Sep 30 '23
alright will give it a go cheers
1
Sep 30 '23
If you are looking for book recommendations, I'd recommend Python Crash Course https://ehmatthes.github.io/pcc/
42
u/[deleted] Sep 30 '23
Programming is a reusable set of instructions (a bit like a recipe) that some person writes that tells the computer how to solve a problem or complete some activity.