CPTR 124 Fundamentals of Programming
The purpose of this lab is to acquaint you with the environment in which we will be developing Python programs.
- Log into a lab machine
If you are not using your own laptop, log into a lab workstation using your SAU username and password.
- Accessing information on the web
Point your browser to the the CPTR 124 web page:
- Go to
- click the CPTR 124 link,
- click the Labs link, and
- look at Lab 1.
- Go to
- Becoming acquainted with the lab
Quickly read over this entire lab before you begin to work on the computer. This will give you a good overview of what we will be doing today. For future labs you should make a habit of reading the entire lab before you begin any work. Ideally you will have read the assignment over completely (and maybe even begun work on it) before you come to lab.
You may work with a partner for this lab. Working with a teammate offers several advantages:
- Two people do not think alike. By collaborating with another student you can gain insights into programming concepts that might otherwise escape you.
- You have a built-in support system: You may have an immediate answer to a simple question that your teammate has, or vice-versa. Sometimes individual students are hesitant to ask a teacher a question because they mistakingly believe that everyone else knows the answer and the teacher will think they are stupid. Having a teammate in the same situation can make it less threatening to ask for help.
- Working with a classmate is more fun.
You may elect to work alone, if you prefer.
Regardless of whether you work alone or with a partner, on this and all future labs you are responsible for understanding all aspects of the work required to complete the assignment.
- Saving and organizing your work
If you are working on your own computer, you should create a new folder in which to store your work for this course. You could create a folder named
CPTR_124in your documents folder.
If you are working on a lab computer, you should not save anything to the computer's hard drive. When you log off of the machine anything you saved to it will be lost. Instead, create a folder on your network drive or on a USB thumb drive to store your work.
If you are unsure about how to go about creating new folders or navigating the operating system environment, please ask for assistance!
- Installing the development software
The lab workstations have the Python development software installed. If you wish to use your own computer, you may obtain the necessary software for free:
- First download and install the proper distribution of Python for your computer. Go to python.org and be sure to get version 3.4.1.
- After installing Python, download and install the latest Wing IDE from wingware.com.
- Using the Wing IDE 101 integrated
Chapter 1 in the textbook describes how to use WingIDE 101. For supplemental support, the video Creating a Python Program in Wing IDE 101 shows how to use the Wing IDE 101 integrated development environment (hereafter, simply Wing) to create and run Python programs.
You should follow the instructions in the book or video, but if you are working on a lab computer, you should save your Python programs on your network drive or a USB drive, not the computer's desktop. The instructions in the book or on the video show you how to create a particular program; modify the program so that it printsHey! This is part 1 of Lab 1.
After you have run your program and convinced yourself that it works correctly you may proceed with the next part of this assignment.
- Getting and working with the code we
develop in class
We will work on many programs in class, and all the code we develop in class is available online at the link provided below. It is very useful to get the code we do in class and play with it (modify it, break it, etc.) until you thoroughly understand how it works.
Direct your browser to
Chapter01and download one of the programs (a .py file) we developed in class, and save it to your computer or thumb drive, as appropriate. Right click on the downloaded file and open it with Wing.
Within the Wing environment, be sure you are able to examine and execute the program you downloaded.
You can use parts of the code from the code repository in your own programs as needed. The code repository site is updated after each class, so you should check back frequently for the latest Python code.
It is important that you are able to download files and work with them, not only so you can experiment with class code, but also because future labs may require you to incorporate other Python files into the programs you write.
There is one file in the repository that we did write in class. Obtain the file
other.pyand execute the Python program to see what it does. You can look at the program's code in the Wing editor, but do not worry about its complexity. It will be several weeks before we are ready to write such programs ourselves. Be prepared to run the program to demonstrate what it does.
When you are satisfied that you can obtain and work with Python code from the course repository, you may proceed to the next part of this assignment.
- Creating a simple Python program
Using Wing, write a Python program that displays the initials of your name on the screen. These initials will be large letters that you must construct. Each letter is created by composing many smaller “normal” characters into the shape of the desired letter:
- Create a new file. A good name for the file
- Add a
- Duplicate the printing line about 10 times.
You can duplicate the line by the
normal Windows means of copying and pasting. (Highlight the
line with the mouse, select Edit→Copy, move the cursor to the next line, and select
- Change the contents of the
quotation to form slices of the initials of your name. For
example, for my initials above, the first statement would look
print('RRRRRRRRRRR LLLL HHHH HHHH')
This printing statement makes the top row of letters (the first "slice") in my initials.
- Execute your program to make sure it works. If necessary, modify your program until you are satisfied that it works correctly.
- Check out
I will review your initials program with you before you leave. After your lab has been reviewed, please submit your initials Python source file to http://eclass.e.southern.edu. Log into eclass, select the
CPTR 124course, and submit your initials program using the appropriate assignments link. If you worked with a partner, your partner should submit his/her own copy of the code to
Important: For this assignment and all future assignments you should not submit an assignment to eclass until your work has been checked and approved in the lab.
- Finish up
You should close the Wing development environment when you are finished working with it. Select File → Exit.
- Log out
Don't forget to safely remove your USB drive and log out of your lab workstation before you leave.
If you are working with a partner, each person should write a program to do his/her own initials.
You should not devise
a sophisticated algorithm to complete this part; instead, simply
use a series
of printing statements that each print a horizontal slice of all three letters.
In order to do this part of the assignment:
Hint: Watch out for mixing tabs and spaces within the editor. Tabs may be treated differently within the editor than in the window that displays the program's output. It is best to use only spaces when laying out your initials within the editor.