• OK, it's on.
  • Please note that many, many Email Addresses used for spam, are not accepted at registration. Select a respectable Free email.
  • Done now. Domine miserere nobis.

Help with Python

Pyropyro

Magos Biologis
Local time
Today 8:07 PM
Joined
Feb 3, 2012
Messages
4,044
---
Location
Philippines
Context: My gf is planning to study "R" to be even more competent (I find that INTJ's just don't stop learning) and I thought it would be great if I can accompany her by learning another computer language with her.

I've looked at Python since it's probably the most basic language there is. It seems there are two versions: 2 and 3 so I'm a bit confused on which one to play with.

Personally, I just want to make this as a hobby and another subject that we can converse about, nothing academic or money generating about my plans.
 

Cheeseumpuffs

Proudly A Sheeple Since 2015
Local time
Today 4:07 AM
Joined
Jun 27, 2011
Messages
2,238
---
Location
Earth Dimension C-137
I have both 2.7 and 3.3. I think 2.7 is generally believed to be the "better" version but I've noticed very little difference. That said, I'm far from an expert so my opinion should probably mean very little.
 

Ex-User (9086)

Prolific Member
Local time
Today 12:07 PM
Joined
Nov 21, 2013
Messages
4,758
---
Python 2 is the old, widespread version which due to its popularity back in the day received lots of useful libraries (tools and resources). It doesn't feature all the new additions which helped standardise code and modernised the way it handles. It is however more forgiving than 3 regarding the way you write and allows for a less disciplined approach.

The only major difference between those two for someone who's interested in learning programming is that python 2 has a lot more documentation, learning resources and programming libraries suited for specific tasks. Many of these have been recreated for python 3, but nowhere near all of them.

I'd say python 2 would be easier for someone who's going to learn and play around, while python 3 is the choice if you want to create something professional and portable across all other standards or get more serious about your programming.

That said, whichever of those two you pick, it won't have a significant impact on the difficulty or things you can do with it.
 

Black Rose

An unbreakable bond
Local time
Today 5:07 AM
Joined
Apr 4, 2010
Messages
11,431
---
Location
with mama
I tried python but I could not get arrays to work. If you cannot get data in and out, then you cannot set the rules to produce the results you want. I finally got Java to work and I made the program I wanted to make in python. I came to realize computers are just boxes with numbers in them. I would be better at understanding machine code I think. C++ gets into that level but I don't know C++. I think I know how Lisps works in machine code but not syntax. Python is slow, it does not match the refresh rate of your monitor if you have huge data sets. It is good for shapes but not high end graphics. Once I finished my program I could not think of anything else to do. I am going to make another YouTube video about being INTJ. I love my graph paper notepad, it is covered in tiny boxes just like a computer has. I wish I had more ideas. :slashnew:

edit: I got my java program to work not my python program. I did some stuff in python but not a whole lot and not my main goal (brain waves).
 

Pyropyro

Magos Biologis
Local time
Today 8:07 PM
Joined
Feb 3, 2012
Messages
4,044
---
Location
Philippines
Thanks guys. I'll think I'll go for the more "casual" Python 2.
 

rainman312

rice-eater extraordinaire
Local time
Today 7:07 AM
Joined
Feb 28, 2015
Messages
166
---
Location
West Hollywood
If you're set on casual python programming, 2 is probably the way to go, although I wouldn't recommend python itself if you hadn't specified it. I think C++ is probably a better beginner's language, due to how encompassing it is. If you learn C++ first, it'll be probably a lot easier to learn other languages if they're even somewhat similar (something completely functional like Haskell might be just as tough). Anyway, I guess that assumes you'd be interested in learning multiple languages. If you're set on python, go with it, as it's fine for small personal projects.
 

Haim

Worlds creator
Local time
Today 3:07 PM
Joined
May 26, 2015
Messages
817
---
Location
Israel
If you're set on casual python programming, 2 is probably the way to go, although I wouldn't recommend python itself if you hadn't specified it. I think C++ is probably a better beginner's language, due to how encompassing it is. If you learn C++ first, it'll be probably a lot easier to learn other languages if they're even somewhat similar (something completely functional like Haskell might be just as tough). Anyway, I guess that assumes you'd be interested in learning multiple languages. If you're set on python, go with it, as it's fine for small personal projects.
I would not recommend c++ as first language, it adds a lot unneeded complexity for what a beginner is doing, it is good to learn it but not as first, and it isn't that similar to other languages, it has different mindset.I would recommend C# or java.
 

rainman312

rice-eater extraordinaire
Local time
Today 7:07 AM
Joined
Feb 28, 2015
Messages
166
---
Location
West Hollywood
I would not recommend c++ as first language, it adds a lot unneeded complexity for what a beginner is doing, it is good to learn it but not as first.I would recommend C# or java.
I suppose, but it also prepares you fairly well for future languages, that's the point I was trying to make. Still, there's no definitive answer to this question. Just learn what you're interested in first, it's going to be challenging regardless.
 

ProxyAmenRa

Here to bring back the love!
Local time
Today 10:07 PM
Joined
Sep 30, 2009
Messages
4,668
---
Location
Australia
Once you pick up a language it is very easy to pick up any other. Just make sure the first language you pick up is not the Basic language. It is a horrible, horrible language.
 

Tannhauser

angry insecure male
Local time
Today 1:07 PM
Joined
Jul 18, 2015
Messages
1,462
---
Code:
def fibonacci():    
    yield 1
    yield 1
    
    a = 1
    b = 1
    while True:
        c = a + b
        a = b
        b = c    
        yield c
    
for n in fibonacci():
    print n
 

Grayman

Soul Shade
Local time
Today 4:07 AM
Joined
Jan 8, 2013
Messages
4,418
---
Location
You basement
Once you pick up a language it is very easy to pick up any other. Just make sure the first language you pick up is not the Basic language. It is a horrible, horrible language.

I actually started with it. I don't know when you used it but it has grown some. C, C#, VB, Java are very similar in idea but when I look at python I don't find it that simlar. I use windows OS so python isn't worth learning for me. I prefer UWP supported languages because I am lazy and only want to write one program for all my devices.
 

Tannhauser

angry insecure male
Local time
Today 1:07 PM
Joined
Jul 18, 2015
Messages
1,462
---
I mean what cause the while loop to exit or run more than once?

It generates numbers indefinitely. Say, for example, you want to find the smallest fibonacci number larger than N. Then you can use that function as
Code:
for n in fibonacci():
    if(n > N):
        print n
        break
One could of course write a regular function and do that check inside it, but then it is no longer general-purpose, and the code will look much less readable.

And it runs more than once because it is a generator, so one can iterate over the function in a for-loop. At every iteration, it will remember its previous state.

More on generators: link
 
Top Bottom