Professional Documents
Culture Documents
Python Placement Questions
Python Placement Questions
(A Govt. Aided UGC Autonomous & NAAC Accredited Institute Affiliated to RGPV, Bhopal)
Department of Computer Science & Engineering
Assignment: Summer internship in “Python Programming & its Applications”
Q2 Write a Python program that takes input_string as a parameter and returns an output_dict based
on the logic given below-
• output_dict would have keys as “LETTERS” and values as “COUNT”
• Value corresponding to key “LETTERS” would be an output_list1 which would contain
the unique letters in the input_string
• Value corresponding “COUNT” would be an output_list2 which would contain the count
of corresponding letters in the output_list1
• Elements in output_list2 are stored in descending order of counts and the letters
corresponding to the count in output_list1
• If there are more than one letter with the same count, then the letters are stored in the same
order as they appear in input_string
Example:
input_string output_dict
RadeepeekaaRrm LETTERS = ['e', 'a', 'R', 'd', 'p', 'k', 'r', 'm'],
COUNT = [4, 3, 2, 1, 1, 1, 1, 1]
Mississippi LETTERS = [I, s, p, M],
COUNT = [4, 4, 2, 1]}
Continue LETTERS = [n, C, o, t, i, u, e],
COUNT = [2, 1, 1, 1, 1, 1, 1]}
Madhav Institute of Technology and Science, Gwalior
(A Govt. Aided UGC Autonomous & NAAC Accredited Institute Affiliated to RGPV, Bhopal)
Department of Computer Science & Engineering
Assignment: Summer internship in “Python Programming & its Applications”
Q3 Write a Python program to check the validity of a password given by the user.
The Password should satisfy the following criteria:
1. Contain at least 1 letter between a and z
2. Contain at least 1 number between 0 and 9
3. Contain at least 1 letter between A and Z
4. Contain at least 1 character from $, #, @
5. Minimum length of password: 6
6. Maximum length of password: 12
Q4 Given an list of “n” integers where each value represents number of chocolates in a packet. Each
packet can have variable number of chocolates. There are “m” students, the task is to distribute
chocolate packets among the students such that:
• Each student gets one packet.
• The difference between the number of chocolates in a packet with maximum chocolates
and the packet with minimum chocolates given to the students is minimum.
• If m > n, then no chocolate distribution.
Example – 1:
Note: take the list of chocolate-packets as: [12, 4, 7, 9, 2, 23, 25, 41,30, 40, 28, 42, 30, 44, 48, 43,
50]
Sample Input: m = 7
Sample Output:
Selected packets of chocolates: 40, 41, 42, 43, 44, 48, 50
Minimum Distance: 10
Example – 2:
Take the list of chocolate-packets as: [2,80,56,47,23,15,32,18,12,8,90,35,47,44]
Sample Input: m = 6
Sample Output:
Selected packets of chocolates: [2, 8, 12, 15, 18, 23]
Minimum Distance: 21
Madhav Institute of Technology and Science, Gwalior
(A Govt. Aided UGC Autonomous & NAAC Accredited Institute Affiliated to RGPV, Bhopal)
Department of Computer Science & Engineering
Assignment: Summer internship in “Python Programming & its Applications”
Q5. Write a python program which implements the following class diagram and create 5 objects of
Employee class:
Employee
-name: string
-id: int
-Salary: int
-employee_count → static
__init__(name,id,address)
+displayEmployeeDetails( )
+displayAverageSalary( ) → static