Question

Demonstrate this result for the parallel calculation. CODE: from Tkinter import * # MODIFY THIS TO...

Demonstrate this result for the parallel calculation.

CODE:

from Tkinter import *
# MODIFY THIS TO HANDLE THREE RESISTORS

__author__ = "robincarr"

""" GUI version of Resistor Calculator finds the equivalent resistance for two resistors
connected either in series or parallel. Features entry widgets and buttons."""



def series_calculation():
    r1 = float(resistor1.get())
    r2 = float(resistor2.get())
    req = r1 + r2
    equivalent_resistance.delete(0, END)  # Clear the previous result.
    equivalent_resistance.insert(0, req)
    print("Resistor 1: %s\nResistor 2: %s" % (r1, r2))
    print "The equivalent series resistance is: ", req, "\n"


def parallel_calculation():
    r1 = float(resistor1.get())
    r2 = float(resistor2.get())
    req = r1 * r2 / (r1 + r2)
    equivalent_resistance.delete(0, END)  # Clear the previous result.
    equivalent_resistance.insert(0, req)
    print("Resistor 1: %s\nResistor 2: %s" % (r1, r2))
    print "The equivalent parallel resistance is: ", req, "\n"


root = Tk()
root.title("Resistor Calculator")

Label(root, text="Resistor 1").grid(row=0)
Label(root, text="Resistor 2").grid(row=1)
# 1. Add a label for the third resistor here in row 2.

resistor1 = Entry(root)  # Entry widget for Resistor 1.
resistor2 = Entry(root)  # Entry widget for Resistor 2.
# 2. Add an entry widget for Resistor 3 here.


resistor1.grid(row=0, column=1)  # Specify the location in the grid layout.
resistor2.grid(row=1, column=1)  # Specify the location in the grid layout.
# 3. Place resistor 3 here.

# 4 Now adjust the calculation callbacks to handle three resistors instead of 2.




# All that follows has already been shifted down one row for your convenience.

seriesButton = Button(root, text='Series', command=series_calculation)
seriesButton.grid(row=3, column=0, sticky=W, pady=4)


Button(root, text='Parallel', command=parallel_calculation).grid(row=3, column=1, sticky=W, pady=4) # Added
Button(root, text='QUIT', command=root.quit).grid(row=3, column=2, sticky=W, pady=4)  # Added


Label(root, text="Equivalent Resistance").grid(row=4) # Added

equivalent_resistance = Entry(root)
equivalent_resistance.grid(row=4, column=1) # Added

root.mainloop()
0 0
Add a comment Improve this question Transcribed image text
Answer #1

from Tkinter import *
# MODIFY THIS TO HANDLE THREE RESISTORS

__author__ = "robincarr"

""" GUI version of Resistor Calculator finds the equivalent resistance for two resistors
connected either in series or parallel. Features entry widgets and buttons."""

def series_calculation():
r1 = float(resistor1.get())
r2 = float(resistor2.get())
r3 = float(resistor3.get())
req = r1 + r2 + r3
equivalent_resistance.delete(0, END) # Clear the previous result.
equivalent_resistance.insert(0, req)
print("Resistor 1: %s\nResistor 2: %s\nResistor 3: %s" % (r1, r2, r3))
print "The equivalent series resistance is: ", req, "\n"


def parallel_calculation():
r1 = float(resistor1.get())
r2 = float(resistor2.get())
r3 = float(resistor3.get())
req = (r1 * r2 * r3 )/ (r1 * r2 + r2 * r3 + r3 * r1)
equivalent_resistance.delete(0, END) # Clear the previous result.
equivalent_resistance.insert(0, req)
print("Resistor 1: %s\nResistor 2: %s\nResistor 3: %s" % (r1, r2, r3))
print "The equivalent parallel resistance is: ", req, "\n"


root = Tk()
root.title("Resistor Calculator")

Label(root, text="Resistor 1").grid(row=0)
Label(root, text="Resistor 2").grid(row=1)
Label(root, text="Resistor 3").grid(row=2)
# 1. Add a label for the third resistor here in row 2.

resistor1 = Entry(root) # Entry widget for Resistor 1.
resistor2 = Entry(root) # Entry widget for Resistor 2.
resistor3 = Entry(root) # Entry widget for Resistor 3.
# 2. Add an entry widget for Resistor 3 here.


resistor1.grid(row=0, column=1) # Specify the location in the grid layout.
resistor2.grid(row=1, column=1) # Specify the location in the grid layout.
resistor3.grid(row=2, column=1) # Specify the location in the grid layout.
# 3. Place resistor 3 here.

# 4 Now adjust the calculation callbacks to handle three resistors instead of 2.

# All that follows has already been shifted down one row for your convenience.

seriesButton = Button(root, text='Series', command=series_calculation)
seriesButton.grid(row=3, column=0, sticky=W, pady=4)


Button(root, text='Parallel', command=parallel_calculation).grid(row=3, column=1, sticky=W, pady=4) # Added
Button(root, text='QUIT', command=root.quit).grid(row=3, column=2, sticky=W, pady=4) # Added


