Step 1: Understand the rule.
A Prime Minister can be a member of either the Lok Sabha or the Rajya Sabha. The Constitution does not force the PM to come from the lower house.
Step 2: Check each name.
Lal Bahadur Shastri, Charan Singh and Morarji Desai were all in the Lok Sabha when they became Prime Minister.
Step 3: Look at Indira Gandhi.
When Shastri died in January 1966, Indira Gandhi was chosen as PM. At that time she sat in the Rajya Sabha, representing Uttar Pradesh.
Step 4: Draw the conclusion.
So she is the one who was first appointed PM while being a Rajya Sabha member.
Answer: Indira Gandhi (Option 4).