This assignment has you explore the capabilities of integer and floating point numbers in Python.
Create a loop that sets a variable to 2^N with N going from 1 to 1024 in steps of 1. Then, increase the final value of N. Print out the value of 2^N and the type of number used. Make sure you use integer values for this exercise and you'll need to use "2**N" rather than the math function "pow()".
Question 1: At what value do integer variables change type and what do they change to?
Create a loop that sets a variable to 2.0^N (note the addition of the ".0") with N going from 1 to 1024 in steps of 1 as in the previous problem. Print out the value of 2^N and the type of number used. Make sure you use floating point values for this exercise. Then, increase N until an error is reported.
Question 2: What error occurs and at what value of N?
You'll need to make sure you are using a version of Python 2.X for this exercise or you will get different results than expected. Also, depending on the approach you use you may obtain somewhat different results than other students who try different approaches.
Notes to instructors for next year: This assignment may need to change again if ArcGIS rolls to Python 3.3.
© Copyright 2018 HSU - All rights reserved.