Label(root, text="Equivalent Resistance").grid(row=4) # Added

equivalent_resistance = Entry(root)
equivalent_resistance.grid(row=4, column=1) # Added

root.mainloop()

Add a comment
Know the answer?
Add Answer to:
Demonstrate this result for the parallel calculation. CODE: from Tkinter import * # MODIFY THIS TO...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python 3 Code does not save the data into excel properly ​​​​​​​ # required library import...

    Python 3 Code does not save the data into excel properly ​​​​​​​ # required library import tkinter as tk from tkcalendar import DateEntry import xlsxwriter # frame window = tk.Tk() window.title("daily logs") #window.resizable(0,0) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=3, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money = tk.Entry(window) # arraging barcode.grid(row=0, column=1) product.grid(row=1, column=1) money.grid(row=2, column=1) cal =...

  • Python 3 Fix the code so if the user enter the same bar code more than...

    Python 3 Fix the code so if the user enter the same bar code more than three times, it shows a warning message indicating that the product was already tested 3 times and it reached the limits Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window,...

  • The Gui has all the right buttons, but from there i get lost. I need to...

    The Gui has all the right buttons, but from there i get lost. I need to know whats wrong with my assignment can someone please help. The code I have so far is listed below, could you please show me the errors in my code. PYTHON Create the GUI(Graphical User Interface). Use tkinter to produce a form that looks much like the following. It should have these widgets. Temperature Converter GUI Enter a temperature (Entry box)                 Convert to Fahrenheit...

  • Python 3 How to change the icon in the error message want to put a yellow...

    Python 3 How to change the icon in the error message want to put a yellow warning icon import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product =...

  • Help with Python code. Right now I'm creating a code in Python to create a GUI....

    Help with Python code. Right now I'm creating a code in Python to create a GUI. Here's my code: #All modules are built into Python so there is no need for any installation import tkinter from tkinter import Label from tkinter import Entry def calculatewages(): hours=float(nhours.get()) nsal=float(nwage.get()) wage=nsal*hours labelresult=Label(myGUI,text="Weekly Pay: $ %.2f" % wage).grid(row=7,column=2) return Tk = tkinter.Tk()    myGUI=Tk myGUI.geometry('400x200+100+200') myGUI.title('Pay Calculator') nwage=float() nhours=float() label1=Label(myGUI,text='Enter the number of hours worked for the week').grid(row=1, column=0) label2=Label(myGUI,text='Enter the pay rate').grid(row=2, column=0)...

  • Using Matlab When several resistors are connected in an electrical circuit in parallel, the current through...

    Using Matlab When several resistors are connected in an electrical circuit in parallel, the current through each of them is given by in=vs/Rnwhere in and Rn are the current through resistor n and its resistance, respectively, and vs is the source voltage. The equivalent resistance, Req, can be determined from the equation 1/Req=1/R1+1/R2+1/R3+.......+1/Rn. The source current is given by is , and the power, Pn, dissipated in each resistor is given by . is=vs/Req, and Pn=vsin. Write a program in...

  • e circuit below includes 3 resistors in parallel, R1 = 1 kQ, R2 = 2 kQ,...

    e circuit below includes 3 resistors in parallel, R1 = 1 kQ, R2 = 2 kQ, and R,-4kD ta) Dmine the equivalent resistance (Req), (b) use Ohm's Law to determine the circuit current, a use Ohm's law to determine the current through each resistor R1 R2 R3

  • Three Resistors in Parallel Three resistors are connected in parallel as shown in figure (a). A...

    Three Resistors in Parallel Three resistors are connected in parallel as shown in figure (a). A potential difference of 12.0V is maintained between points a and b. Three resistors connected in parallel. The Another circuit with three resistors and a voltage across each resistor is 12.0 V. battery. Is it equivalent to the circuit in (a)? a Ž 3.00 6.00 9.00 3.00 6.00 09.00 (a) Calculate the equivalent resistance of the circuit. SOLUTION Conceptualize Figure (a) shows that we are...

  • Task 1 The equivalent resistance Req of four resistors R1, R2, R3 and R4 connected in series is g...

    Use MATLAB to solve these problems, thank u Task 1 The equivalent resistance Req of four resistors R1, R2, R3 and R4 connected in series is given as eq.series R1 R2 R3 R4. The equivalent resistance Req of four resistors R1, R2, R3 and R4 connected in parallel is given as q.parallel K1R2R3 R Write an m-file that does the following in order: Prompt the user for the type of connection (e.g. user should enter "1" for series and "2"...

  • Please, I need help, I cannot figure out how to scan variables in to the function...

    Please, I need help, I cannot figure out how to scan variables in to the function prototypes! ******This is what the program should look like as it runs but I cannot figure out how to successfully build the code to do such.****** My code: #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <conio.h> float computeSeriesResistance(float R1, float R2, float R3); float computeParallelResistance(float R1, float R2, float R3); float computeVoltage(int current, float resistance); void getInputR(float R1, float R2, float R3); void getInputCandR(int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT