Working with Microsoft stuff is incredibly painful and not fun. The same is true for doing Oracle DBA stuff. However, if you decide to learn any of these boring and painful technologies, you will have opportunity to make lots of money if you are willing to move to a major city.
I live in Queens, NY. Money is fun to spend, but I'll play around with a few of the languages before I ultimately decide. Definitely starting with Python though.
My 2 cents. Yes it is possible to major in CS if you have no background in programming. Depending on where you are going, how sharp you are, and possibly how good you are in math. CS programs differ between colleges. Some are easier/different than others. In my situation, years and years ago, the CS program where I went was really split between Letters Arts &Sciences and Engineering. It was back in the time BW (Before Windows), so things were a bit different in the colleges knowing "what CS was about". So I had to take both Science and Math classes for the degree. The math was the bane of my existence because I was weak on it from high school. Specifically Calculus (bah). It may be different now.
The way I see it, the classes for the CS Major aren't really there to teach you specific languages/technologies. They're there to teach you the thought processes and give you a background to learn multiple things. Sure it's nice to learn VB or C# or whatever. However, the intent is really to give you the background that will enable you to pick up VB, C#, C++, etc. for whatever project you need, fairly quickly. Set theory, boolean logic, basic algorithims, object oriented theory, basic understanding of compilers, etc. don't change between languages. If you don't have any problems understanding those things, you'll do fine in CS. If you have problems understanding it (it just doesn't click) look for another major.
Incidentally, I haven't used Calculus since college...
I have a question regarding one of the exercises in the book.
Write a function named check fermat that takes four parameters—a, b, c and n—and that checks to see if Fermat’s theorem holds. If n is greater than 2 and it turns out to be true that "an + bn = cn". the program should print “Holy smokes, Fermat was wrong!†Otherwise the program should print “No, that doesn’t work.â€Â
So, I figured out how to write an if statement that would do the math part of the problem but you can't put an if statement inside of a function. Or, at least it hasn't let me yet. Is there another way to solve the problem? Did I go above and beyond the needs of the problem, like I usually do?
For the record, here's what I've come up with:
a=2;b=3;c=4;n=5 fermat_false=a**n+b**n==c**n fermat_true=a**n+b**n!=c**n if fermat_false print 'Holy smokes, Fermat was wrong!' elif fermat_true print 'No, that doesn’t work.'
In other news, I've actually enjoyed myself so far. I just really want to solve this problem, so in case of it coming up later, I know what I should be doing. Thanks for recommending the book.
Here is what I would do in pseudocode: function fermat (int a, int b, int c, int n) if n>2 if a*n+b*n==c*n print "Holy smokes, Fermat was wrong!" else print "No, that doesn't work"
Ditto. And from what I see, Fermat is wrong when a+b=c? Anyways, draw from WiP's code condensation. Condense your code. Your try is slightly confusing and might cause problems.
Wait:
If an integer n is greater than 2, then the equation an + bn = cn has no solutions in non-zero integers a, b, and c.
You need to the power. Don't know how that's done in Python. Probably also just with the ^.
Woot! I've never even done Python and with a bit of research I found the problem. You forgot the semicolons.
!!The slashes are not part of the program. The code tag seems to put them there for some odd reason. Ignore them.!!
a=2;b=3;c=4;n=5 fermat_false=a**n+b**n==c**n fermat_true=a**n+b**n!=c**n if fermat_false: print 'Holy smokes, Fermat was wrong!' elif fermat_true: print 'No, that doesn’t work.'
However, this still is not the correct answer to the problem, because we have a fixed variable here, and the problem wants you to say n>2. So for that I think it would be something like this:
a=2;b=3;c=4;n=5 fermat_false=a**n+b**n==c**n fermat_true=a**n+b**n!=c**n if n>2: if fermat_false: print 'Holy smokes, Fermat was wrong!' elif fermat_true: print 'No, that doesn’t work.' else: print 'That isn’t even Fermat’s theorem!'
This still doesn't include setting your own variables, but it's close. Whatever you have the variable's defined as, it checks to see if it even applies to the theorem. If you have the variable defined in the shell, it uses those.
Edit: You don't have to define the other variables, only n, because the other's don't have any effect since we are testing true and false. Edit 2: You don't have to define any variable's in the program, if you got that impression, but I meant in the shell.
a=2;b=3;c=4;n=5; fermat_false=a**n+b**n==c**n fermat_true=a**n+b**n!=c**n def check_fermat(): if fermat_false: print 'Holy smokes, Fermat was wrong!' elif fermat_true: print 'No, that doesn\'t work.'
print check_fermat
The if statement works within the function. Vhdblood was half right . . . I was missing colons, not semicolons. Now I have one more issue. When the function is put through the interpreter, it doesn't actually print any of the statements. It gives me this back instead.
-function check_fermat at 0x00D3D830-
Last piece of the puzzle missing is how to get it to actually announce if the equation works or not.
Try this: def fermat(a,b,c,n): if n>2: if a*n+b*n==c*n: print "Holy smokes! Fermat was wrong!" else: print "No, that does not work." else: print "n is not large enough."
You have to remember that Python uses whitespace to deliniate your program blocks. So make sure you make all of your indentation correct.
Yeah, you are printing the memory address of the function, not executing it. Remember to pass in variables as well if you are taking in arguments in your function.
a=2;b=3;c=4;n=5; def fermat(a,b,c,n): if n>2: if a**n+b**n==c**n: print "Holy smokes! Fermat was wrong!" elif a**n+b**n!=c**n: print "No, that does not work." fermat(a,b,c,n)
Thank you WiP. The above works perfectly. Now to work backwards and make sure I understand why that works.
Yeah, I totally meant colon, as you can see in my code blocks.
The only question I have is, why do you have to define fermat? This function works fine without defining it. I guess it would be useful to use later.
Edit: Nevermind. I see now.
Edit 2: The only things I see wrong with that are that you don't have it whitespaced, and you don't have a second else, so in theory the program would either die or put out nothing if you tried to make N 2 or less.
I'm glad you started doing this. My interest is peaked because you are asking questions. Normally, I can never get myself to sit down and learn to code, but when presented with a question, I seem to be ready for an all-nighter.
I know what you mean. However, and I feel like an idiot for having to say this, I have no idea what the hell is going on in the next chapter [chapter 4]. I downloaded the module but I have no idea how to load it. I feel brain dead because I know it has to be some simple thing I'm missing.
What are you using to code Python in? I downloaded Vim and couldn't use it, it was just too in depth and I may go back to it later, but for now I'm using the official Python program. If you're using that, you can just right click on the .py file and click Open in IDLE. That works for me.
You know this is redundant, right? There's no third option in the if statement, so you can do with just 'else' and weed out potential problems with it.
As for loading a module, it's discussed, or it will be. Backtrack a bit, perhaps you've not remembered something mentioned earlier because it wasn't needed back then.
I'm glad to see you're making progress. One thing I consider worth addressing is the flexibility of your first two years. Most colleges expected you to try things out before you choose a major. Students change their majors once, at the very least. So, go ahead and major in CS. If you don't like it then become an English major. It seems to be what most people do.
I'm glad to see you're making progress. One thing I consider worth addressing is the flexibility of your first two years. Most colleges expected you to try things out before you choose a major. Students change their majors once, at the very least. So, go ahead and major in CS. If you don't like it then become an English major. It seems to be what most people do.
I disagree. There might be some schools where changing majors doesn't hurt you, but in my experience changing majors hurts a lot. Depending on which major you change from/to, and when you change, you could end up being stuck in school for one or two extra years before graduating. Also think of the money that costs. Also, if you go to school without declaring a major, most of the classes you will take are useless. Schools just do that to encourage you to give them money.
My suggestion is that if you are undecided you should only be going to cheap community college, or state school at the most. Don't go to an expensive "real" school until you are ready to declare a major, and are sure you want to stick with it.
In other news, at the end of chapter 4, the example has to do with drawing flowers using a program called TurtleWorld. After like an hour in front of my monitor trying to figure out what to do with the code I finally got code that can draw flowers. However, they look nothing like the pictures in the book. They look like a crackhead with Altzheimer's drew them. It's probably just my math. Should I just move on or continue working til I get it perfect?
I know it has to be my math that's wrong. I haven't done more than simple math while working on a register in a long time. The god forsaken code is right, I'm sure of that much. Thing is, I know I would get this rush of endorphins if I could just draw this damn flower. A hint would be thoroughly appreciated.
Maybe you can use some polar coordinates? Is there an interface for that? I used a version of turtleworld within a learning IDE called Greenfoot. If you can use polar coordinates something like r = cos(2(theta)) will make a flower.
I haven't tried using the sine, cosine, tangent things yet. Thought about it but I just don't remember enough of the math involved for me to know how to write the equation. I really hope there's a refresher course for that stuff in college.
Another question for you guys. I remember it being discussed in an episode before, I forget which exactly, but how big is the difference between a BA in Computer Science and a BS in Computer Science? As far as I understand it, course-wise, the difference is a few classes. Do employers really take note of that?
Another question for you guys. I remember it being discussed in an episode before, I forget which exactly, but how big is the difference between a BA in Computer Science and a BS in Computer Science? As far as I understand it, course-wise, the difference is a few classes. Do employers really take note of that?
A BA in CS is worthless. If a school is offering a BA that usually means that their program could not be accredited. Someone hiring programmers might not know the difference. However, if the person hiring actually knows their shit, they will know that a BA in CS basically means you got a CS degree from a crummy school.
Comments
The way I see it, the classes for the CS Major aren't really there to teach you specific languages/technologies. They're there to teach you the thought processes and give you a background to learn multiple things. Sure it's nice to learn VB or C# or whatever. However, the intent is really to give you the background that will enable you to pick up VB, C#, C++, etc. for whatever project you need, fairly quickly. Set theory, boolean logic, basic algorithims, object oriented theory, basic understanding of compilers, etc. don't change between languages. If you don't have any problems understanding those things, you'll do fine in CS. If you have problems understanding it (it just doesn't click) look for another major.
Incidentally, I haven't used Calculus since college...
For the record, here's what I've come up with: In other news, I've actually enjoyed myself so far. I just really want to solve this problem, so in case of it coming up later, I know what I should be doing. Thanks for recommending the book.
function fermat (int a, int b, int c, int n)
if n>2
if a*n+b*n==c*n
print "Holy smokes, Fermat was wrong!"
else
print "No, that doesn't work"
Wait: You need to the power. Don't know how that's done in Python. Probably also just with the ^.
!!The slashes are not part of the program. The code tag seems to put them there for some odd reason. Ignore them.!!
a=2;b=3;c=4;n=5
fermat_false=a**n+b**n==c**n
fermat_true=a**n+b**n!=c**n
if fermat_false:
print 'Holy smokes, Fermat was wrong!'
elif fermat_true:
print 'No, that doesn’t work.'
However, this still is not the correct answer to the problem, because we have a fixed variable here, and the problem wants you to say n>2. So for that I think it would be something like this:
a=2;b=3;c=4;n=5
fermat_false=a**n+b**n==c**n
fermat_true=a**n+b**n!=c**n
if n>2:
if fermat_false:
print 'Holy smokes, Fermat was wrong!'
elif fermat_true:
print 'No, that doesn’t work.'
else:
print 'That isn’t even Fermat’s theorem!'
This still doesn't include setting your own variables, but it's close. Whatever you have the variable's defined as, it checks to see if it even applies to the theorem. If you have the variable defined in the shell, it uses those.
Edit: You don't have to define the other variables, only n, because the other's don't have any effect since we are testing true and false.
Edit 2: You don't have to define any variable's in the program, if you got that impression, but I meant in the shell.
def fermat(a,b,c,n):
if n>2:
if a*n+b*n==c*n:
print "Holy smokes! Fermat was wrong!"
else:
print "No, that does not work."
else:
print "n is not large enough."
You have to remember that Python uses whitespace to deliniate your program blocks. So make sure you make all of your indentation correct.
check_fermat()
The only question I have is, why do you have to define fermat? This function works fine without defining it. I guess it would be useful to use later.
Edit: Nevermind. I see now.
Edit 2: The only things I see wrong with that are that you don't have it whitespaced, and you don't have a second else, so in theory the program would either die or put out nothing if you tried to make N 2 or less.
As for loading a module, it's discussed, or it will be. Backtrack a bit, perhaps you've not remembered something mentioned earlier because it wasn't needed back then.
My suggestion is that if you are undecided you should only be going to cheap community college, or state school at the most. Don't go to an expensive "real" school until you are ready to declare a major, and are sure you want to stick with it.