Solutions of Python Programming Assignment

Spyder Familiarisation Exercise

1. Open the Spyder IDE. This can be done by

a. Downloading and installing Anaconda on your Mac or PC. Go to
https://www.anaconda.com look under Products, select individual Edition, then click Download and select the version appropriate to your computer.

b. Use a webbrowser (If using a Mac, Chrome is better browser than Safari).
Enter http://aka.ms/wvdarmweb into the URL search field and then follow the instructions. See video “Access Spyder with Browser” on the PH185 Myplace page

c. Use the Remote Desktop, instructions on how to download can be found at
https://docs.microsoft.com/enus/windowsserver/remote/remotedesktopservices/clients/remotedesktopclients. Follow the set up instructions shown in the video “Access Spyder with Remote Desktop” on the PH185 Myplace
page.

d. If you are using a Mac and download Anaconda watch the video “SpyderMac” on the PH185 Myplace page.

e. If you are using a PC and download Anaconda the steps to open Spyder given in the video “SpyderPC”.

2. Identify the IDE window, the Console window and the Variable Explorer window, see the video “Spyder layout”.

3. In the IDE window type (If you cut and paste you may need to change the single quote punctation marks ‘ otherwise you may get an error message). Do not worry about what the statements below mean, we will cover this during the module.

import numpy as np
myname = input(‘My name is:’)
array1 = np.linspace(1, 10, 10)
array2 = np.linspace(20, 35, 16).reshape(2, 8)
array3 = np.linspace(100, 135, 36).reshape(2, 3, 6)
notarray = 6.7

4. Save the file. If you are using the virtual desktop save to either your OneDrive or your hDrive. The hDrive can be accessed through the File Explorer by expanding “This PC” . It may be sensible to create a folder called PH185 in either drive to store your work.

5. Press the green “run” arrow and the text “My name is: appears in the Console window.

6. Place the cursor after the colon and enter your name

7. The variables created in step 3 now appear in the Variable Explorer Window. With reference to the video ‘Using the debugger’ on the PH185 Myplace page explore the values stored in each array. Try changing the integers in the reshape() method. If you do this make sure that the product of the integers is 16 for the 2D array and 36 for a 3D array.

8. Return to the console window and after the colon by In [2]: type the variable name myname then press return. You will see Out[2]: ‘your name’ appear in the console window.

9. Repeat step 8 for the other variables created in step 3.

You can change the appearance of the Spyder window. Simply click on the Spanner Icon at the top of the Spyder window. To change the background color select appearance and edit that.