3

The number can be very large

n = input()
print(n) #gives output in scientific notation

How to get the entire number?

PS: New to python

EDIT:

s = (input())      #100000000000000000000000000000000000000
if int(s[-1])%2 == 0:
    print (2)
    print (2)
    print (int(s)/2)         #5e+37
user3080029
  • 553
  • 1
  • 8
  • 19

2 Answers2

3

In Python 3, if you want integer division, use the // operator:

print(int(s) // 2)

The result of the division will be an integer and will not get printed out in the scientific notation.

NPE
  • 486,780
  • 108
  • 951
  • 1,012
  • 2
    Note that `//` operator has been there [*since Python 2.2*](https://docs.python.org/3/whatsnew/2.2.html#pep-238-changing-the-division-operator). So it is the recommended way to obtain integer division since then (even on python2). Your wording may be interpreted as if `//` is only part of python3, and one should use `/` in python2. – Bakuriu Sep 07 '14 at 11:08
1

You can format a large number into a scientific notation using the {:2E} formatting code. Example:

>>> "{:.2E}".format(100000000000000000000000000000000000000)
'1.00E+38'

Another variation to do this:

>>> n = 100000000000000000000000000000000000000
>>> '%2E' % n
'1.000000E+38'

See this question for discussion about the stripping out the extra zeros from the output.

Community
  • 1
  • 1
Anas Elghafari
  • 1,062
  • 1
  • 10
  • 20