Its not running

import math
import os

cls = os.system("cls")
title = os.system("title Pythagorean Theorum Solver")

def MainLoop():
    cls
    print "Enter 3 coordinate plane points (x - y) format"
    print ""

    firstPair = input("--> ")
    SecondPair = input("--> ")

    MathPart()

def MathPart():

    '''structure of the formula:

        squareRoot of --> (x-y)^2 + (x-y)^2

            '''
    
    g = (FirstPair ** 2) + (SecondPair ** 2)

    answer = float(math.sqrt(g))

    print "Your Answer is ", `answer`, "."
    raw_input()
    MainLoop()

Ouch!!!!!!!
A couple of hints ...

you still have to start with one function call from main

you need to pass your arguments to and from your functions

variable, function and class names are case sensitive in Python
firstPair and FirstPair are not the same

don't use capitalized names for functions, those are traditionally used for class names

give your functions meaningful names

not quite sure what your hangup is with clearing the screen, those things are OS specific


You need to read up on functions, try this here:
http://www.swaroopch.com/notes/Python_en:Functions

I don't understand why someone modded the OP down. He clearly showed effort in his homework, and has a legitimate newby question.

I redid my code and it worked. I did not understand how to do anything you suggest vegaseat and the link you gave did not help much :( im kind of lost with it i guess.

import math
import os

while 1:

    cls = os.system("cls")
    title = os.system("title Pythagorean Theorum Solver")

    print "Enter 2 values in (x - y) format"
    print ""
    FirstPair = input("--> ")
    SecondPair = input("--> ")

    '''structure of the formula:

    squareRoot of --> (x-y)^2 + (x-y)^2

    '''

    g = (FirstPair ** 2) + (SecondPair ** 2)

    answer = float(math.sqrt(g))

    print "Your Answer is ", `answer`, "."
    raw_input()

Well I managed to make my code run-able by elminating the use of functions, simply because I don't understand how to make variables work universally throughout functions, and some other stuff...

but yeah, I like to use things like cls and mode because im used-to another very simple, less powerful language that used those types of things.

I don't know anyone who uses linux nor do i associate with many mac users so I don't care much about OS specific commands.

I know you gave me a link vegas, but i didn't get it.

Here's my new working code:

import math
import os

while 1:

    cls = os.system("cls")
    title = os.system("title Pythagorean Theorum Solver")
    mode = os.system("mode con cols=35 lines=5")
    
    mode

    print "Enter 2 values in (x - y) format"
    print ""
    FirstPair = input("--> ")
    SecondPair = input("--> ")

    '''structure of the formula:

    squareRoot of --> (x-y)^2 + (x-y)^2

    '''

    g = (FirstPair ** 2) + (SecondPair ** 2)

    answer = float(math.sqrt(g))
    print ""
    print "Your Answer is ", `answer`, "."
    raw_input()

I redid my code and it worked. I did not understand how to do anything you suggest vegaseat and the link you gave did not help much :( im kind of lost with it i guess.

import math
import os

while 1:

    cls = os.system("cls")
    title = os.system("title Pythagorean Theorum Solver")

    print "Enter 2 values in (x - y) format"
    print ""
    FirstPair = input("--> ")
    SecondPair = input("--> ")

    '''structure of the formula:

    squareRoot of --> (x-y)^2 + (x-y)^2

    '''

    g = (FirstPair ** 2) + (SecondPair ** 2)

    answer = float(math.sqrt(g))

    print "Your Answer is ", `answer`, "."
    raw_input()

i was under the mistaken impression that you had to use functions

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.