Assignment 2 pythonprogramming
Assignment 2 pythonprogramming
2. WAP to create a list of 100 random numbers between 100 and 900. Count and print
the: (i) All odd numbers
(ii) All even numbers
(iii) All prime numbers
3. (i) Write a function which takes principal amount, interest rate and time. This function
returns compound interest. Call this function to print the output.
(ii) Save this function (as a module) in a python file and call it in another python file.
4. A) Make a class called Restaurant. The __init__() method for Restaurant should store two
attributes: a restaurant_name and a cuisine_type. Make a method called describe_restaurant()
that prints these two pieces of information, and a method called open_restaurant() that prints
a message indicating that the restaurant is open. Make an instance called restaurant from
your class. Print the two attributes individually, and then call both methods.
B) Make a class called User. Create two attributes called first_name and last_name, and then
create several other attributes that are typically stored in a user profile. Make a method called
describe_user() that prints a summary of the user’s information. Make another method called
greet_user() that prints a personalized greeting to the user. Create several instances
representing different users, and call both method for each user.