How does varying temperature affect the accuracy of grandma's pendulum clock? I have an antique pendulum clock(my granny's!) . If I detail it, 
This clock is approximately 5 feet tall and enclosed by wood and below it its glorious pendulum oscillates . 
It gave more or less correct time. But then I saw it was going slowly . I thought the spring inside had relaxed. But to my surprise, it was not. It was all in the right place. Yet it was giving a slower time . It was summer time and temperature was above $37^\circ$ celcius. 
So, is there any relation between temperature and the time period of this pendulum? If so, how can I prevent it??
 A: There are many, many factors that affect a pendulum's accuracy. There is a fairly famous pendulum clock in the bell tower of Trinity College, Cambridge, which is the subject of a fair bit of scientific analysis and monitoring (it keeps time to better than one second per month). The "keepers" of the clock wrote a detailed discussion about the factors affecting its accuracy
This tells us about a number of things you have to worry about when you want a really accurate clock:


*

*Length of pendulum

*Amplitude of motion

*Temperature

*Changes in gravity

*Changes in air density (humidity, barometric pressure)


and it proceeds to estimate (for that particular clock) the effect these factors might have. The time change per day due to changing length, for example, is given to a very good approximation by
$$\Delta T = T\frac{\Delta L}{2L}$$
(this is really just a first order expansion of the "exact" expression which ROIMaison gave in his answer). So if you estimate the change in length (coefficient of thermal expansion times temperature change) you can get the change in "going" (seconds lost or gained per day) directly from the above expression.
The Trinity clock has all kinds of compensation mechanisms: a barometric compensator, thermal expansion correction, etc.  Incidentally the mechanism for a thermally compensated pendulum is quite ingenious: looking at figure 4 from the above link we see

The "down" rods have one coefficient of thermal expansion and the "up" rods have another: by carefully choosing their relative lengths as a function of this coefficient, it is possible to make it so that the bob remains at a constant distance below the pivot.
Any number of things can give rise to changes in the accuracy of your clock - the change in temperature can change the friction and thus the amplitude as well as the length, to give just one example; I hope that after reading the linked document you will have a better appreciation of the ingenuity of clock makers and the problems they face.
Further links worth reading:
About the Trinity College clock
About the Trinity College clock monitoring project
Wikipedia entry about pendulum clock
A: The two lengths are given by:
$$L_{normal}=L$$
$$L_{summer}=L+\alpha \Delta T L$$
With $\alpha$ the thermal expansion coefficient, $12.0 \times 10^{-6} \: m/m \: K$
Thus the two periods become:
$$Period_{normal}=2 \pi \sqrt{\frac{L_{normal}}{g}}=2 \pi \sqrt{\frac{L}{g}}$$
$$Period_{summer}=2 \pi \sqrt{\frac{L_{summer}}{g}}=2 \pi \sqrt{\frac{L+\alpha \Delta T L}{g}}$$
The ratio between the two is then:
$$\frac{Period_{summer}}{Period_{normal}}=\frac{2 \pi \sqrt{\frac{L+\alpha \Delta T L}{g}}}{2 \pi \sqrt{\frac{L}{g}}}=\sqrt{1+\alpha \Delta T}$$
This can written as the following Taylor series:
$$\frac{Period_{summer}}{Period_{normal}}=\sqrt{1+\alpha \Delta T}=1+\frac{\alpha \Delta T}{2}- \frac{\left(\alpha \Delta T\right)^2}{8} + \frac{\left(\alpha \Delta T\right)^3}{16}  - \frac{5\left(\alpha \Delta T\right)^4}{128}  + \dots$$
With the first order approximation equal to:
$$\frac{Period_{summer}}{Period_{normal}} \approx 1+\frac{\alpha \Delta T}{2}$$
Assuming that the clock is inside, and the normal temperature is 20°, we have $\Delta T=17 K$. The difference for a day then becomes:
$$\Delta t_{day} \approx 24 \cdot 3600 \cdot \frac{\alpha \Delta T}{2} \approx 9\: \mathrm{seconds}$$ .
This seems like a lot to me, but then again, this is with the assumption that the temperature difference is 17° degrees all day long, which it obviously is not.
If we assume that the temperature varies as a the first half of a sine wave between 20° and 37°, thus providing a time difference of 0 when the temperature is 20°, and $\frac{\alpha \Delta T}{2}$ when the temperature is 37°. 
The average expansion is decribed by:
$$\frac{\int_0^{\pi} \frac{\alpha \Delta T}{2} \cdot sin( \pi \cdot t)}{\pi}=\frac{\alpha \Delta T}{\pi}$$
Which amounts to $24 \cdot 3600 \cdot \frac{\alpha \Delta T}{\pi} \approx 5 \: \mathrm{seconds}$ per day , which is still quite a lot.
