I really want to learn programming, but I have just started and it's very confusing. I have no programming background at all, so this is all new to me.
Right now I'm learning Python, and although I understand what coding is, I don't understand what I'm currently learning. Im working on variables and strings, I follow the steps and I've passed every exercise so I don't have any problem understanding how to create a variable, strings or using strings methods, my problem is understanding what this is good for?
like I was reading the string method upper() to make a string upper case, so Why not type the string in upper case to begin with, instead of having to make it an upper case with upper( ). I hope you guys understand what I mean.
I don't have a problem understanding the exercises, my issue is understanding what this is all good for! maybe Im looking at a small portion of what coding is, I just can't wrap my head around what a variable or a string really represents.
for your example on the .upper(), if you wanted to check for a users input only in UPPER case, you would use it then...
usrInput = raw_input("hello")
if usrInput.upper() == "H":
# do this
I've only recently started learning to code in depth as well, and I understand where you are coming from. These exercises are intro level and that is why they may not seem very useful persay. But the world of programming is all around us. Anything electronic you use in everyday life has been programmed to do something.
Welcome to the programming world, my fellow programmer @dataace31567!
Nice question. "Why we need to worry about creating variables, using strings, using string methods and such?" Well, coding isn't just getting a value from a user and printing it back to it with a nice output, the idea is that but not only.
The usage of variables is to store a value (any type that's supported by Python) so you, the programmer, can use it to do something. The strings will help you whenever you are working with .txt files or simple non-numeric values such as names.
The function you use to get the input from the user, raw_input(), will bring back a string value so you'll need to learn how to use the basic string methods in other to work with any given input but hey, relax! You'll soon understand how things work and will start coding!
We are talking about users and, most of the time, they will try to tear down your code (lived and learned this in the worst possible way) so that's why, regarding strings, we have functions such as upper() and lower(). We never know what the input of our user(s) will be so we have to be ready but if we did know what they would input, we could simply alter it manually and things would be fine but you can't get everything you want
I believe you just began the course so questions like this sure are relevant so, like I said before, don't worry so much about it. You'll soon understand what functions you'll use most of the time and others you won't use so frequently. Usually you don't need to know everything about Python, unless your goal is to become the best Python developer in history (which is relatively possible), but if you can read the code and have an idea, even if it's a small one, of what's about it, things will be fine.
Hope you enjoy Python, it's amazing and you can sure have lots of fun with it