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 Fix the code so when i click on submit botton the values reset Code:...

    Python 3 Fix the code so when i click on submit botton the values reset 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, 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="Working product").grid(row=4, sticky="W", pady=20, padx=20) #Working product label tk.Label(window, text="Failed...

  • 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 =...

  • 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...

  • 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)...

  • Hi I am using python and I keep getting this error with my code. Traceback (most...

    Hi I am using python and I keep getting this error with my code. Traceback (most recent call last): ['1'] Traceback (most recent call last): File "/Users/isabellawelch/Python ish/shuffle.py", line 86, in <module> emp = Employee(emp_data[0], emp_data[1], emp_data[2], emp_data[3], emp_data[4]) IndexError: list index out of range What does it mean and how do i fix it?? from tkinter import Tk, Label, Button, Entry, END employees = [] class Employee: def __init__(self, empno, name, addr, hwage, hworked): self.empno = empno self.name =...

  • ########### Homework 20 ################################## ################################################### #### Rewrite this code in 'class mode' : define the class...

    ########### Homework 20 ################################## ################################################### #### Rewrite this code in 'class mode' : define the class and so on.... #### If you can - try make a clicked button 'blue'. #### (Only if you can.) from tkinter import * abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def callback(x): label.configure(text = 'Button {} clicked'. format(abc[x])) root = Tk() label = Label() label.grid(row = 1, column = 0, columnspan = 26) buttons = [0]*26 ##create a list to hold 26 buttons for i in range(26): buttons[i]...

  • 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

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