# Price of a floating coupon bond with issuer credit risk and recovery rate

I need help. I have an assignment for an exam where i have to compute the price of a portfolio composed by floating coupon bonds taking into account the issuer credit risk and the recovery rate in case of default. I have to create a code in python. After computed the discount factors, i should price the bonds, but i don't know how to include the issuer risk and the recovery rate in the formula. The professor gave us the interest rates to compute the coupons, and i know that the price of a bonds is given by the sum of the discounted cash flows. How can i insert in the forumula these others two elements? He told me that is a sort of weighted average of the bond's price with the survival probabilitiy and the bond's price in case of default taking into account the recovery rate, with weight survival probability and default probability. But i didn't catch this. Sorry for my basic english and thanks to everyone in advance.

Discount each cash flow (coupons and principal) by the riskfree discount factor (from your bond financing curve) $$\times$$ the probability of survival (i.e. 1 - probability of default) at the time of the cash flow.