Newbie feeling pretty stupid.

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Newbie feeling pretty stupid.

Postby LCD Tom » Fri May 25, 2012 8:27 pm UTC

I'm completely new to coding and programming, but I've wanted to get into it for a while. Yesterday I finally watched the MIT OCW video for the first class, taking notes religiously the whole time. I got my Python 2.7.2 up and running and attempted the first assignment, outlined here:

http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/

And that's when I realized that I must be coming short on some fundamental level. No matter what I do, I can't seem to find a way to simply execute a program. I can bind values to variables (myString = 'eric') and other such basic stuff, but I can't for the life of me figure out how to create a program that asks for a first and last name. I've attempted to look up several help guides for this specific assignment. The problem, though, is that many of them assume I already have some unidentifiable basic knowledge that I just can't seem to get my hands on.

1) How do I set up a program?
2) How do I trigger it to execute?
3) How in the hell do I tackle this frustratingly simple yet dauntingly unattainable goal?

Names have never made me so mad before. As I said in the post title, I feel mediocre and idiotic at the moment. I knew should've never branched away from the humanities. Ask me about nineteenth century British politics or French decolonization and I'll tell you everything. Ask my why a singular they should totally be A-OK and I'll talk for hours and find the nearest computer to look up the sources I remember. But ask me to produce infantile coding and I'll break down in sobs. Maybe there's just something that's not "clicking," or maybe I need more intuition and talent for this.

Not to say I'm giving up. This assignment is now a blood mission for me.

I'm begging you. Please, please help me to fill the fundamental conceptual gaps in my base understanding of code and figure out how I can do this most basic task.
LCD Tom
 
Posts: 1
Joined: Thu May 24, 2012 4:27 pm UTC

Re: Newbie feeling pretty stupid.

Postby Ben-oni » Sun May 27, 2012 12:01 pm UTC

The assignment included this link, which explains input and output in python. And it provides plenty of samples. Go ahead and open the python interpreter, and type some in, and see what they do. A lot of learning is like that: you try things out, and see what it does. See what works, see what doesn't. Try to figure out what the difference is so that you know why.

To run a program, the code should be in a file, "program.py", or something similar. From the command line, type "python program.py" to run it, assuming python is in the current $PATH, and assuming you know what a command line is.

Actually, I guess I should ask that first. Do you know how to run the python interpreter?
Ben-oni
 
Posts: 268
Joined: Mon Sep 26, 2011 4:56 am UTC

Re: Newbie feeling pretty stupid.

Postby Snark » Sun May 27, 2012 12:58 pm UTC

I started teaching myself Python yesterday. Here's how I finally managed to execute a program.

Edit: Step 0) Download Python
1. Open IDLE (Python GUI)
2. Click File-New Window or press Ctrl+N
3. Type up your program in the new window.
4. Save (with a .py extension if it doesn't give you that extension automatically)
5. Click Run-Run Module or press F5

The program will run in the original window (the shell).

I never could get the python program.py method to work, and that seems like more trouble than the method I discovered anyways.
DaBigCheez wrote:Because I totally think Snark's the kind of guy who could pull off a stunt like "let teammate get vigkilled by your drone D1, to make yourself a "confirmed town" for not going against it, then pick off everyone while laughing about it."
User avatar
Snark
 
Posts: 317
Joined: Mon Feb 27, 2012 3:22 pm UTC
Location: Washington D.C.

Re: Newbie feeling pretty stupid.

Postby Jplus » Sun May 27, 2012 1:23 pm UTC

For the Windows users: Python doesn't install itself into your %PATH% by default, so you can't run 'python' from the command prompt. However, the Python installer does tell Windows that it can open .py and .pyw files. So you can save your Python program with a .py extension and run it from the command prompt by just entering the name of the file. For example, if you wrote the 'Hello World' program and you saved it in 'hello.py' in your Documents folder, do this:

  1. Open the command prompt.
  2. Type 'cd Documents' (on Vista and later) or 'cd "My Documents"' (on XP and earlier) and hit enter.
  3. Type 'hello.py' and hit enter.

Tip: you can also just double-click the file from the Explorer in order to run it. By default, the command prompt window will close as soon as the program is finished. You can prevent this by giving the file a .pyw extension.
Hey, like coding? Perhaps you should check out the red spider project.
Feel free to call me Julian. J+ is just an abbreviation.
User avatar
Jplus
 
Posts: 1091
Joined: Wed Apr 21, 2010 12:29 pm UTC

Re: Newbie feeling pretty stupid.

Postby troyp » Sun May 27, 2012 11:50 pm UTC

The very first steps in programming can be the hardest, when you have no idea what you're doing (and even when you've been programming a while, setting up a new environment can be frustrating). Don't let it get you down.

We can give you specific advice, but you'll have to explain exactly what steps you're taking when you try to save and run a program. If I had to guess, I'd say you may be trying to save a program from IDLE's "shell" window, rather than an editor window. If you're working directly in IDLE, the default window is for interactive commands, not for typing in a program to save. To enter a program, you need to choose the "new" or "open" items from the menu to get an editor window ("open" if it already exists, "new" otherwise). You'll notice the new window doesn't have a prompt and doesn't do anything when you hit return - it's just a text editor. You can enter and save your program there and choose "run->run Module" from the editor window menu, which will run your program and leave you in the interactive shell.

The other way to do it is to use a regular text editor and the command line (you should be able to find a newbie's guide to this pretty easily.)
troyp
 
Posts: 398
Joined: Thu May 22, 2008 9:20 pm UTC
Location: Lismore, NSW

Re: Newbie feeling pretty stupid.

Postby wumpus » Fri Jun 22, 2012 7:50 pm UTC

I don't think it has been mentioned yet, but make sure that whatever text you are trying to learn from is for Python 2.x since you downloaded 2.7. If your text is for 3.x, either get a new text or update Python to 3.x

Personally, I couldn't stand 3.0 and ran screaming back to 2.x, but my problems were due to trying to mix C/C++ with Python, something a newbie rarely needs to do.
wumpus
 
Posts: 202
Joined: Thu Feb 21, 2008 12:16 am UTC


Return to Coding

Who is online

Users browsing this forum: No registered users and 10 guests