Answers.Body: <p><a href="https://docs.python.org/3/library/random.html" rel="nofollow noreferrer">Python has this built in</a>. Or is there some reason you can't use it?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-20T00:11:11.220Z
Answers.Text: Thanks! I had simply not known about that function.
Answers.UserDisplayName: technicguy1
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-20T00:34:34.343Z
Answers.Text: Not every function from full python is necessarily available in every partial (or micro) python implementation, so I wanted to check first before going down a more elaborate route.
Answers.UserDisplayName: RSchulz
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-20T03:05:42.600Z
Answers.Text: Links tend to break. Could you give a code example in your answer in case the link is no longer available?
Answers.UserDisplayName: David Lechner
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-20T04:40:40.097Z
Answers.Text: I'm guessing python.org is pretty safe.
Answers.UserDisplayName: RSchulz
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-22T22:21:57.627Z
Answers.Text: In case anyone is looking for a concrete example using (Micro)Python's `random`, I created a small program that randomly displays images in the hub. You can find it here https://nbviewer.jupyter.org/github/arturomoncadatorres/lego-mindstorms/blob/main/examples/programs/random_images.ipynb?flush_cache=True
Answers.UserDisplayName: Arturo Moncada-Torres
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-20T00:10:01.080Z
Answers.LastActivityDate: 2021-01-20T00:10:01.080Z
Answers.UserDisplayName: RSchulz
Answers.Body: <p>Under operators, there is a block &quot;Pick Random&quot; where you can specify to pick an integral number between x to y... x and y you can type... So for a random direction, set it between 0 and 359 degrees ...</p>
  <p><a href="https://i.sstatic.net/VK2Hc.png" rel="noreferrer"><img src="https://i.sstatic.net/VK2Hc.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-19T23:46:31.120Z
Answers.Text: I am actually using python, so this solution is not really applicable, but that's my fault for not saying so.
Answers.UserDisplayName: technicguy1
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-19T09:57:32.227Z
Answers.LastActivityDate: 2021-01-19T09:57:32.227Z
Answers.UserDisplayName: Michael Verschaeve
Body: <p>I am making a Python program with the LEGO Robot Inventor software which will, among other things, turn the robot a random amount periodically, which of course requires a random number. However, I could not find any way to do so. Is there any Python function which I could use to get a random number?</p>
  
Tags: <programming><spike-prime><robot-inventor><micropython>
Title: How to get a random value in the Robot Inventor software (Python)
UserDisplayName: technicguy1
ThreadText: # How to get a random value in the Robot Inventor software (Python)
  
  (Asked by: username_0 on 2021-01-19)
  
  I am making a Python program with the LEGO Robot Inventor software which will, among other things, turn the robot a random amount periodically, which of course requires a random number. However, I could not find any way to do so. Is there any Python function which I could use to get a random number?
  
  **Tags:** programming, spike-prime, robot-inventor, micropython
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-01-20. Score: 3 | Accepted answer
  
  [Python has this built in](https://docs.python.org/3/library/random.html). Or is there some reason you can't use it?
  
  > **Comments:**
  > **username_0**: Thanks! I had simply not known about that function.  
  > **username_1**: Not every function from full python is necessarily available in every partial (or micro) python implementation, so I wanted to check first before going down a more elaborate route.  
  > **username_2**: Links tend to break. Could you give a code example in your answer in case the link is no longer available?  
  > **username_1**: I'm guessing python.org is pretty safe.  
  > **username_3**: In case anyone is looking for a concrete example using (Micro)Python's `random`, I created a small program that randomly displays images in the hub. You can find it here https://nbviewer.jupyter.org/github/arturomoncadatorres/lego-mindstorms/blob/main/examples/programs/random_images.ipynb?flush_cache=True  
  
  ---
  
  ### Answer by username_4 on 2021-01-19. Score: 5
  
  Under operators, there is a block "Pick Random" where you can specify to pick an integral number between x to y... x and y you can type... So for a random direction, set it between 0 and 359 degrees ...
  
  [![enter image description here](https://i.sstatic.net/VK2Hc.png)](https://i.sstatic.net/VK2Hc.png)
  
  > **Comments:**
  > **username_0**: I am actually using python, so this solution is not really applicable, but that's my fault for not saying so.  
  
  ---
  
  