Python 2.7.3 or 3.4.1? Which to Learn for Physics/Math

  • Thread starter Cake
  • Start date
  • Tags
    Python
In summary, both versions of Python are relatively straightforward to learn and work well for programming physics and mathematics. However, if you are planning on using standard libraries or writing code specifically for 3.4.2, you should learn Python 3.
  • #1
100
16
I have a book for learning python that teaches it with python3 in mind. I also have been using codecademy.com to learn in a more structured way. The thing is that codecademy teaches python from when the most recent form of python was 2.7.3. Their reasoning behind this is that python3 isn't very backwards compatible so they're teaching 2.7.3 for now. If you were learning python for physics and mathematics programming, which version would you learn?
 
Technology news on Phys.org
  • #3
Either way you'll be fine. The main purpose of initially learning how to code is to learn how python works. At the most basic level, python 2.7 and python 3 will work the same. If you want to be extra clever, you can follow the python 2.7 lessons and do it python 3. Thus teaching yourself the difference. However, as someone who knew python 2.7, teaching myself python 3 took a day at basic principles. A bit longer to get used to smaller modules, but the built in STAT modulo was nice.
 
  • #4
Yes, for a long time now, everybody keeps talking of waiting for the move until all scientific modules have been ported over to 3...but you don't need them all, just check to see which ones you need and if those have already been ported over or not.

Lately, I learned of the Anaconda Python distribution...I liked it and install it; from the documentation, one can tell that it is fairly easy to switch between running 2.7 and 3.4 using conda.
 
  • #5
I would learn 2.7 just because there are a lot more useful libraries for it so far. I don't know how many times I started writing a program in 3.4.2 and then I had to convert the whole thing back to 2.7 just because there weren't any libraries to do what I wanted. Unless you are either going to be using really standard libraries without getting too technical, or you are up to writing whole new libraries for 3.4.2 (which you aren't since you are just starting out), I would recommend 2.7.
 
  • #6
If you need 2.x for compatibility with libraries, use that. Otherwise use 3.x.
 

1. What are the main differences between Python 2.7.3 and 3.4.1?

The main difference between Python 2.7.3 and 3.4.1 is that Python 3 is not backwards compatible with Python 2. This means that code written in Python 2 may not work in Python 3 without some modifications. Additionally, Python 3 offers new features and improvements, such as better Unicode support and a more consistent syntax.

2. Which version of Python should I learn for physics/math?

Both Python 2.7.3 and 3.4.1 can be used for physics and math applications. However, as Python 3 is the newer version with more features and support, it would be beneficial to learn Python 3 for these fields.

3. Are there any libraries or packages that are only compatible with one version of Python?

Yes, there are some libraries and packages that are only compatible with either Python 2 or Python 3. It is important to check the compatibility of the libraries you plan to use before deciding which version of Python to learn.

4. Can I switch between Python 2.7.3 and 3.4.1 when working on different projects?

Yes, it is possible to have both versions of Python installed on your computer and switch between them for different projects. However, it is recommended to choose one version and stick with it to avoid confusion and compatibility issues.

5. Is it necessary to learn Python for physics/math, or are there other programming languages that may be better suited?

While Python is a popular choice for physics and math applications, there are other programming languages that can also be used, such as MATLAB and R. It ultimately depends on the specific needs and preferences of the user. However, Python is a versatile language with a large community and many useful libraries, making it a great choice for these fields.

Suggested for: Python 2.7.3 or 3.4.1? Which to Learn for Physics/Math

Replies
2
Views
909
Replies
1
Views
152
Replies
15
Views
1K
Replies
1
Views
1K
Back
Top