Jump to content





Photo

My Very First Python Program [U]

Posted by le717 , in Triangular Minifigure Blog 06 January 2013 · 356 views

THIS PROGRAM WAS WRITTEN BY A BEGINNER PROGRAMMER. YOU WILL FIND IT TO BE VERY BASIC, AND NOT VERY USEFUL TO YOU. YOU HAVE BEEN WARNED.



It's more of a test program than a useful program, but it is my nevertheless my first program.

I call it Basic Shapes. It calculates the Perimeter and Area of a Triangle, Circle, Rectangle, and Square. Some of the shapes have other calculations attached to them. I also have an Easter egg thrown in (Hint: a 2x4 ____ brick).

I wrote it in Python 3.3 using IDLE (IDLE is horrible), and compiled x86 and x64 Windows EXEs using cx_freeze (why, since this is just a test, who knows). The Python script has no dependencies other than a Python interpreter. I did run it on Python 2.7, but it did not work (which is odd, since it is such a simple script). The EXEs also have no dependencies other than the files in the same folder as the EXE.

As of V1.1, all bugs have been fixed, and now works as I had originally planned.

Download Basic Shapes V1.1 from Sourceforge.net.

Special thanks to JrMasterModelBuilder for helping me set up the multiple Python installations correctly, for looking at my code because I thought it was broken, and just putting up with me and all my annoying questions! ;P

Update: I've basically rewritten the script, fixed it up a bit and correcting the bugs. If you care, get the updated version from the link above.



print """
This text will be formated as you see it.
You can write any number of lines with only one call to print.
If you still insist on putting newlines, \"print 'herpderp' +/n\" works.
You also don't need parenthesis. """
Photo
JrMasterModelBuilder
Jan 07 2013 01:27 AM
@TheDoctor: You need parenthesis in Python >= 3. It's also just good practice.

@TheDoctor: You need parenthesis in Python >= 3. It's also just good practice.

I feel that I need to say something about Python 3.x, but I don't know what. Maybe asking you what you can do that you can't in 2.7.x that's not related to syntax, but I still don't know.
Photo
JrMasterModelBuilder
Jan 09 2013 08:45 AM
It's cleaner, UTF8 support, bytes are treated as integers instead of chars (personal preference), nonlocal closure declaration, speed, new features are being added to 3 and not 2.
Plus, a lot of Python 2 stuff that kinda doesn't work too well has either been fixed, rewritten, or removed in Python 3. For example, raw_input() freezes FF with using it on Codecademy, and I've had issues with it on a computer before. In Python 3, it has been replaced with input(), which works much better. ;)
BTW, I've updated Basic Shapes to V1.1. It fixes the bugs, and have been overall fixed. If you want to, download it from the same link.

October 2014

S M T W T F S
      1234
567891011
12131415161718
192021 22 232425
262728293031 

Search My Blog

Recent Entries

Recent Comments

0 user(s) viewing

0 members, 0 guests, 0 anonymous users