Python Lesson 1
by adweb.admin
So…here we are…back again. This time we are going to run through the first lesson in the new material and see what we can break…sound like fun?
In this first lesson we are asked to open up our Gedit notepad and type in a series of print statements, save the file in the *.py* format (which is the python extension). Then from our terminal we are to run the program.
At first I ran all of these commands using Python but then it dawned on me that the tutorial was wanting me to type the print commands into the notepad, save the file and then run it from my terminal.
[note] Pay Attention Nick! [/note]
So that is what I did…well except for the pay attention part…which we will see next.
What I failed to do is type it correctly. You will notice on line (3) I capitalized the word print and when I opened up the Terminal and ran the program I immediately got a Syntax Error on line (3)
Imagine my surprise! I immediately went back in and made the correction using my amazing powers of deduction. If you will remember from our last blog one of the three things this book is going to teach us is how to notice differences. I spotted it immediately with the help of Terminal which announced my mistake.
[note] At this level of the game mistakes stick out like a cold sore covered in Caramex[/note]
After making the changes and saving the file…I was able to run the program with success!
[note] Before ran the program I saved the file I wrote in the notepad to a temp folder and used my terminal to open the directory before running the program
>> cd temp
>> python ex1.py[/note]
As I read on the author, Zed, points out an error. Interestingly enough the error that he displays was on the same line that I found my error (line 3). The specific error was different (mine was a capital “P” where his error was due to the failure to use an end quote).
The point here is that if you make a mistake your terminal will prompt you of your error and the line in which the error is found.
And well…that ends this first exercise! Yay Me!
The extra credit part of this lesson involved going back into the code in the notepad and adding a # symbol to one of the lines of code. I did that and saved it and then ran the program. Apparently this symbol (which they call an octothorpe – I call it a pound or a hash tag) is used to comment out a line of code. When I ran the code the line I chose did not show up in the final program.
Well…this ends our lesson on programming Python for today. I will probably come back later tonight and finish the next lesson with you.
Recommended Posts

713-397-3833
December 6, 2022

What Are Google Posts and How Can I Use Them?
August 26, 2022

Megadeth Christmas Cards
June 23, 2022