Chapter 2: Basic Electric Circuits and Components

Example 2.1, Page 23

In [3]:
#Initialisation
v1=15.8                 #voltage across r1
v2=12.3                 #voltage across r2
r2=220                  #resistance R2 in ohm

#Calculation
v=v1-v2                 #voltage difference across the resistor
i=v/r2                  #current in ampere

#Result
print'Current, I = %.1f mA'%(i*1000)
Current, I = 15.9 mA

Example 2.2, Page 24

In [5]:
#Initialisation
i1=10;                  #current in amp
i3=3;                  #current in amp


#Calculation
i2=i1-i3                  #current in amp

#Result
print'I2 = %d A'%i2
I2 = 7 A

Example 2.3, Page 25

In [6]:
#Initialisation
E=12                  #EMF in volt
v2=7                  #volt


#Calculation
v1=E-v2                  #volt

#Result
print'V1 = %d V'%v1
V1 = 5 V

Example 2.4, Page 25

In [8]:
#Initialisation
i=3                        #current in amp
r=50                       #resistance in ohm


#Calculation
p=(i**2)*r                       #power in watt

#Result
print'P = %d W'%p
P = 450 W

Example 2.5, Page 26

In [9]:
#Initialisation
r1=10                       #resistance in ohm
r2=20                       #resistance in ohm
r3=15                       #resistance in ohm
r4=25                       #resistance in ohm


#Calculation
r=r1+r2+r3+r4                       #series resistance in ohm

#Result
print'R = %d ohm'%r
R = 70 ohm

Example 2.6, Page 27

In [13]:
#Initialisation
r1=10                       #resistance in ohm
r2=20                       #resistance in ohm



#Calculation
r=(r1*r2)*(r1+r2)**-1                       #parallel resistance in ohm

#Result
print'R = %.2f ohm'%r
R = 6.67 ohm

Example 2.7, Page 28

In [14]:
#Initialisation
r1=200                       #resistance in ohm
r2=300                       #resistance in ohm


#Calculation
v=(10*r2)/(r1+r2)                       #resistance in ohm

#Result
print'V = %d V'%v
V = 6 V

Example 2.8, Page 29

In [20]:
#Initialisation
r1=1*10**3                       #resistance in ohm
r2=500                       #resistance in ohm
v1=15                         #voltage
v2=3                         #voltage

#Calculation
v=v2+((v1-v2)*((r2)*(r1+r2)**-1))                       #resistance in ohm

#Result
print'V = %d V'%v
V = 7 V

Example 2.9, Page 30

In [21]:
#Initialisation
f=50                       #frequency in herts


#Calculation
t=(1*f**-1)                    #time period


#Result
print'T = %d ms'%(t*10**3)
T = 20 ms
In [ ]: