Answer to Question #289497 in Python for Sundar

Question #289497

In a class of 'N' students each student is asked to bring number of dishes as per their roll number for example student of roll number1 will bring 1 item, roll number 2 brings 2 items and so on. Write a python function calc(N) that takes integer value N and returns the total number of items brought by N students. Do not input() function for taking input ,specify it in fixed form and also don't use advanced data type(i.e. list, tuple,set, dictionary)


1
Expert's answer
2022-01-23T10:20:07-0500
def number_dishes(n):
    if n<0:
        return 'Enter a positive number'
    else:
        return (n*(n+1))//2


n = 5
print(number_dishes(n))

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