Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Studying Computer Science in College, help

Featured Replies

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!

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?

polvCwJ.gif
"It's not a rest for me, it's a rest for the weights." - Dom Mazzetti

  • Author

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()

   a,b,c=eval(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()


 

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

What's the error that you get?

 

Just looking at it, you may need to convert the parameters a,b, and c to floats.

polvCwJ.gif
"It's not a rest for me, it's a rest for the weights." - Dom Mazzetti

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 or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.