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

  • Thread starter Thread starter drosser
  • Start date Start date
  • Tags Tags
    Books Programming
Click For Summary

Discussion Overview

The discussion revolves around recommendations for programming books suitable for beginners, with a focus on languages like Python and C++. Participants also explore specific programming challenges related to arbitrary-precision arithmetic and running scripts from the command line.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant seeks book recommendations for beginners in programming to assist with a specific project.
  • Another participant suggests Python for its ease of use and built-in arbitrary-precision integer type, recommending resources like "Learning Python" and "Programming Python" from O'Reilly.
  • C++ is also recommended by a participant, but it is noted to be more complex and lacking built-in arbitrary-precision arithmetic, with a suggestion to use the GMP library if C++ is chosen.
  • Participants discuss issues related to running Python scripts from the command line and the challenges of handling precision in calculations, with specific code examples provided.
  • There is mention of using the GMPy module for arbitrary-precision floating-point arithmetic in Python, with code snippets shared to illustrate its use.

Areas of Agreement / Disagreement

Participants express differing opinions on the suitability of Python versus C++ for beginners, with some favoring Python for its simplicity and others advocating for C++ despite its complexities. The discussion remains unresolved regarding the best approach for handling arbitrary-precision arithmetic.

Contextual Notes

Participants have not reached a consensus on the best programming language for beginners, and there are varying opinions on the resources and libraries needed for specific programming tasks.

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

  • · Replies 49 ·
2
Replies
49
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 23 ·
Replies
23
Views
2K
  • · Replies 9 ·
Replies
9
Views
14K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 7 ·
Replies
7
Views
1K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
8
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 58 ·
2
Replies
58
Views
5K