Import a package : Import « Language Basics « Python






Import a package

Import a package

import random

# generate random numbers 1 - 6
die1 = random.randrange(6) + 1    
die2 = random.randrange(6) + 1

total = die1 + die2

print "You rolled a", die1, "and a", die2, "for a total of", total

           
       








Related examples in the same category

1.Import enclosing moduleImport enclosing module
2.Demonstrates the differences between the methods for importing modulesDemonstrates the differences between the methods for importing modules