Programming Books for Beginners | Find the Right Book for Your Project

  • Thread starter Thread starter drosser
  • Start date Start date
  • Tags Tags
    Books Programming
AI Thread Summary
The discussion centers on beginner programming resources, specifically for creating a program related to a physics project. Python is recommended for its ease of use and built-in support for arbitrary-precision integers, making it suitable for mathematical computations. Suggested resources include the official Python tutorials and O'Reilly's "Learning Python" for complete beginners, or "Programming Python" for those with prior experience. C++ is also mentioned as an option, though it is noted to be more complex and lacking built-in arbitrary-precision arithmetic. For C++, using the GNU Multiple-Precision Library (GMP) is advised for handling large numbers. The conversation also addresses practical coding issues, such as running scripts from the command line and managing precision in calculations. Users are encouraged to utilize the long data type in Python for integer operations and to explore the GMPy module for floating-point precision.
drosser
Messages
13
Reaction score
0
I want to get into programming. Does anyone have any suggestions for books for beginners?

My goal is to make a program to finish my project at https://www.physicsforums.com/showthread.php?t=172789

Is there already a program that can do this?
 
Technology news on Phys.org
Mathematica can do it.

Or you can write your own program. If you're looking for a language that can easily do arbitrary-precision integer math, I'd look into Python. Python includes a native data type called long, which is an arbitrary-precision integer type that you can use just like any other number. Furthermore, Python is pretty easy to pick up.

Look on python.org for some tutorials, or pick up a copy of Learning Python from O'Reilly if you're completely new to programming. If you already have some programming experience in other languages, pick up Programming Python, also from O'Reilly.

- Warren
 
Python is a good language. I also recommend C++. If you search Google for something like "Beginner C++ Tutorials," you can probably find many good tutorials to help you with your problem, such as this one. C++ needs to be compiled (into native code so that your computer can understand it), so you'll need a compiler. I would recommend the latest Nightly Build of Code::Blocks, but I think that for what you seem to be doing, something that may be easier to install such as http://www.bloodshed.net/dev/devcpp.htm might be better (I'm assuming you're using Windows). Once you've downloaded and installed a compiler and feel comfortable with C++ (variables, loops, functions, object-oriented programming, etc.), I suggest checking out this.
 
Last edited by a moderator:
bfr,

C++ is fine, but it provides no built-in arbitrary-precision arithmetic and is syntactically and semantically much more difficult to learn than Python. However, if you choose to use C++, you might find GMP (the GNU Multiple-Precision Library) useful.

- Warren
 
True.

Note that the last link in my post actually linked to the GMP. ;) Great minds think alike...
 
I've been looking into the Python.

The python.org interpreter didn't work but I do have a command line interpreter.

How to you run a script file from the command prompt?
I've tried "read" and "write" functions but I'm pretty sure those aren't the right ones to use.

Also, I can't figure out how to turn on the precision numbers. When I make a calculation the interpreter just rounds the nearest integer. I tried to use the "if" command to escape when the program found an integer value, but the number is already rounded, so the number entered for x is outputted.

x = int(raw_input("Enter an integer: ")
if ((x*x)-R)/(P-(2*x)) == round(((x*x)-R)/(P-(2*x)))
print x
else:
x = x+1

The enter integer is for a starting number
 
drosser said:
How to you run a script file from the command prompt?
I've tried "read" and "write" functions but I'm pretty sure those aren't the right ones to use.

You type a command like python myscript.py where myscript.py is the name of your program.

Also, I can't figure out how to turn on the precision numbers. When I make a calculation the interpreter just rounds the nearest integer. I tried to use the "if" command to escape when the program found an integer value, but the number is already rounded, so the number entered for x is outputted.

If you're doing integer division, then just use the long datatype (rather than int), and carry on. If you need to do arbitrary-precision floating point division, then you need to install the GMPy module and use that. (You can check to see if GMPy is already installed by typing "import gmpy" in the Python interpreter.) Once GMPy is installed, just use code like this:

Code:
import gmpy, math

m = gmpy.mpf(math.pi)
print m ** 300

where gmpy.mpf is a multiple-precision floating point number.

- Warren
 

Similar threads

Back
Top