# Studying Computer Science in College, help

## Recommended Posts

Hey guys, I'm a future computer science student but I need a bit of help.

Can anyone recommend me any good step by step guides/books/textbooks that will help me learn it?

My teacher this fall assigned us Python Programming: an introduction to computer science, but every time I type the examples into IDLE, they don't work. I've checked my syntax at least 15 times, entirely typing the script again and comparing side by side to no avail. It keeps saying there are errors when I have exactly what the author initially put down in the book.

So any GOOD tutorials/books are greatly appreciated, thanks!

##### Share on other sites

What error is it giving you? Be specific.

You'll also have to be more specific about exactly what kind of books you want. Python in particular? "It's not a rest for me, it's a rest for the weights." - Dom Mazzetti

##### Share on other sites

Sorry, I'm studying python first so those are the kinds of books and tutorials I'm looking for.

But here's one of the codes, written the same as the book, and it keeps getting a syntax error.

```# quadratic.py
# A program that computes the real roots of a quadratic equation.
# Illustrates use of the math library.
# Note: this program crashes if the equation has no real roots

import math   # makes the math library available
def main():
print("This program finds the real solutions to a quadratic")
print()

discRoot=math.sqrt(b*b-4*a*c)
root1=(-b+discRoot)/(2*a)
root2=(-b-discRoot)/(2*a)

print()
print("The solutions are: ",root1,root2)

main()

```

The first discRoot there keeps giving me an error...

##### Share on other sites

What's the error that you get?

Just looking at it, you may need to convert the parameters a,b, and c to floats. "It's not a rest for me, it's a rest for the weights." - Dom Mazzetti

##### Share on other sites

For a start, the main problem is that your input line is missing a ')'.

You need to use raw_input() instead of input()

And you should not use IDLE for implementations, only for testing new functions / odd bits. Set up your environment variable paths, and run your code from cmd, much easier.

```import math   # makes the math library available
def main():
print("This program finds the real solutions to a quadratic")
print()

a,b,c = eval(raw_input("Please enter the coefficients(a,b,c): "))
discRoot=math.sqrt((b*b)-(4*a*c))
root1=(-b+discRoot)/(2*a)
root2=(-b-discRoot)/(2*a)

print()
print("The solutions are: ",root1,root2)

main()```

## Create an account

Register a new account