Lab-02 - Functions Homework
Lab-02 - Functions Homework
Total Tasks 6
Submission Type Handwritten
Home Task 1: Hospital Fee
Suppose, you work for a hospital. Your job is to find out the highest fee received by
the hospital and the person(s) who paid the highest amount. Now, write a function
that takes multiple keyword arguments that returns the highest amount of fee taken
by the hospital and the person(s) who paid the highest fees.
[Hint: You might need to use **kwargs to solve this task.]
Function Call: Sample Output:
Highest fee was 1000 tk
max_amount, max_payer = hospital_fee(Neymar =
which was paid by
1000, Dembele = 600, Reus = 500, Bale = 1000)
Neymar, Bale.
Function Call: Sample Output:
Highest fee was 1200 tk
max_amount, max_payer = hospital_fee(Mashrafe =
which was paid by
400, Bumrah = 900, Steyn = 1200, Cummins = 900,
Steyn.
Wood = 400, Marsh = 700)
Write a function that takes in a list of integers and returns True if it contains 007 in
order.
Function Call: Sample Output:
is_james_bond( [1, 2, 4, 0, 0, 7, 5] ) True
Function Call: Sample Output:
is_james_bond( [1, 7, 2, 0, 4, 5, 0] ) False
Function Call: Sample Output:
is_james_bond( [1, 0, 2, 0, 4, 7, 5] ) True
Home Task 3: Section Assigning
"You are tasked with organizing students into different sections in a school. There
are 'ABCDE' (five) sections available, and you have a list of student names. You
need to create a function that will take these inputs and assign students to sections
based on their names.
The first parameter, 'sections', should be a string representing the available sections
(e.g., 'ABCDE' for five sections).
The second parameter should be a variable number of student names.
The function should calculate the sum of ASCII values of characters in each student's
name, then use the modulo operation with the number of sections to determine the
section based on the calculated value. It should return a dictionary where each
section is a key, and the associated value is a list of students assigned to that section.
Function Call: Output:
assign_students_to_sections ('ABCDE', 'Alice', {'A': ['Bob'], 'B': ['Charlie'],
'Bob', 'Charlie', 'David', 'Eve', 'Frank', 'Grace') 'C': ['Grace'], 'D': ['Alice',
'David', 'Eve', 'Frank'], 'E': [ ]}
Explanation:
For example, your name is Charlie and there are 5 Sections “ABCDE”.
So, the ASCII values for your name is:
C = 67
h = 104
a = 97
r = 114
l = 108
i = 105
e = 101
So, the summation is 67+104+97+114+108+105+101= 696
Now, as you have 5 sections,
696%5 = 1
So, Charlie will be on section 1 which means section B.
Home Task 4: Username Generator
Note: You can use random.choice() function from Python's random module to
randomize the opponent’s action.
3 Computer: paper
rock Computer: rock
paper Computer: rock
scissor Your Score: 1
Computer's Score: 2
Computer has won the game!
5 Computer: scissor
rock Computer: rock
paper Computer: rock
scissor Computer: rock
rock Computer: paper
paper Your Score: 2
Computer's Score: 1
You have won the game!