An example of a simple resistor circuit is displayed below.
Need help with this assignment?Get an original answer from a qualified tutor — from $10/page.
Get it written →An example of a simple resistor circuit is displayed below.
In such circuits, V1 is a voltage source (V) and R1 is a resistor (Ω). The current in these circuits may be calculated using Ohm’s law:
The power dissipated across the resistor is
In the above equations, I is the current in amps (A), V is the voltage in volts (V), R is the resistance in ohms (Ω), and P is the power in Watts (W).
An input data file called circuits.txt contains voltage and resistance information for a set of simple resistor circuits. The first record line of the input file is the control number, which defines the number of circuits to be read into the program. Each succeeding record line has two columns, where the first column is the voltage and the second column is the resistance. The input file is comma delimited.
ASSIGNMENT:
Write a Python script that will read the required values from the input file. Using the voltage and resistance, compute the current in each circuit and the power dissipated by the resistor in each circuit. Write a function to compute the current and a function to compute the power. You should have a function to check whether the input data file exists, and there should also be a main function. Your program will produce a report in tabular format. Print the table to the computer screen and to an output file called levels.txt.
Once the program is working, modify the program to account for any current that is greater than 0.1 amp. Instead of printing the normal column items, for any circuit with current greater than 0.1 amp, print the voltage, the resistance, and then print a message that the current may be fatal. The output format is shown on page 2.
OUTPUT FORMAT:
**********************************************
CIRCUIT AMPERAGE AND POWER
Voltage Resistance Current Power
(V) (ohms) (A) (W)
xxx xxxx x.xx x.xx
. . . .
. . . .
. . . .
. . ** Current may be fatal. **
**********************************************
SUBMITTING ASSIGNMENTS:
Once you have your program working, exit the Python IDE that you are using. Make sure that your source program file name conforms to the following specifications:
sn_pn_first_last
where: sn is your section number (01, 02, 03 …)
pn is the program number (7)
first is your first name
last is your last name
An example for the sixth coding assignment would be 1_7_elmer_fudd.py.
Submission:
Submit both your handwritten problem-solving process and your Python source code using the Assignments button in Blackboard. Remember to submit your Python source program in Python 3 only, using code as demonstrated in class. No other format will be accepted.
If you make changes to your program and need to resubmit, rename the file such as 1_7_elmer_fudd_2.py or 1_7_elmer_fudd_3.py, etc. Then use the Assignments button in Blackboard to submit the new version. Only the most current submitted program version will be graded.
FILE LOCATION:
Files on the grader’s computer and Dr. B.’s computer will be located at:
C:Engr 200circuits.txt a
Get a plagiarism-free answer to this question
Send us your instructions and we’ll match you with the best writer in your subject.
- 100% human-written, zero AI
- Turnitin report included
- Confidential — we never share your data
- Free revisions & refunds