Home python Does not run on Python Expected An Indented Block

Does not run on Python Expected An Indented Block

Author

Date

Category

You need to check the operation of the Random module with this code, and it does not start, Python shouts that the problem is in the 14 line, but that I do not understand
I work in 3.5.2.3.
The code itself is below

import random
Import Matplotlib.pyPlot AS PLT
Low = 12; HIGH = 68;
Fig = Plt.gcf ()
Fig.set_size_inches (14,5)
For k in Range (3,6):
PLT.SUBPLOT (1, 3, K - 2)
N = 10 ** k
N = RANGE (N)
RND = [RANDOM.UNIFORM (LOW, HIGH) FOR I IN N]
Plt.plot (N, RND, 'B.' ')
Plt.axis ([0, N, 10, 70])
Plt.xlabel ('$ n $'),
PLT.YLabel ('$ RND $')

Answer 1, Authority 100%

This error says that you have problems with retreats . In Python, cycles (and not only) are separated by indentation. For example, the body for you need to separate 4 spaces (ideally). I do not know how and cho there you have, but I think it will be correct (at least a mistake will eliminate)

import random
Import Matplotlib.pyPlot AS PLT
Low = 12.
High = 68.
Fig = Plt.gcf ()
Fig.set_size_inches (14,5)
For k in Range (3,6):
  PLT.SUBPLOT (1, 3, K - 2)
  N = 10 ** k
  N = RANGE (N)
  RND = [RANDOM.UNIFORM (LOW, HIGH) FOR I IN N]
  Plt.plot (N, RND, 'B.' ')
  Plt.axis ([0, N, 10, 70])
  Plt.xlabel ('$ n $'),
  Plt.ylabel ('$ RND $')

Also, points with commas are not needed absolutely, they worsen the readability of the code. I advise you to read PEP8

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions