That was a bit complicated explanation though test for starters, but let me give a shot to explain in some easier words..
Example 1.
Nifty 8300 PE sold (Yes you are right that you are long on Nifty, but maximum that you can gain from selling put is the premium that you received from it, which is I'm taking value given by test is 13.5 Rs)
So At expiry if Nifty is 8300 you will gain 13.5
Nifty is 8400, you will still gain 13.5.
Now downside Scenario: Simple formula of what will be value of PE on downside level is Strike Price of PE-Nifty Spot.
a)So at exact 8300 Nifty spot your option value will be
Strike - Spot, (8300-8300) = 0, since you have sold 8300 PE you receive 13.5 rs, and that will be your gain.
b) At 8200 Nifty spot on expiry value will be,(again strike price -spot)
8300-8200 = 100, amount you will loose will be (100-13.5)86.5
Likewise you can calculate loss at different price points, so originally you asked what will be your gain or loss at 8299, answer is simple, value of put will be 1 Rs, so overall gain will be 13.5-1=12.5 Rs gain.
Now some technical parts and catches in selling Call or put, you need to maintain full value of Nifty future to sell a call or put, which I think is very high with increased margin, might be around 50k, but i dont know coz i left trading Nifty long ago, but its equal to 1 lot of Nifty Futures. second you must buy the option on the expiry to square off position else you'll be charged a lot of money for holding option at expiry...
Wrong. If you have sold option, you have already paid STT (STT is never on buying) therefore, squaring off is not required. But if you have bought option, and is ITM or carries considerble value on expiry, and you don't sell it then it will be considered as excercised option and STT charged on an excercised option will make you weep.
...and third downside risk in selling option is unlimited so be careful while selling option...
Again wrong. The myth of Unlimited risk is scarecrow designed to protect option writing business. Never heard of a option writer going in coma just after writing an option, therefore it is as good as playing futures with SL. Indeed, everything being equal, option writing has more safe SL than futures, and far less tiring. Statistically proven bottomline: an option written even a bit carelessly has more chances to bring in profits than one bought even after careful combing of option chain and greeks. Option buying is profitable only in scalping with multiple lots, 10x onwards.
....Hope above info helps.