User:Bmai3673/ENES-100/project 3: Difference between revisions

From Wikiversity
Jump to navigation Jump to search
Content deleted Content added
 
Line 128: Line 128:
<u> Getting Started with Python(version 2.7) </u>
<u> Getting Started with Python(version 2.7) </u>


Python is a very easy to use programming language. Python is also a little more simple to understand because it uses spacing to denote different lines of code. To start, download Python from the main website (https://www.python.org/) the most recent Python version is Python 3 however a large sum of people are still using python 2. This how-to will be about the latest update to Python 2 which is 2.7 on a Windows computer. After Python 2.7 has been installed it may get a little confusing when trying to get it started up. The first thing can be to open notepad and just type anything into it, then click save-as and title it. At the very end of the title, write '.py' to save as a Python document, i.e it should look something like this: 'example.py'. It is now saved as a python document and if it was saved to desktop, the file should look like a piece of paper with the Python symbol at the lower right corner of the paper. Now that it is a Python document, to be able to edit it you need to right click the file and select 'edit with idle' and it now opens up in Python. From there all you have to do is write code and then to test if it works, click on the 'Run' tab at the top of the window then click 'Run Module'. If you want to quickly run a test program, type in the words: print 'Hello World'. Then run the module. When you run the module, it brings you to Python Shell and runs the program. Python Shell is more or less an interactive Python that will automatically run each line of code you enter. So if you were to do addition which would be to type in a number and then a second number separated by a '+' symbol, it will automatically add the numbers together.
Python is a very easy to use programming language. Python is also a little more simple to understand because it uses spacing to denote different lines of code. To start, download Python from the main website (https://www.python.org/) the most recent Python version is Python 3 however a large sum of people are still using python 2. This how-to will be about the latest update to Python 2 which is 2.7 on a Windows computer. After Python 2.7 has been installed it may get a little confusing when trying to get it started up. The first thing can be to open notepad and just type anything into it, then click save-as and title it. At the very end of the title, write '.py' to save as a Python document, i.e it should look something like this: 'example.py'. It is now saved as a python document and if it was saved to desktop, the file should look like a piece of paper with the Python symbol at the lower right corner of the paper. Now that it is a Python document, to be able to edit it you need to right click the file and select 'edit with idle' and it now opens up in Python. From there all you have to do is write code and then to test if it works, click on the 'Run' tab at the top of the window then click 'Run Module'. If you want to quickly run a test program, type in the words: print 'Hello World'. Then run the module. When you run the module, it brings you to Python Shell and runs the program. Python Shell is more or less an interactive Python that will automatically run each line of code you enter. So if you were to do addition which would be to type in a number and then a second number separated by a '+' symbol, it will automatically add the numbers together. To learn more about programming, it may be beneficial to learn from this website: http://www.codecademy.com/


<u> Getting Started with GitHub </u>
<u> Getting Started with GitHub </u>

Latest revision as of 02:44, 8 December 2014

Week 1 Narrative

[edit | edit source]

The tasks that I was assigned this week were to learn how to use pydocs, test pydocs with a small program and see how much information it returns, determine whether or not it could be useful for the attendance scanning project and to look for a python library that could be used for barcode scanning.

Pydoc Test



What was learned:

  • In Python Shell (which is an interactive Python application) need to import pydoc library
  • Then need to import the saved Python code using: import code_title
  • then write: pydoc.help(code_title)

How much does pydocs return?:

  • Pydocs returns important aspects of a code
  • Doesn't return any specific line of code
  • Comments are very important for documentation
  • Returns location of the saved file that is being documented
  • Returns the name of the file

Could this be useful for the project?: With good use of comments, pydocs could be very useful for the project

Barcode Scanning:

  • Unable to find a library however, I found a file called zbar 0.10 that is meant to read barcodes from images and/or video

This is the link to the file: https://pypi.python.org/pypi/zbar

Next Steps:

  • Re-write Attendance Access program
  • Install zbar 0.10 and test to see if it is the correct program

Week 2 Narrative

[edit | edit source]

The task that was assigned to me was to write a code using python that could read a CSV file and then return specific pieces of information in the file. The program could be deemed successful if the returned values were separated with spaces only, no comma's.

What is a CSV file?

CSV stand for Comma Separated Values and it is basically a list. It is text that separates rows and columns through the use of spacing and comma's.

Bad Code


What was done:

  • Created small sample CSV file
  • Wrote a program that can return chosen values

What was done wrong:

  • The program doesn't read the CSV file
  • The information in the program was manually entered in
  • The program prompted the user for what information was desired
  • Returned information was still separated by comma's

What was changed:

  • The whole code
Code Re-Write




Summary of Events:

  • The new code couldn't find the CSV file
  • Found syntax error, the letters CSV in "ENES100.CSV" weren't capitalized; Gave code a file path to the CSV file
  • Program worked but it returned the whole file and it still had the brackets and comma's
  • In last update, used list slicing to return only the first two columns and used ' '.join() to separate values with only spaces

Week 3 Narrative

[edit | edit source]

The task that I was assigned this week was to update the previous code to display the names of the lists that are in the imported CSV file and have the program prompt the user to choose the desired lists. The program must be able to return several lists at once and not only one at a time.


What was done:

  • Made the program ask what the user wanted
  • In addition to the question, the available items are listed and are numbered
  • The program can return several lists at once
  • Code updated was placed into my personal GIT repository

Next Steps:

  • Could possibly re-work code to improve code quality(Make minor improvements)



Week 4 Narrative

[edit | edit source]

The tasks that were assigned to me were to make the program able to receive numbers past 9, be able to print out specific rows of the CSV file, and to create a small write-up about using pydocs at the end of this narrative.

What was done:

  • Changed the code so that each number was required to have a semi-colon following it
  • The semi-colon allows numbers with multiple digits to be entered in
  • Only a minor update to code was achieved

What went wrong:

  • Unable to get the program to return specific rows
  • Was unable to get the program to count the number of rows in the CSV file

Next Steps:

  • Could look through forums about working with CSV files
  • See if there is any work online that does something similar to current goal to help

Pydocs

When using pydoc, it is important to have comments about the code that is being written. Pydoc Is a very good documentation system but it can only document the information that it is given which means that there needs to be information(comments) about what is currently happening with each line of code. It is not necessary to have a comment for each line, there just needs to be a good description of what is happening at important points so that when pydoc creates documentation, it is easy to follow along with what was happening with the writing of the code. It is important to make sure that the file for the code is given a relevant name for the project since pydoc will us the file name as the title. It may also be helpful to write a brief description about the goals of the program and its main purpose before any code is written because pydoc will use this as a description of the whole program. There is more information on pydocs in the links below.

http://stackoverflow.com/questions/13040646/how-do-i-create-documentation-with-pydoc

https://docs.python.org/2/library/pydoc.html

https://docs.python.org/3.2/library/pydoc.html

http://archive.oreilly.com/pub/post/programming_is_just_easier_wit.html

Week 5 Narrative

[edit | edit source]

The tasks that were assigned to me for the last week of project 3 was to upload everything I have for my code to GitHub and create a "Getting Started" how-to about Python and GitHub.

Link to code on GitHub: https://github.com/bmai3673/Attendance_Access_Python

Getting Started with Python(version 2.7)

Python is a very easy to use programming language. Python is also a little more simple to understand because it uses spacing to denote different lines of code. To start, download Python from the main website (https://www.python.org/) the most recent Python version is Python 3 however a large sum of people are still using python 2. This how-to will be about the latest update to Python 2 which is 2.7 on a Windows computer. After Python 2.7 has been installed it may get a little confusing when trying to get it started up. The first thing can be to open notepad and just type anything into it, then click save-as and title it. At the very end of the title, write '.py' to save as a Python document, i.e it should look something like this: 'example.py'. It is now saved as a python document and if it was saved to desktop, the file should look like a piece of paper with the Python symbol at the lower right corner of the paper. Now that it is a Python document, to be able to edit it you need to right click the file and select 'edit with idle' and it now opens up in Python. From there all you have to do is write code and then to test if it works, click on the 'Run' tab at the top of the window then click 'Run Module'. If you want to quickly run a test program, type in the words: print 'Hello World'. Then run the module. When you run the module, it brings you to Python Shell and runs the program. Python Shell is more or less an interactive Python that will automatically run each line of code you enter. So if you were to do addition which would be to type in a number and then a second number separated by a '+' symbol, it will automatically add the numbers together. To learn more about programming, it may be beneficial to learn from this website: http://www.codecademy.com/

Getting Started with GitHub

GitHub is an incredibly useful resource when programming. GitHub can help with version control, so basically it allows the ability to undo all the changes that were just made to the written code if needed. Another reason why it is so useful is because it allows other people to work on your project, if you choose to let them, and all of the files are online so they would be able to access your program from their computer. To start, the first thing to do is to go onto the GitHub website (https://github.com/) and create an account. Having an account is very important since it is what gives access to version control and group working capabilities. The next step is to download the GitHub application, there is a separate application for each operating system so if you have windows computer, makes sure to download the windows application. The GitHub application is a good way to look through all of the changes that are being made to your code and makes pushing your code to GitHub much easier. In order to make use of the application, all of the coding files that are being used for a specific project need to be placed into one folder and put into the GitHub application. to get the files onto the application, you just have to open the GitHub application then click and drag the folder containing all of the files and drop it onto the GitHub window. From there the application will ask if you want to create a Git repository for the folder. To go any farther, click 'create and add' and then fill in the proper information when it asks for it. This app helps sync the files that is located on your desktop and what is on GitHub and the application will keep track of the changes that are made to the code. When finished, click the publish button at the top right corner of the GitHub application window to move everything to GitHub.

Here is a guide to help with uploading code to GitHub: https://guides.github.com/introduction/getting-your-project-on-github/