#
# CSC 112 Python Example: another function, this one to print
# out information about a number (its square and square root)
#
# Jim Teresco, The College of Saint Rose, Fall 2015
#
import math
import random
# define a function to print some information about a number
def printNumberInfo(n):
square = n*n
root = math.sqrt(n)
print("The number " + str(n) + " squared is " + str(square) +
" and its square root is " + str(root))
# program execution begins here
# we can pass our function numbers
printNumberInfo(2)
printNumberInfo(7)
# we can pass it names that contain a numeric value
for num in range(30, 150, 13):
printNumberInfo(num)
# we can create some random numbers and pass those - notice
# here that we are passing along the random number returned to
# us by random.randint.
for trial in range(10):
printNumberInfo(random.randint(1,100))