Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I'm learning Python and can't even write the first example:

I am a beginner in python and not even able to solve this example:

print 2 ** 100

I am getting an error:

SyntaxError: invalid syntax

 I am using version 3.1

Where am I going wrong?

1 Answer

0 votes
by (36.8k points)

In python 3 version print statement is been replaced by print function.

The syntax is the same but you need to use parathesis

Old: print "The answer is", 2*2

New: print("The answer is", 2*2)

Old: print x,           # Trailing comma suppresses newline

New: print(x, end=" ")  # Appends a space instead of a newline

Old: print              # Prints a newline

New: print()            # You must call the function!

Old: print >>sys.stderr, "fatal error"

New: print("fatal error", file=sys.stderr)

Old: print (x, y)       # prints repr((x, y))

New: print((x, y))      # Not the same as print(x, y)!

 If you want to know more about the Data Science then do check out the following Data Science which will help you in understanding Data Science from scratch

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...