Real Estate buy houses as investments. At the end of each year the value of the house is estimated to grow by 5%. An Example for 5 years investment is as follows.
#Sample run for q1.py
Please enter your investment amount: 1000000
Please enter number of years: 5
Year Value (Million Dollars)
---- -----------------------
1 1.050000
2 1.102500
3 1.157625
4 1.215506
5 1.276282
Write a function calc_profit that takes two parameters. A number (integer or decimal) called principal which is the amount of money to invest in the house and a number (integer) called year which represents the number of years of investment. The function calculates and displays the value of growth per year. Save the function in a PyDev library module named a6_functions.py
Write and test a main program named q1.py that tests the function.
In mathematics, a square number or perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. (i.e 9 is a perfect square 9 = 3 x 3 while 7 is not). Write a function called perfect_square that takes an integer called num as parameter and prints all the perfect square numbers between 1 and num (exclusive). If num is not a positive integer, your function should display an error message. Save the function in a PyDev library module named a6_functions.py (same as other questions)
Write a main program q2.py to test the function by asking the user to enter a number.
#Sample run for q2.py
Enter a positive integer: 10
Perfect Squares below 10 are: 1, 4, 9
#Sample run for q2.py
Enter a positive integer: -10
You did not enter a positive integer
In mathematics, the notation n! represents the factorial of a non-negative integer n. The factorial of n is the product of all the non-negative integers from 1 to n.
For example,
7! = 1 x 2 x 3 x 4 x 5 x 6 x 7 = 5,040
and
4! = 1 x 2 x 3 x 4 = 24
Write a function called factorial that takes a non-negative integer num as a parameter then uses a for loop to calculate and return the factorial of that number. If the user enters a negative number, the function returns the integer -1. Save the function in a PyDev library module named a6_functions.py (same as other questions)
Write a main program named q3.py that tests the function by asking the user to enter a number and displaying the output.
#Sample run for q3.py
Enter a positive integer: 7
7! = 5040
#Sample run for q3.py
Enter a positive integer: -7
You did not enter a positive integer
In mathematics, a positive integer greater than 1, which has no other factors except 1 and the number itself, is called a prime number. 2, 3, 5, 7 etc. are prime numbers as they can only be divided by 1 and by themselves to give a whole number. 4, on the other hand is not a prime because, 4 can be divided by 1,2 and 4.
Write a function called is_prime that takes a positive integer called num as parameter and returns True if the number is prime and False otherwise. If the user enters an invalid input (negative integer) the testing program should keep asking the user for another input until the user enters a valid input. Save the function in a PyDev library module named a6_functions.py (same as other questions)
Write a main program named q4.py that tests the function by asking the user to enter an integer and displaying the output.
#Sample run for q4.py
Enter a positive integer: 8
8 is not a prime number
#Sample run for q4.py
Enter a positive integer: -8
Enter a positive integer: 23
23 is a prime number