PYTHON Assignment

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Assignment Questions

Day 1:

No Questions.

Day 2:

1. Given String “ExcellenC”, print the last 3 letters using String slicing methods.

2. Given List Colours = [“Red”, “Blue”, “Green”, “Yellow”]


Find a) index of Green

b) add new element “Black” after the Blue

c) copy the elements to a new list.


d) remove the element “Green”

3. Given Dictionary

Students = {

"student1" : {

"name" : "Ram",

"age" : 15

},

"student2" : {

"name" : "Vimal",

"age" : 16

},

"student3" : {

"name" : "Mahesh",

"age" : 15

}
}

Find a) Print the age of Mahesh

b) List out the all the Key elements.

Day 3:

1. Write a program to take salary as input from the user and print the Bonus amount to be
paid according the table below.
Salary Bonus percentage
0-20,000 10 %
20,000-40,000 8%
40,000 -60,000 6%
60,000-80,000 5%
80,000 and above 4%
2. Write a program to print all the prime numbers between 10 – 50.

3. Write a program to find the smallest integer in a given list.


List1= [5,7,2,16,48]

Day 4:

1. Create a function to find whether given string is Palindrome or not.


2. Create a calculator application using functions, provide an option to user to choose
which operation to perform. Use Exception handling. Expected output:

Click 1 for Add


Click 2 for Sub
Click 3 for Mul
Click 4 for Div

(After user selecting the operation. Take two inputs from the user and print the answer.)
Day 5: Given a String below.
Hello I’m Raj, my mobile number is +91-9876765899 and email id is [email protected]. My Professional
Email is [email protected] and phone number is 040- 2254785.

Extract the phone numbers and email addresses from the string using RegEx and print them.
Day 6:

1. Write a program to create a text file with Python and insert text “Data Analytics is the trending course in
market.” And close the File.
Use Exceptional Handling and Log all the steps into a log file with time stamp. (Creating, writing and
closing)

Day 7:

Write Python Program to

1. Connect with MySql server and create a Library Database.


2. Create books table with id, bookname, author, date_of_pulication and price
3. Insert Values into the table
4. Retrieve all the records and print on the screen. 5. Update price of a book
5. Delete a record.
Day 8:

Write a Python class Employee with attributes like emp_id, emp_name, emp_salary, and
emp_department and methods like calculate_emp_salary, emp_assign_department, and
print_employee_details.

• Use 'assign_department' method to change the department of an employee.


• Use 'print_employee_details' method to print the details of an employee.
• Use 'calculate_emp_salary' method takes two arguments: salary and hours_worked, which is the
number of hours worked by the employee. If the number of hours worked is more than 50, the method
computes overtime and adds it to the salary. Overtime is calculated as following formula:
overtime=hours_worked–50
Overtime amount = (overtime * (salary / 50))
Day 9:
Write a Python Program to scrape the IMBD website and get top 250 movies of all time. Scrape and store
Rank, Movie Name, Year of Release and IMBD Rating in a Excel file.
Source: https://www.imdb.com/chart/top/

Day 10:
From the given Covid19 Dataset Find the average number of cases recorded for each country and store them
to a new CSV file.

Day 11:

Write a NumPy program to create an element-wise comparison (greater, greater_equal, less and less_equal) of
two given arrays.
Day 12:

Write a Python programming to create a pie chart of the popularity of programming Languages.

Sample data:
Programming languages: Java, Python, PHP, JavaScript, C#, C++ Popularity: 22.2, 17.6, 8.8, 8,
7.7, 6.7

You might also like