Practical 3 Python
Practical 3 Python
1. Given the coordinates (x,y) of center of a circle and its radius, determine whether a point lies inside the
circle, on the circle or outside the circle. (Hint: Use sqrt( ), pow(
))
Source code:-
Output:
2. Given three points (x1,y1), (x2,y2) and (x3,y3), check if all the three points fall on one straight line.
Source code:-
Output:
3. WAP to read two text files and merge their contents into a third file.
Source code:-
Output:
4. Write a program in Python to create a CSV file by entering user-id and password, read and search the
password for given user-id.
Source code:-
Output:
5. WAP to ask the number of lines from the user and print the following pattern: 1
AB
234
ABCD
Source code:-
Output:
6. Display the user specified term in Fibonacci series using a recursive function fibo().
Source code:-
Output:
7. You have graduated from PDEU and now have a great job! You move to Banglore and decide that you want
to start saving to buy a house. As housing prices are very high in Banglore, you realize you are going to have
to save for several years before you can afford to make the down payment on a house. We are going to
determine how long it will take you to save enough money to make the down payment given the following
assumptions:
b. Call the portion of the cost needed for a down payment portion_down_payment. For simplicity, assume
that portion_down_payment = 0.25 (25%).
c. Call the amount that you have saved thus far current_savings. You start with a current savings of ₹ 0.
d. Assume that you invest your current savings wisely, with an annual return of r (in other words, at the
end of each month, you receive an additional current_savings*r/12 funds to put into your savings – the
12 is because r is an annual rate). Assume that your investments earn a return of r = 0.04 (4%).
f. At the end of each month, your savings will be increased by the return on your investment, plus a
percentage of your monthly salary (annual salary / 12).
Write a program to calculate how many months it will take you to save up enough money for a down
payment. You will want your main variables to be floats, so you should cast user inputs to floats.
def calculate_months_to_save():
Output: