Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/feed-rss2.php on line 8
‘Python’ Articles at TC101 Fall 2015 https://kenscourses.com/tc101fall2015 Introduction to Programming Python and C++ Fri, 18 Sep 2015 20:20:03 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ Mastery02 https://kenscourses.com/tc101fall2015/2015/mastery02/ Fri, 18 Sep 2015 20:20:03 +0000 http://5nbppkkyj.wordpress.com/?p=100

]]>
https://creativecommons.org/licenses/by/4.0/
Creating a Python File and running it from the Command Line https://kenscourses.com/tc101fall2015/2015/creating-a-python-file-and-running-it-from-the-command-line/ Wed, 16 Sep 2015 18:26:49 +0000 http://5nbppkkyj.wordpress.com/?p=84 ]]> For a basic understanding and use of the command line I recommend this Code Academy course.
Screen Shot 2015-08-29 at 2.01.33 PM

You can watch my tutorial here:

]]>
https://creativecommons.org/licenses/by/4.0/
Masteries 01 and 02 – How to create, open and execute a Python file on Windows https://kenscourses.com/tc101fall2015/2015/masteries-1-and-2-how-to-create-open-and-execute-a-python-file-on-windows/ Fri, 11 Sep 2015 16:00:00 +0000 http://kenscourses.com/tc101fall2015/?guid=fbe3f1957756f8c6002cfc060fffee3e To create a new file:To create a file in python first you have to open the Python IDLE, to do this you have to go to the search bar and look for "python", there you willl see the IDLE exe.

The IDLE is like a comand line, you can´t write code on in, its just for testing. What you need to do to open a new blank space to write python code is to press "Ctrl+N  or to go to the corner and open a new file.

Now that you know how to create a new file, once you have your code written be sure to save it. It will be saved with a ".py" termination. 

To open/edit a file:

Once you have your file (you can even create it or download it) you will sometimes want to edit it, to write some extra code, finish your work or even correct somehing that was wrong. To do this first you have to localize your file: 
On the example I want to open the WSQ07.py file that I have in a folder in my desktop. 

I recommend you to memorize the files locations because if you want to execute it through the command line you will have to write the hole file adress. If you are bad at memorizing you should organize your files in jerarchised folders, this helps you to localize the file without not even knowing the exact location. Example: World/Continent/Country/State/City
This extructure will help you to go from something general to something specific without memorizing the exact adress. By the way, try not to use complicated names like "Masd123". Use something easy to remember that follows the logic of the jerarchy.

Continuing with the tutorial. The next step is to right-click on the file and select "Edit with IDLE". If you just open the file by double-clicking on it it will execute in the console or of it´s not finished it will not open anything. You should avoid opening .py files by double-clicking because the console that it launches will instantly run your code and when it ends it will close, you will not be able to see the prints or the results.
This will open the script so that you can continue writing on it.

To execute a file:

There are two ways of executing a file, through the command line and though the IDLE.
In my opinion opening it with the IDLE it´s a lot easier and you save a lot of time but it´s necessary that you know how to execute it with the command line because some text editors don´t have this option.

To execute the file with the command line(windows):

The first thing that you need to do is to open the CMD, look for it in the search bar and open it.
It will look like this:
Masteries 01 and 02 - How to create, open and execute a Python file on Windows

Now you have to write the folder directory of your file, I highly recommend you to save the file on c:/ so that you don´t have to write the location every time you run the program. 

To find the root directory open documents go to C:/ users / (name of the user), there is where the CMD will start. Here is an example:


Now, once that you have localized your file location and you are ready to put it down on the CMD be sure to write "python" before the file separated with a space. This tells the CMD to excute the file with python (if you installed it correctly of course), the CMD will imitate the python console and execute the file you selected with it. 


Always remember to write the file termination, in this case is ".py".

To execute the file with the IDLE:

This is going to be really simple. First you need to open the file with the edit option that I teached you.

This is my WSQ07 and if want to run it while i´m using the IDLE I just have to pres F5... yes, just that. The console will open the file automatically.


As you can see it atomatically star asking me for the first number, that means that the program is running. 

Just as simple as that you can execute the file and test it without pressing more that 3 buttons, have in mind that in some computers you need to press Fn+F5.



]]>
To create a new file:

To create a file in python first you have to open the Python IDLE, to do this you have to go to the search bar and look for “python”, there you willl see the IDLE exe.

