Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Assignment 2 pythonprogramming

The document outlines a lab assignment for a Computer Science and Engineering course focused on Programming Essentials for AI and ML. It includes tasks such as manipulating a dictionary, generating random numbers, calculating compound interest, and creating classes for a restaurant and user profiles. The assignment emphasizes practical coding skills in Python through various programming exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment 2 pythonprogramming

The document outlines a lab assignment for a Computer Science and Engineering course focused on Programming Essentials for AI and ML. It includes tasks such as manipulating a dictionary, generating random numbers, calculating compound interest, and creating classes for a restaurant and user profiles. The assignment emphasizes practical coding skills in Python through various programming exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Computer Science and Engineering Department

Programming Essentials for AI and ML (UAI201)


Lab Assignment-2
1. D is a dictionary defined as D= {1:”One”, 2:”Two”, 3:”Three”, 4: “Four”,
5:”Five”}. (i) WAP to add new entry in D; key=6 and value is “Six”
(ii) WAP to remove key=2.
(iii) WAP to check if 6 key is present in D.
(iv) WAP to count the number of elements present in D.
(v) WAP to add all the values present D.

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.

You might also like