Importing from Libraries

Cards (11)

  • A library is a collection of different commands that automatically come with Python , but are separate from the main file
  • Libraries can be imported to your program by using the import command at the start of your program
  • These commands belong to the random section in Python's library
  • These commands belong to the time section in Python's library
  • To import a specific from one of Python's libraries (e.g. random or time) , use the from and import commands at the top of your program
  • To generate random numbers, import the randint command section from Python's random code library , on the first line of the program
  • The randint command can be imported to generate random numbers
  • The randint command stands for random integer
  • In brackets, state the number range to randomly choose from
  • The random value generated by the randint command should be stored in a variable
  • The randint range could also be controlled by variables - The program below uses variables , to allow the user to select the lower and upper values of the range