Answer to Question #294212 in Python for Rahul

Question #294212

In a class test teacher announces the marks (negative marking allowed) of n students a student can achieve max 100 marks. Write a python function p-marks(*marks) that takes no. of students , marks of students and return the marks and check the marks are valid or

not. If valid then it calls the recursive function re-sort(*marks) which returns the students marks as a comma-separated string with elements in ascending order ( You can use built-in function max() or min() to do this) . Specify input in fixed form.


1
Expert's answer
2022-02-06T02:13:46-0500
#for printing marks

def print_marks(*marks):
    for m in marks:
        if m > 100:
            print('Invalid mark:', m)
            exit()
    s = rec_Sort(*marks)
    print(s)

#for sorting marks
def rec_Sort(*marks):
    if len(marks) == 1:
        return str(marks[0])
    
    m = min(marks)
    res = list(marks)
    res.remove(m)
    return str(m) + ", " + rec_Sort(*res)

#for printing the last answer
def main():
    print_marks(10, 93, 45, 76, 87, 45)


main()



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS