anonymous
  • anonymous
Hi. I just started the 6.00 Computer Science course, and I have a small programming issue. I tried to type the professor's code used in the lecture manually (the PDF for the link failed) and only the first part to the program showed. What I typed: x = int(raw_input('Enter an integer ')) if x%2 == 0: print 'Even' else: print 'Odd' if x%3 != 0: print 'And not divisible by 3' What it gave me: Enter an integer When you enter an integer, the program finishes. Nothing else happens. What is wrong? I know the exclamation point is likely incorrect...
MIT 6.00 Intro Computer Science (OCW)
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
Additionally, whenever I insert a premade program into python that has 2 lines (input, assignment) only the print section of the program works. Nothing else. For example, in this premade program: name = raw_input('What is your name?\n') print 'Hi, %s.' % name It says 'what is your name' but stops there.
rsmith6559
  • rsmith6559
The only problem that I see in your first program is that the 2 lines dealing with three shouldn't be part of the else block. It's interesting that both programs have an issue with raw_input(). Are you using Python v3.x? AFAIK, the course requires Python v2.x.
anonymous
  • anonymous
I'm using 2.5.4. Is that not the correct verson? This is what happens: >>> x = int(raw_input('Enter an integer ')) if x%2 == 0: print 'Even' else: print 'Odd' if x%3 != 0: print 'And not divisible by 3' Enter an integer 23 >>> What do you mean by "the three should not be part of the else block?"

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

rsmith6559
  • rsmith6559
2.5.4 is the recommended version for the 6.00 course from 2008. There's a 6.00 course from, I think, 2010, and I'm not sure which version that recommends. What I see in your reply is that you're not putting this code in iDLE, but in the shell, which is geared mostly toward single line commands: >>> x = int(raw_input('Enter an integer ')) Enter an integer 5 >>> print x 5 >>>
anonymous
  • anonymous
How do you put the code into idle? The download only came with two things: the shell, and a black window, as well as a guide. Does iDLE need to be downloaded separately?
rsmith6559
  • rsmith6559
Actually, you don't HAVE to have iDLE. I don't use it because it was changing my tabs to spaces and giving me errors. You need to put this code into a plain-text editor. Examples would be notepad on PCs, TextEdit can be used on Mac, but you have to be careful when you save it. The editor that comes with Adobe CS, XCode. And the command line editors vi, emacs and nano. Then you can execute with a command like: python myprogram.py. This was a way to quick intro to this stuff.
anonymous
  • anonymous
Ohhh. I get it. You have to execute the program by using F5. IDLE is just a sort of notepad-like thing that automatically tabs for you and hilights. Thanks much for your help! I'll probably need it in the future :D
rsmith6559
  • rsmith6559
Feel free.
anonymous
  • anonymous
open python shell gui. on top, click file, then new window. type code. file, save as. save with.py after the name of the file. close all python windows, open python shell gui again. file, open, find ur file. to execute, press f5 and save changes. the results appear in the shell window.

Looking for something else?

Not the answer you are looking for? Search for more explanations.