Final answer:
A t-test is used when the sample size is small and the population is not normally distributed or the population standard deviation is unknown, while a z-test is used when the sample size is large and the population is approximately normally distributed or the population standard deviation is known.
Step-by-step explanation:
The ideal situations in which a t-test or z-test can be used depend on the sample size and the distribution of the data. In general, a t-test is used when the sample size is small (typically less than 30) and either the population is not normally distributed or the population standard deviation is unknown. On the other hand, a z-test is used when the sample size is large (typically greater than 30) and the population is approximately normally distributed, or when the population standard deviation is known.
For example, if we have a small sample size of 20 students and we want to test whether there is a difference in their exam scores before and after a study intervention, we would use a t-test. However, if we have a large sample size of 100 students and want to compare the mean heights of males and females in a population, we would use a z-test.