#!/home/lab391/Ureka/variants/common/bin/python # Do not write anything above or delete the line above ####DIRECTIONS!####### # Cut and paste the commands below in the pyraf environment. # Be sure to import the following libraries: import numpy as np import math from pylab import * x = 78 y = 5*x**(1/3) + sqrt(x)+log10(x) z = math.pi*x**2 print '**Example 1**' print 'This is x, y, and z' print x,y,z print # If you have a list of data (aka array) which you will have,you need # to enter it like the following example x=[3,0,5,6,1,2] print '**Example 2**' print 'This is called a list in python' print x print # If you want to operate on each element, use the syntax # y = [function(element) for element in x], see the example below: # multiply each element of x by 3 and save it as variable y # We can call each element 'a' for convenience. y = [3*a for a in x] print '**Example 3**' print 'I just multipled x by 3' print x, y print # if you want to add or subtract...etc a list by another list, use syntax: # z = [function(element1, element2) for element1,element2 in zip(x,y)] # assuming you have defined y x=[3,0,5,6,1,2] y=[34,23,10,98,3] z = [a-b+9 for a,b in zip(x,y)] print '**Example 4**' print 'This is x,y and x-y+9' print x print y print z #Note you can run this script in a terminal window # without running pyraf or python by typing ./myscript.py