Code:
import random import math def printHeader(): print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") print("Wire Wire Wire Wire Resistance") print(" no. gauge length material (OHM)") print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") def diameter(wireGauge): d=0.127*math.pow(92,((36-wireGauge))/39) d=d/1000 return d def copperWireResistance(length,wireGauge): p=1.678E-8 d=diameter(wireGauge) R=(4*p*length)/(math.pi*d*d) return "%10.3E"%(R) def goldWireResistance(length,wireGauge): p=2.44E-8 d=diameter(wireGauge) R=(4*p*length)/(math.pi*d*d) return "%10.3E"%(R) def aluminumWireResistance(length,wireGauge): p=2.82E-8 d=diameter(wireGauge) R=(4*p*length)/(math.pi*d*d) return "%10.3E"%(R) #print(copperWireResistance(100,35)) #print(aluminiumWireResistance(160,23)) def main(): printHeader() fh=open("SampleInput.txt",'r') contents=fh.readlines() illegal=0 total=0 count=0 aluminum_total=0 for line in contents: #print(len(list(line.split(' ')))) gauge,length,material=line.rstrip().split(' ') length=float(length) total+=1 try: if not(int(gauge)>0 and int(gauge)<=40): raise ValueError except ValueError: gauge=random.randint(1,40) illegal+=1 if not(length>=50 and length<=200): illegal+=1 continue if material=='gold': count+=1 R=goldWireResistance(length,int(gauge)) print(count,"\t",gauge,"\t ",length," Gold \t ",R) elif material=='copper': count+=1 R=copperWireResistance(length,int(gauge)) print(count,"\t",gauge,"\t ",length," Copper\t ",R) elif material=='aluminum': count+=1 aluminum_total+=1 R=aluminumWireResistance(length,int(gauge)) print(count,"\t",gauge,"\t ",length," Aluminum\t ",R) else: illegal+=1 print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") print("Total records:",total) incorrect=illegal*100/total print("Incorrect records:",illegal,"corresponds to "+str(round(incorrect,2))+"% of the records") alu_per=aluminum_total*100/total print("Percentage of aluminum wires "+str(round(alu_per,2))+"%") print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") main()
Note: Sample input file should have values separated by a single space.
Sample Input:
SampleInput.txt
35 100 copper
-28 160 aluminum
15 110 copper
6 170 aluminum
40 95 aluminum
- 200 aluminum
9 16 aluminum
27 45 gold
30 100 silver
39 65 gold
1 150 copper
20 400 aluminum
40 180 gold
5 135 gold
50 180 copper
17 200 aluminum
7 85 copper
7 190 copper
19 50 copper
30 70 aluminum
5a 120 gold
21 190 copper
Output:
Please write the python functions Problem: Electric wire (Figure is a cylindrical conductor covered by an...
Need this question answered in python. Science P5.35 Electric wire, like that in the photo, is a cylindrical conductor covered by an insulat- ing material. The resistance of a piece of wire is given by the formula where p is the resistivity of the conductor, and L, A, and d are the length, cross- sectional area, and diameter of the wire. The resistivity of copper is 1.678 × 10-8 Ω m. The wire diameter, d, is commonly specified by the...
You want to produce three 1.00-mmmm-diameter cylindrical wires, each with a resistance of 2.00 ΩΩ at room temperature. One wire is gold, one is copper, and one is aluminum. Refer to Table 25.1 in the textbook for the resistivity values. C.) What will be the length of the aluminum wire? Include units D.) Gold has a density of 1.93 ×× 1044 kg/m3kg/m3. What will be the mass of the gold wire? Include Units E.) If gold is currently worth $$40...
1 Rev You want to produce three 1.00-mm-diameter cylindrical wires, each with a resistance of 5.00 N at room temperature, One wire is gold, one is copper, and one is aluminum. Refer to Table 25. 1 in the textbook for the resistivity values. Part A What will be the length of the gold wire? Express your answer with the appropriate units. L 161 m Correct Part B What will be the length of the copper wire? Express your answer with...
Determine the overall resistance of a 100-meter length of 14 AWA (0.163 cm diameter) wire made of the following materials.a. copper (resistivity = 1.67x10-8 O•m)b. silver (resistivity = 1.59x10-8 O•m)c. aluminum (resistivity = 2.65x10-8 O•m)d. iron (resistivity = 9.71x10-8 O•m)
Two square wires are composed differently, see the figure of their cross-sections. Wire 1 is a square wire of material A but with a circular center of material C. The diameter of the circular inside is equal to the length of side of the square. The second square wire has the same cross-sectional area as the first but is entirely comprised of material A. Both wires are the same length and setup to have the same temperature difference maintained between...
problem A wire 4.00 m long and 6.00 mm in diameter has a resistance of 15.0 m2. A potential difference of 22.0 v is applied between the ends Resistivity, p Temperature Coefficient of Resistivity, a(K-1) Material (2 m) Typical Metals 41 x 10-3 Silver 1.62 x 10 43 x 10-3 1.69 x 10 Copper 40 x 10-3 2.35 x 10-8 Gold 4.4 x 10 2.75 x 10 Aluminum 4.82 x 10-s 0.002 x 10-3 Manganin 4.5 x 10-3 5.25 x...
1. A ductile metal wire has resistance R. Then the wire is stretched to three times its original(poin) length. The stretching shrinks the diameter of the wire, but does not affect its density or resistivity. What is the resistance of the stretched wire? O3R 2. A current of 1.50 A flows through the leads of an electric appliance. How long does it take for (1 point) 7.50 C of charge to pass through the leads? 0 2.00s 11.0 s 6.00s...
It is possible to crudely determine the resistivity of a material using the following equipment and materials. Five coils of wire all made of the same unknown metal can be produced with characteristics shown in the table below. In addition to each coil being made of the same metal, each coil is wound using 10 meters of wire. The difference between each coil is the diameter of wire. Coil characteristics Length Coil Number Gauge (AWG) Diameter (mm) (m) 10 2.58826...
hey, this is a filei/o homework. um please show me how to do this (im using ONLY arraylist for the first part so please continue on that) i have put my work please fix some mistakes and continue on it. the file is named “tools.txt” its a text document file that i savedin the netbeansprojects file. um pleas euse netbeans and show me the output afterwards, make it simple and continue on what i have worked on whilw fixing some...
MATLAB question: I have written a code to solve for a metals resitance. Here is the problem statement: Part 1 (Algorithms) – due Friday: Think about how you might solve the problem of calculating the resistance of a given group of metals depending on the type of metal, the length of the wire and the area of the wire (if given the diameter only – so you must calculate the area). Write instructions (an algorithm) for a script that behaves...