12-24-2012, 10:20 PM
I have taken a c++ programming course and I'm trying to learn python. In C++ I would write something like:
int var = 3;
var = var+1;
cout << var << endl;
and later when I compile and run the program I expect the program to display the number 4. But in Python i wrote:
>>> var=3
>>> var=var+1
>>> print var
4
and to my dismay a 4 pops out right away! So how can write scripts so that they don't start doing things right away?
Also how do I use my Python programs once they're written?( I'm using Ubunu 12.10 and IDLE.)
For instance in for a C++ program, using the Linux terminal I would find the program in my directory, then type:
g++ ./programName.cpp
And if it compiles I would type:
./a.out
And my program would run in the terminal!
int var = 3;
var = var+1;
cout << var << endl;
and later when I compile and run the program I expect the program to display the number 4. But in Python i wrote:
>>> var=3
>>> var=var+1
>>> print var
4
and to my dismay a 4 pops out right away! So how can write scripts so that they don't start doing things right away?
Also how do I use my Python programs once they're written?( I'm using Ubunu 12.10 and IDLE.)
For instance in for a C++ program, using the Linux terminal I would find the program in my directory, then type:
g++ ./programName.cpp
And if it compiles I would type:
./a.out
And my program would run in the terminal!