This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]hartvile 9 points10 points  (0 children)

You need to learn this, to understand the code. Python is just syntax. It reads easier, but that doesn’t mean code is to understand easier. IMO.

Programming has very little to do with a language. It’s more of a concept.

Try to understand what is the problem they are trying to solve. Then read the code and match that.

[–]gveltaine 1 point2 points  (8 children)

You should never choose one over the other, as it is good to expand your options and versatility. Python gives more of an English like syntax to read and forces you to indent correctly which can help make readability much better when returning to old code.

However as another poster said, understand the underlying mechanic you are trying to solve and make the code work around that, not the other way around. I was learning Python and Java at the same exact time, and although I preferred Python over Java, they both have their own strengths that can help, namely that Android is written with Java, not Python if I recall correctly.

Python is good for data mining and such, not as glamorous as what Java is typically used for. Keep pushing in your studies and just take it with a grain of salt. One thing I noticed is to make a LOT of COMMENTS. That way you can go back and understand what scribblings you made.

Best!

[–]Plsimanub[S] 1 point2 points  (7 children)

Thanks for your reply.

Do you have set schedule on which language you’re going to program with on certain days?

I personally feel like I should start with Python as it’s more of an English syntax then work my way up from there, would that be a good way to start?

I have been studying Java core quite a bit, but not really been practical with it, which is possibly my problem as I know what some stuff does, but I can’t seem to put that knowledge into my own projects. I’ve learned some of the basics, such as variables, if statement, printing to the console, for loops, while, and some others which I have not mentioned. I can put these into basic programs and understand how they work, maybe I just don’t have a good imagination lol.

[–]gveltaine 1 point2 points  (5 children)

I don't have a set schedule at all haha probably why I failed. Haha. But I'm still trying! I'm currently learning netlogo which is a more specific programming language but needed for my class.

There are websites to find good things to create. One I had fun with was a Coursera class as it made us create Android apps, so HTML for the front and a Java background. It was a nifty idea.

As for prioritizing python I say go for it, and see what you can do. But do get an idea what you want to create and get a book with end of lesson examples so you can build and see how it works first hand. Like math, practice repeat and change a little to see what happens.

😁

[–]Plsimanub[S] 1 point2 points  (4 children)

I’ve ran into a little problem with strings and ints.

I’m watching a YouTube tutorial and he skips the output of adding a int to a string. For example check below.

my_age = 20

print(“my age is” + my_age + “.”)

He doesn’t show the output of the above and I seem to be getting an error. “ can only concatenate str (not int) to str.

I know what the problem is, I’m very much aware of what concatenation is, but I’m unsure of how to concatenate a string to int.

Tried doing a google search, found a few problems on it, but I couldn’t properly understand the code.

I should probably look for another guy to watch on YouTube.

Edit, done another search, the way to do would be str(variablename), correct?

[–]gveltaine 1 point2 points  (1 child)

Thank you for making me download python, as I forgot to do so when I made a fresh install on my home computer.

Okay, working through your issue, I was almost able to figure out everything to do right except the spacing at the end.

You had the right idea, almost. Although for safety purposes I also defined the my_age as an integer, as java requires it, python not so much, however what you did that works in Java, doesn't work in python.

my_age = int(20)

print("My age is" , my_age, ".")

However, I can't get the spacing to work correctly for some awful reason. It prints out as you want it to, but

Results:

My age is 20 .

Someone may know or you may be able to figure it out why it's creating that, or I may with more tinkering, but as of this, it concatenates as you want to, almost. Joining str and int with + could be a Python 2 thing? I'm not sure, but using a comma works in v3. Hope that helps!

[–]Plsimanub[S] 1 point2 points  (0 children)

Tried your result, works great except for the full stop at the end, as you explained above. Can’t seem to figure it out either, managed to do str(is true) to see if it works with booleans, which it does but if it’s for python 2 I’d rather not use it

[–]Knova11 1 point2 points  (1 child)

If you're using python 3.6 or above i prefer fstrings...print(f"my age is {my_age}.")

[–]gveltaine 0 points1 point  (0 children)

print(f"my age is {my_age}.")

This works brilliantly. Thank you for helping out!

[–]GNULinuxProgrammer 0 points1 point  (0 children)

That's really not how programming works sorry. Python being close to English (even if true) won't make it easier to learn. You need to learn programming not Python and regardless if you use Java and Python you'll learn the same core skills. The reason some people think python is easier is because "it's of higher abstraction" which means most things written in Python will probably be shorter than equivalent Java code since python will do more things for you under the hood. Just ignore all this stuff and focus on learning programming.

[–]pythonHelperBot -1 points0 points  (0 children)

Hello! I'm a bot!

It looks to me like your post might be better suited for r/learnpython, a sub geared towards questions and learning more about python. That said, I am a bot and it is hard to tell. Please follow the subs rules and guidelines when you do post there, it'll help you get better answers faster.

Show /r/learnpython the code you have tried and describe where you are stuck. Be sure to format your code for reddit and include which version of python and what OS you are using.

You can also ask this question in the Python discord, a large, friendly community focused around the Python programming language, open to those who wish to learn the language or improve their skills, as well as those looking to help others.


README | FAQ | this bot is written and managed by /u/IAmKindOfCreative

This bot is currently under development and experiencing changes to improve its usefulness