Sign InSign Up

Rocketbot Forum

Rocketbot Forum Logo Rocketbot Forum Logo

Rocketbot Forum Navigation

  • Academy Rocketbot
  • Tutorials
  • Documentación
Search
Ask A Question

Mobile menu

Close
  • Home
  • Popular
  • Categories
  • Tags
  • Questions
    • New Questions
    • Most voted
    • Most visited
    • Most Responded
  • Academy Rocketbot
  • Tutorials
  • Documentación
Home/ Questions/Q 1356
Next
Answered

Rocketbot Forum Latest Questions

bgrados
  • 0
  • 0
bgrados
Asked: January 8, 20212021-01-08T17:43:31+00:00 2021-01-08T17:43:31+00:00In: Academy

name ‘random’ is not defined

  • 0
  • 0

Buen día, en este caso intento usar la función de python random.int(0, 2)

para obtener un número aleatori, y lo toma como variable

quisiera saber como lo puedo solucionar o si hay otra alternativa

gracias.

5
  • 5 5 Answers
  • 31k Views
  • 0 Followers
  • 0
Share
  • Facebook

    5 Answers

    • Voted
    • Oldest
    • Recent
    1. joff
      Best Answer
      joff
      2021-01-08T19:25:08+00:00Added an answer on January 8, 2021 at 7:25 pm

      Evening,

      On the left if you go to to the bottom section there is a System module and this contains a Random option that you can use.

      If it fails you can download and install the System++ module from the Market and that should work for you.

        • 1
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. Bender
      Bender
      2021-01-08T19:06:12+00:00Added an answer on January 8, 2021 at 7:06 pm

      Hola bgrados,

      Puedes utilizar la siguiente instrucción: random.randint(0,2)

        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. bgrados
      bgrados
      2021-01-08T20:08:18+00:00Added an answer on January 8, 2021 at 8:08 pm

      gracias joff, lo pude solucionar con el módulo System ++

        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    4. bgrados
      bgrados
      2021-01-08T21:35:40+00:00Added an answer on January 8, 2021 at 9:35 pm
      name ‘random’ is not defined

      Bender, intente con la instrucción: random.randint(0,2) pero salió lo mismo ¿Porque que motivos puede fallar esa instrucción ?

        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
      • A16
        A16
        2021-01-09T03:16:49+00:00Replied to answer on January 9, 2021 at 3:16 am

        Es porque rocketbot por defecto no tiene importada la librería random.

        Esto te puede servir también, si es que no quieres usar el comando random del módulo de system++

        __import__(«random»).randint(0,2)

        lo que hará será importar temporalmente la librería y puedes acceder al método randint

          • 0
        • Reply
        • Share
          Share
          • Share on Facebook
          • Share on Twitter
          • Share on LinkedIn
          • Share on WhatsApp

    Leave an answer
    Cancel reply

    You must login to add an answer.


    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    Ask A Question

    Stats

    • Questions : 1k
    • Answers : 2k
    • Posts : 0
    • Comments : 0
    • Best Answers : 163
    • Users : 5k
    • Popular
    • Comments
    • Tags

    Related Questions

      • Answer: 1

      Error al iniciar Rocketbot

      • Answers: 0

      Error al conectar a BD oracle

      • Answers: 4

      error al ahcer click en objeto

      • Answers: 3

      Without access to Academy Rocketbot and its courses

      • Answers: 3

      Bot final Level 2

    Users

    Explore

    • Home
    • Popular
    • Categories
    • Tags
    • Questions
      • New Questions
      • Most voted
      • Most visited
      • Most Responded

    Footer

    rocketbot white

    Rocketbot SpA | Todos los derechos reservados 2018 - 2020

    © 2020 Discy. All Rights Reserved
    With Love by 2code.

    en_US
    es_ES en_US

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.