Difference between revisions of "PythonOnSHIPs"
From CoolWiki
Jump to navigationJump to searchLine 9: | Line 9: | ||
:[[File:python2.pdf]] | :[[File:python2.pdf]] | ||
:'''Exercises''': | :'''Exercises''': | ||
− | ::Evaluate the square root of 10.1*10.2 + 15.3*15.4 | + | ::* Evaluate the square root of 10.1*10.2 + 15.3*15.4 |
− | ::What happens when you add two string variables together? | + | ::* What happens when you add two string variables together? |
− | ::Create a numpy integer array of values from 0 to 100, incrementing in steps of 2 | + | ::* Create a numpy integer array of values from 0 to 100, incrementing in steps of 2 |
− | ::Create a numpy floating-point array of 101 elements that range in value from 0.0 to 1.0 | + | ::* Create a numpy floating-point array of 101 elements that range in value from 0.0 to 1.0 |
− | ::Perform the following operations (in order) on the previous array: trignometric cosine, multiply by 1000.0 and convert it to integer format. | + | ::* Perform the following operations (in order) on the previous array: trignometric cosine, multiply by 1000.0 and convert it to integer format. |
− | ::Find the minimum and maximum value of the resulting array in previous exercise. | + | ::* Find the minimum and maximum value of the resulting array in previous exercise. |
− | ::Find the sum total of all elements of the resulting array. | + | ::* Find the sum total of all elements of the resulting array. |
− | ::What is the length of the array 'a' created by the following numpy command: a = np.zeros( int(np.sqrt(np.pi*100)+3.) )? | + | ::* What is the length of the array 'a' created by the following numpy command: a = np.zeros( int(np.sqrt(np.pi*100)+3.) )? |
− | ::What is the data type of the array 'a' in the previous exercise? | + | ::* What is the data type of the array 'a' in the previous exercise? |
− | ::Create an array 'x' of size 20 with floating point values between 1 and 20. Create a second array 'y' of size 20 with floating point values between 1 and 20. Calculate the distance between a point (2.5,7.8) and all elements of (x,y) pairs and store it in the variable 'dist'. | + | ::* Create an array 'x' of size 20 with floating point values between 1 and 20. Create a second array 'y' of size 20 with floating point values between 1 and 20. Calculate the distance between a point (2.5,7.8) and all elements of (x,y) pairs and store it in the variable 'dist'. |
− | ::Create a 2-Dimensional numpy array of size 15 columns X 17 rows filled with zeros. Set the middle column to 10. Set the last five rows to 20. | + | ::* Create a 2-Dimensional numpy array of size 15 columns X 17 rows filled with zeros. Set the middle column to 10. Set the last five rows to 20. |
Revision as of 23:18, 29 May 2013
Tutorial 1: Overview of Programming
- Presents the basic concepts of programming for newbies.
- File:Python1.pdf
Tutorial 2: Data, Variables and Math operators
- An introduction to the python interpreter, variables and types of data they store. Using math functions and python as a calculator.
- File:Python2.pdf
- Exercises:
- Evaluate the square root of 10.1*10.2 + 15.3*15.4
- What happens when you add two string variables together?
- Create a numpy integer array of values from 0 to 100, incrementing in steps of 2
- Create a numpy floating-point array of 101 elements that range in value from 0.0 to 1.0
- Perform the following operations (in order) on the previous array: trignometric cosine, multiply by 1000.0 and convert it to integer format.
- Find the minimum and maximum value of the resulting array in previous exercise.
- Find the sum total of all elements of the resulting array.
- What is the length of the array 'a' created by the following numpy command: a = np.zeros( int(np.sqrt(np.pi*100)+3.) )?
- What is the data type of the array 'a' in the previous exercise?
- Create an array 'x' of size 20 with floating point values between 1 and 20. Create a second array 'y' of size 20 with floating point values between 1 and 20. Calculate the distance between a point (2.5,7.8) and all elements of (x,y) pairs and store it in the variable 'dist'.
- Create a 2-Dimensional numpy array of size 15 columns X 17 rows filled with zeros. Set the middle column to 10. Set the last five rows to 20.