Resistors act as the most common passive components in circuits.
For example, a resistor can be used to limit the current through a LED. In the example circuit given below, we can calculate the value of resistance by simple calculation as given below.
V_PWR-(I_LED*RESISTANCE VALUE)-V_LED =0
[Samples values => V_PWR=5V; I_LED=20mA; V_LED = 3V(typical forward voltage for blue LED)]
Which gives => RESISTANCE VALUE = 100 Ohm
In this case the power rating of the resistance also matter. Power rating of resistance is calculated below.
Power = (Square of Current) * (Resistance value)
Power = (0.02*0.02)*(100) = 0.04 Watt