Python Assignment 1
Python Assignment 1
1. The following tasks are related to a birthday party. Create a Python program file to do the following
tasks step-by-step:
I. Take input of the following information from the user console and store them in separate
variables:
II. Suppose, every friend of the birthday person came with his both of his parents. Count the total
number guests in the party.
III. Suppose, in this party there were 10 staffs. Count the total number of persons available in the
party including the birthday person, his/her parents, guests and staffs.
IV. Assume all guests were given 2 slices of cake. Calculate and print the total number of cake
slices needed.
V. Assume each guest ate 3 slices of pizza and each pizza has 8 slices. Calculate and print the
number of pizzas purchased for the party (round up to the nearest whole pizza).
VI. Assume each guest took 1.5 liters of water. Calculate and print the total liters of water needed.
VII. Suppose, party favor was given to all friends of the birthday person. Calculate and print the
total cost of party favors for all friends
VIII. Calculate the total expenses for Cake, pizza, water, party favors. First three are fixed costs as
taken as input from the user.
IX. Calculate the cost per guest rounded to two decimal places.
X. Use an f-string to display:
■ Birthday person's name and age
■ Number of people attending
■ Number of pizzas
■ Liters of drinks
■ Total cost
■ Cost per person
Part - 2: Logical Statements
1. Write a Python program that takes a student's percentage of marks (0-100) as input. If the
percentage of marks is 40 or above, print "Passed" otherwise don't print anything.
2. Write a Python program that takes a student's percentage of marks (0-100) as input. If the
percentage of marks is 40 or above, print "Passed". Otherwise, print "Failed".
3. Write a Python program that takes a student's percentage of marks (0-100) as input. Find and
print the grade based on the percentage of marks obtained by the student. Use following
gradation scheme:
4. Write a Python program that takes a student's percentage of marks (0-100) and attendance
percentage (0-100) as input. If attendance is below 75%, print "Fail due to low attendance"
regardless of grade. If attendance is 75% or higher:
■ Use the previous grading scale (A, B, C, D, F)
■ For grades C and above, add "Good attendance!" to the output
■ For grade D, add "Pass, but please improve attendance"
■ For grade F, add "Fail, attendance satisfactory but grades need improvement"
Part - 3: Strings
Suppose you received the following encoded message:
AGT007XXXmeetXXXatXXXtheXXXoldXXXlighthouseXXXatXXXmidnightXXXbringXXXtheXXXbluep
rintsXXXandXXXwearXXXaXXXredXXXhatXXXcodewordXXXumbrellaXXXoverXXXandXXXout
Write a python program for performing the following tasks on the encoded message
i. Join all the words in the transformed message with "---" (hint: use join()).
ii. Add the agent ID to the start and end of the message.
iii. Print the final decoded message in all caps (hint: use upper()).
i. Agent ID
ii. Length of original message
iii. First and last words of the decoded message
iv. Whether the code word was found