CSC 226

CSC 226 logo

Software Design and Implementation


T1: Exploring our IDE Spyder

Objectives:

  • Set-up environment to see file extensions, so we can find Python files.
  • Learn to use the Spyder IDE
  • Learn a bit about Python

Team assignment T1 should be explored in class with a pair partner from your team. In future work, we will work as "pair programmers", a technique used in industry. Today, we are not going to work that way completely because I want everyone to get their laptops set up and to get comfortable with the Spyder IDE. Use your pair partner to talk together if anything is confusing. Then when we get to the point of submitting, we will take on roles.

File Extensions

Before we get started, I want to help you to improve your windows environment. Go to your Control Panel.

control panel

In the Control Panel, Go to Folder Options, and then go to the View Tab. Un-check the box that says "hide extensions for known file types."

un-hide extensions

This will allow us to see the ".py" extensions on our Python programs.

The Spyder IDE

According to Wikipedia, An integrated development environment (IDE) is a software application that helps edit and debug code. In other words, it is a program used to create other programs. Our IDE is Spyder. To open Spyder, if you are in Windows, you should see Anaonda in your program list, and Spyder will be in a submenu.

Spyder menu

You should see the splash screen appear while it is opening. Note that sometimes it will appear behind other windows if you have other programs open.
Spyder splash screen

The Window Panes in Spyder

With the default set up, the lower right window pane in Spyder is called the IPython Console. It is an interpreter window which you can think of as a scratch pad. Hence, you can type commands directly into it.
Spyder iconsole

Try typing some arithmetic statements like "2000 + 23" (without the quotation marks) into this console.

The upper right window pane has tabs:


The Object Inspector gives you the opportunity to engage with a Spyder tutorial:

Spyder Object Inspector


The Variable Explorer lets you see the values of variables when you run a program:
Spyder Variable Explorer


The File Explorer lets you navigate around in order to open files in the editor pane. You can just double-click when you find the file you want to open.

Spyder File Explorer

The left-most window pane is the editor pane. It is where we will do most of our work.
Spyder Editor


The Requirements and Deliverables

For the remainder of this teamwork, please use the following roles:
  • Facilitator: Reads the questions aloud, keeps track of time, and makes sure both partners contribute appropriately.
  • Recorder: Fully contributes in discussions then records all questions and answers.
  • If there is a third partner, they should serve as a Quality Control Officer: Considers how the answers could be deeper, and how the team could work and learn more effectively.
All partners should create a Microsoft Word file called yourusername-t1.docx where yourusername is appropriately replaced. e.g. Mine would be pearcej-t1.docx
  • Facilitator and Quality Control Officer: Submitted file contains only the name of the assignment, and the names and roles of all team members. For example:
    • Teamwork T1 Exploring our IDE Spyder
    • Facilitator: Ashley Aiken
    • Recorder: Jan Pearce
    • Quality Control Officer:Eric Rhodes
  • Recorder: Submitted file contains the name of the assignment, and the names and roles of all team members. For example:
    • Teamwork T1 Exploring our IDE Spyder
    • Facilitator: Ashley Aiken
    • Recorder: Jan Pearce
    • Quality Control Officer:Eric Rhodes
    • Followed by answers to all of the following:
  1. Use Spyder's IPython console for arithmetic. Be sure to try each of the following operators: +, -, *, and / with positive and negative integers as well as positive and negative non-integer real numbers. Report what happens. Is it what you expect in all cases?
  2. Use Spyder's IPython console to determine what // does when used as an operator with integers as if it was just /. Try enough examples to determine precisely what it does. Explain.
  3. Type "cls" without the quotes in the IPython console and report what it does.
  4. Use Spyder's IPython console to determine what ** does when used with integers. Try enough examples to determine precisely what it does. Explain.
  5. Use Spyder's IPython console with ^ and integers to determine that it does not do the same thing as **. Report what you tried and what you got. Try the same numbers with ** and report what you got. Do not worry about trying to figure out what ^ does quite yet--I give you some additional tools to figure that out with the next bullet. Just report on what you got and whether or not they are the same.
  6. Type "help('^')" in Spyder's IPython console without the double quotes and look through to see what it says about the "^" operator. Feel free to spend some time discussing this and Googling if you are interested in what this is. I mostly wanted you to know about the help feature. :)
  7. Do not Google this next one first. Instead, just guess. Use Spyder's IPython console to see if you can figure out how to take the absolute value of a negative number in Python. Report how you do it and also how many guesses it took until you figured it out.
  8. Do not Google this next one either first. Instead, just guess. Use Spyder's IPython console to see if you can figure out how to convert a non-integer like 3.4 or 6.78 to an integer number in Python. Report how you do it and also how many guesses it took until you figured it out. Note that there are different ways, and they do different things. You only need to find one of them, but please try enough examples so you can describe precisely what it does.
  9. Do not Google this next one either first. Instead, just guess. Computers use binary numbers internally for everything. Binary is a base-2 number system which represents values using two different symbols: typically written as 0 and 1. Use Spyder's IPython console to see if you can figure out how to convert a positive integer like 2 or 3 or 5 or 8 or 2000, etc to a binary number in Python. Report how you do it and also how many guesses it took until you figured it out.
  10. Type "x = 5" in the Spyder's IPython console without the double quotes.
    1. Then type "print(x)" without the double quotes. Report what happens.
    2. Next type "x == 10" without the double quotes. Report what happens.
    3. Next type "x == 5" without the double quotes. Report what happens.
    4. Next type "x = 10" without the double quotes. Report what happens.
    5. Next type "x == 10" without the double quotes. Report what happens.
    6. Explore the use of "=" and "==" until you understand how they differ. Then precisely describe their differences.
  11. Next we are going to explore the editing pane. Download choc.py and save it in a folder where you plan to keep code for this course. Note that you may have to right-click to download in certain browsers.
  12. Open choc.py. (You can drag it over the Spyder window pane to open.) Note that double-clicking a python file will not open Spyder--you will need to open the program from within Spyder. Note the interaction will appear in the IPython console. Report how this went.
  13. Next, click on the Variable explorer tab and run the program again with different inputs. Report what happens.
  14. Describe what the following appear to do in Python 2.7:
    1. raw_input()
    2. str()
    3. int()
    4. the + sign in: "Hello "+ entered_name+"! \n"
    5. the "\n" in: "Hello "+ entered_name+"! \n"
  15. Reflect on what the most surprising thing you and your partner(s) learned in the above teamwork. Explain why it was surprising.
  16. Reflect on what the most interesting thing you and your partner(s) learned in the above teamwork. Explain why it was interesting.
  17. Describe your team's reaction to the teamwork. Did you achieve the learning objectives listed at the top of the page? How might I consider ways of making it even better in the future?
Be sure ALL team members submit files named yourusername-t1.docx before leaving the classroom. Also be sure the recorder shares the file with the answers to all team members before leaving the classroom.

If you have additional time, explore some more by making changes to the code in the editor or by typing in the IPython console.


Copyright 2016 | http://cs.berea.edu/courses/CSC226/ | Licensed under a Creative Commons Attribution-Share Alike 3.0 United States License