Answer to Question #289898 in Python for Rahul

Question #289898

In a class 'N' students are asked to bring a dishes as per their roll numbers for example roll number1 brings 1 item, roll number 2 will bring 2 items and so on.write a function that that takes integer N and returns total number of items brought by "N" students. Don't use list,tuple,dictionary and use simple assignment statements,loop and if,else statement

1
Expert's answer
2022-01-22T16:40:45-0500
def class_dish(N):
    count_dish = 0
    for i in range(1, N+1):
        count_dish += i
    print(count_dish)
class_dish(4)

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