An example of a simple resistor circuit is displayed below.
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
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
