Jump to content

The last poster wins


TheCalliton

Recommended Posts

I started scripting in Python after going through a tutorial or two and I must say, I'm getting pretty good at it. I just have to keep practicing. :thumbsup:

 

Already wrote a 120 lines long script for calculating resistor values for LED diodes, I'm just too lazy to calculate that in my head. :P

You go girl! :P

Link to comment
Share on other sites

 

I started scripting in Python after going through a tutorial or two and I must say, I'm getting pretty good at it. I just have to keep practicing. :thumbsup:

 

Already wrote a 120 lines long script for calculating resistor values for LED diodes, I'm just too lazy to calculate that in my head. :P

You go girl! :P

I have too much penis to be a girl. :wink:

 

 

 

In other news, I just finished the script. :dance: Since I'm still inexperienced in Python, I call a definition that requires "return" value while I use a "print" value for the end result. Works like a charm but it shows "None" at the end of the result, not a big deal for me.

 

Also reduced it down to 106 lines, removed some junk and worthless descriptions I used while I wrote it. Here's the script, it's the first portable LED resistor calculator I've seen so far, and I've been looking for one in quite a while:

 

 

 

#Definicija convertString za koristenje u formuli.

def convertString(str):

    try:

        returnValue = float(str)

    except ValueError:

        returnValue = bool(str)

    return returnValue



#Definicije i formule za razlicite spojeve.

#X je broj dioda u spoju.



#Osnovna formula (Vs - Vl) / I

def single(a, b, c, e):

    print "Resistor Value: ", (convertString(a) - convertString(b)) / convertString(c)

    print "Resistor wattage: ", (convertString(a) - convertString(b)) * convertString(c)

    print "Safe-to-use resistor wattage: ", ((convertString(a) - convertString(b)) * convertString(c)) * convertString(e)

    print "\n"



#Formula za racunanje serijskog spoja (Vs - (Vl * X)) / I

def serial(a, b, c, d, e):

    print "Resistor Value: ", (convertString(a) - (convertString(b) * convertString(d))) / convertString(c)

    print "Resistor wattage: ", (convertString(a) - (convertString(b) * convertString(d))) * convertString(c)

    print "Safe-to-use resistor wattage: ", ((convertString(a) - (convertString(b) * convertString(d))) * convertString(c)) * convertString(e)

    print "\n"

    

#Formula za racunanje paralelnog spoja (Vs - Vl) / (I * X)

def parallel(a, b, c, d, e):

    print "Resistor Value: ", (convertString(a) - convertString(b)) / (convertString(c) * convertString(d))

    print "Resistor wattage: ", (convertString(a) - convertString(b)) * (convertString(c) * convertString(d))

    print "Safe-to-use resistor wattage: ", ((convertString(a) - convertString(b)) * (convertString(c) * convertString(d))) * convertString(e)

    print "\n"



keepProgramRunning = True



#Izbornik sa spojevima i volazama dioda.

print "Welcome to Werne's LED Calculator!"

print " "

print "Common LED voltages:"

print " "

print "Infra-Red LED - 1.5V"

print "Red LED - 2.0V"

print "Orange LED - 2.0V"

print "Yellow LED - 2.1V"

print "Green LED - 2.2V"

print "Real Green LED - 3.3V"

print "Blue LED - 3.3V"

print "White LED - 3.3V"

print "Ultra-Violet LED - 3.3V"

print "Blue (430 nm) LED - 4.6V"

print "\n"



while keepProgramRunning:



    print " "

    print "Select type of connection:"

    print " "

    print "1: Single Diode"

    print "2: Serial connection"

    print "3: Paralell connection"

    print "4: Close program"    



    #Skripta izbornika.

    choice = raw_input()



    #Jedna dioda.

    if choice == "1":

        numberA = raw_input("Enter source voltage: ")

        numberB = raw_input("Enter diode voltage: ")

        numberC = raw_input("Enter diode current in ampers: ")

        numberE = float(1.6)

        print " "

        print single(numberA, numberB, numberC, numberE)

        print "\n"

        

        #Serijski spoj.

    elif choice == "2":

        numberA = raw_input("Enter source voltage: ")

        numberB = raw_input("Enter diode voltage: ")

        numberC = raw_input("Enter diode current in ampers: ")

        numberD = raw_input("Enter number of diodes: ")

        numberE = float(1.6)

        print " "

        print serial(numberA, numberB, numberC, numberD, numberE)

        print "\n"

        

        #Paralelan spoj.

    elif choice == "3":

        numberA = raw_input("Enter source voltage: ")

        numberB = raw_input("Enter diode voltage: ")

        numberC = raw_input("Enter diode current in ampers: ")

        numberD = raw_input("Enter number of diodes: ")

        numberE = float(1.6)

        print " "

        print parallel(numberA, numberB, numberC, numberD, numberE)

        print "\n"

        

        #Izlaz.

    elif choice == "4":

        print "Goodbye."

        keepProgramRunning = False

        

        #Za kretene.

    else:

        print "Please, choose one of the options given."

        print "\n"

 

 

And only Iv000 and I will understand the description lines, unless someone else knows Croatian too.

Link to comment
Share on other sites

I have too much penis to be a girl. :wink:

 

I know guys with vaginas and girls with penises :teehee: My best friend is trans FtM actually and more manly than 97% of the guys I know xD

Oh genetics, u so funny.

 

 

 

In other news, I just finished the script. :dance: Since I'm still inexperienced in Python, I call a definition that requires "return" value while I use a "print" value for the end result. Works like a charm but it shows "None" at the end of the result, not a big deal for me.

 

Also reduced it down to 106 lines, removed some junk and worthless descriptions I used while I wrote it. Here's the script, it's the first portable LED resistor calculator I've seen so far, and I've been looking for one in quite a while:

 

I was impressed by that code :D though I guess since you finished engineering or something I shouldn't be surprised.

 

 

and also

 

 

 

#Za kretene.

 

else:

 

print "Please, choose one of the options given."

 

print "\n"

 

Didn't expect that and made me lol ;D

Link to comment
Share on other sites

I was impressed by that code :biggrin: though I guess since you finished engineering or something I shouldn't be surprised.

Electro-mechanical engineering, finished it with second highest grades in my class. :cool:

 

People and my IQ tests say I'm smart. Clinically insane, but smart. :happy:

 

 

 

#Za kretene.

 

else:

 

print "Please, choose one of the options given."

 

print "\n"

Didn't expect that and made me lol ;D

That is an acceptable and accurate description of that part of the script. :yes: If a man has four choices, he can't choose the fifth. If he does that, I described him correctly. :biggrin:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...