python loops?

the question asks Write a code that prints the summation of 1 to value . You can assume that value will be positive. For example, summation for user input 5 would print 15 (1 + 2 + 3 + 4 + 5). we are supposed to do this using why loops

the second question is the same but multiplying the numbers to a value

this is what i have but it when it runs nothing happens it just goes down a line without running anything

def summation(n):

count = 0

num = 0

while count < n:

count+=1

num+=count

return num

print (summation)

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 Q2A.ES - All rights reserved.