The IDLE is like a comand line, you can´t write code on in, its just for testing. What you need to do to open a new blank space to write python code is to press “Ctrl+N  or to go to the corner and open a new file.
Now that you know how to create a new file, once you have your code written be sure to save it. It will be saved with a “.py” termination. 

To open/edit a file:

Once you have your file (you can even create it or download it) you will sometimes want to edit it, to write some extra code, finish your work or even correct somehing that was wrong. To do this first you have to localize your file: 
On the example I want to open the WSQ07.py file that I have in a folder in my desktop. 
I recommend you to memorize the files locations because if you want to execute it through the command line you will have to write the hole file adress. If you are bad at memorizing you should organize your files in jerarchised folders, this helps you to localize the file without not even knowing the exact location. Example: World/Continent/Country/State/City
This extructure will help you to go from something general to something specific without memorizing the exact adress. By the way, try not to use complicated names like “Masd123”. Use something easy to remember that follows the logic of the jerarchy.
Continuing with the tutorial. The next step is to right-click on the file and select “Edit with IDLE”. If you just open the file by double-clicking on it it will execute in the console or of it´s not finished it will not open anything. You should avoid opening .py files by double-clicking because the console that it launches will instantly run your code and when it ends it will close, you will not be able to see the prints or the results.
This will open the script so that you can continue writing on it.

To execute a file:

There are two ways of executing a file, through the command line and though the IDLE.
In my opinion opening it with the IDLE it´s a lot easier and you save a lot of time but it´s necessary that you know how to execute it with the command line because some text editors don´t have this option.

To execute the file with the command line(windows):

The first thing that you need to do is to open the CMD, look for it in the search bar and open it.
It will look like this:
Now you have to write the folder directory of your file, I highly recommend you to save the file on c:/ so that you don´t have to write the location every time you run the program. 
To find the root directory open documents go to C:/ users / (name of the user), there is where the CMD will start. Here is an example:
Now, once that you have localized your file location and you are ready to put it down on the CMD be sure to write “python” before the file separated with a space. This tells the CMD to excute the file with python (if you installed it correctly of course), the CMD will imitate the python console and execute the file you selected with it. 

Always remember to write the file termination, in this case is “.py”.

To execute the file with the IDLE:

This is going to be really simple. First you need to open the file with the edit option that I teached you.
This is my WSQ07 and if want to run it while i´m using the IDLE I just have to pres F5… yes, just that. The console will open the file automatically.

As you can see it atomatically star asking me for the first number, that means that the program is running. 
Just as simple as that you can execute the file and test it without pressing more that 3 buttons, have in mind that in some computers you need to press Fn+F5.
]]>
https://creativecommons.org/licenses/by/4.0/
WSQ01 https://kenscourses.com/tc101fall2015/2015/wsq01-11/ Sat, 29 Aug 2015 19:32:07 +0000 http://5nbppkkyj.wordpress.com/?p=13 ]]> I setup my school computer to run Python3, kind of.

I have downloaded and installed Python3 and I’m currently using Cygwin. This isn’t my ideal programming environment as I was planning to use Linux and maybe learn something while screwing up my computer (as suggested by Ken).

A quick Google search revealed something weird regarding my laptop model and Ubuntu/Elementary OS installation so I shall use OS X as a short-term solution to not being able to dual boot my laptop. I will probably figure this out next week.

ProofShellScreenshot


This helped me get a nice overview of editing before getting into the actual programming How to edit Python Code.

Downloaded Python3 from the Python Website.
Downloaded cygwin from cygwin.com

]]>
https://creativecommons.org/licenses/by/4.0/
WSQ01 – Setup Python https://kenscourses.com/tc101fall2015/2015/wsq1-setup-python/ Fri, 21 Aug 2015 13:51:00 +0000 http://kenscourses.com/tc101fall2015/?guid=67aa01c1d2379fb9b4450e05ee8cc473 This is how I installed Python.

 First I searched Python on Google to find a Download page, i clicked the first one because it seemed like the official page to download it.

 The next step was to choose what version i want. We are going to use Python 3 so I downloaded the Python 3.3.4 version for Windows.

 Next thing to do was to look for the downoaled file and install it.

 When I clicked it this window opened, i dont care if all the users of my computer have Python 3 so i chose the first option and then Next.

 Here I selected the location of the folder. I prefer to keep it default because its easier to find.

  In this window I chose all the features i wanted to install. As i really dont know what is necessary to work with Python I set all in default.

 Now I waited for the installation to finish.

]]>
https://creativecommons.org/licenses/by/4.0/