Why are Python printf examples fiction?

Hi

All the Python learning pages say that printf'ing must be done:
here

for x in range(0, 3):
    print "We're on time %d" % (x)


But, in pyCharm, I have to use brackets:

print("age = ",24)

for x in range(0,5) :
    print(x)
    print("squared=",x*x,'_')

Why does pycharm require this break from examples?
It will seem lame to try and explain that to a student.

Thanks
LVL 1
beavoidAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Most of the languages I know of require function arguments to be in parenthesis even for 'built-in' functions.
0
beavoidAuthor Commented:
So,

in .py files compiled in a console, parentheses are also needed?
Then why do the books exclude parentheses?

Thanks
0
peprCommented:
Just speculation. Python 2 uses print without parentheses (print is a command -- part of the syntax). Python 3 changes that, and print is implemented as a built-in function and it requires parentheses.

Later versions of Python 2 allows to import new syntax of print  with parentheses (that was back-ported from Python 3).

It is possible to write a module or program that can be executed both from Python 2 and Python 3 implementations. The version is detected by the module/program, and the functionality is implemented using both alternatives internally.

As Python 2 was considered to be obsolete in future, pyCharm authors may have chosen the print('with parentheses') syntax as a single one. It means that obsoleting Python 2 in future would not obsolete the pyCharm IDE. This also means that the third party extensions for pyCharm are universal independently on whether it runs or on Python 2, or on Python 3. From another point of view, the extensions are not to be broken when switching to Python 2 to Python 3.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

beavoidAuthor Commented:
Thanks.
If I start teaching local kids to do coding, is Pycharm the best way? (obviously is)
What are professional python projects done in?
Just curious
0
peprCommented:
In my opinion, whatever text editor that supports smart indentation and syntax highlighting is good for Python. Simple ones may be better at the beginning. They should not be confused -- the editor/IDE is not essential for the functionality of the program. Even Python's IDLE may be fine for kids. It also depends on whether the "kids" are 4, 10, 16, or 70.
1
beavoidAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.