Someone told me that Python is a good first language to learn, so I started learning it yesterday. I think I might fall in love with programming as time goes by...(adsbygoogle = window.adsbygoogle || []).push({});

Anyway, here's my first program. What it does is ask you for a line equation, and then a quadratic curve equation. It then tells you how many times the two lines meet, by first subtracting the line equation values from the curve equation values, and then finding the amount of roots by using the discriminant. I plan on adding some sort of function that shows you the coordinates of these lines of intersection.

Also, it cannot take line equations of the form x = n (ie, vertical lines), because of the cheap way I've programmed it.

I was wondering how I would take this program and make a Windows application out of it?

Anyways, just thought you might be interested! Here's the code:

I need more ideas for programs, otherwise I can't practice! Any cool ideas?Code (Text):# Discriminant finder

print "This program will tell you how many time a line crosses a quadratic curve."

print "Firstly, I need information about your line equation."

lm = input("What is its gradient? ")

lc = input("And what is its y-intercept? ")

print "Your line equation is y =", lm, "x +", lc

print "Now the curve."

qa = input("Firstly, what is its a value? ")

qb = input("And its b value? ")

qc = input("And its c value? ")

print "Thanks."

sb = qb-lm

sc = qc-lc

disc = (sb**2)-4*(qa*sc)

print "The discriminant is equal to ", disc

if disc > 0:

print "The line crosses the curve twice."

elif disc == 0:

print "The line is a tangent to the curve."

elif disc < 0:

print "The line doesn't cross the curve."

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Just wrote my first ever program! (few questions)

Loading...

Similar Threads for wrote ever program |
---|

Insights Intro to Algorithms for Programming - Comments |

C/++/# Ideas for a physics or math programming project? |

Program that calculates the list of x and f(x) for a given function |

C/++/# How to use C++ in studying calculus |

C/++/# Has anyone ever seen this std::endl quirk? |

**Physics Forums | Science Articles, Homework Help, Discussion**