0
How to make a program "sum of consecutive number" in python ❓
8 Respuestas
+ 5
Bidur Pokhrel There is no point of others coding stuff for you, if you do not understand it and learn it yourself.
Read the lessons again, as Lisa said, and try to implement into practice what you know. You have to try, and not wait for others to code for you
:)
+ 4
How often are you going to post the same question?
+ 3
Take a break, then write the code.
Then: Show the code so we can check on it and make suggestions.
I have described the approach to you in your thread with the same question and that you deleted.
+ 2
If you are fustrated then you must have something to show? Please share your attempts so that we can see where you may have gone wrong.
+ 2
Bidur Pokhrel I just noticed that you recently joined sololearn only 3 days ago.
Welcome to Sololearn. We are a learning platform, Here we don't simply provide answers to home work.
But if you provide your atttemp we are more than happy to help you with programming related questions.
Get started with the basic python fundamentals. If you don't know python already. If you do know python it wont hurt to revise.
https://www.sololearn.com/Course/Python-for-Beginners/?ref=app
I have already worked up a solution to the code with some explinations. I'm just waiting for you to show that you have a basic understanding of the fundamentals of python.
https://www.sololearn.com/Discuss/3021159/?ref=app
https://code.sololearn.com/W1AxdV4e2H68/?ref=app
Updated Guideliness: https://www.sololearn.com/Content-Creation-Guidelines/
0
Please code this for me.
I am being frustrated.
0
You can create a program in Python to find the sum of consecutive numbers using a for loop.
Python Code :
# Take input from the user
num = int(input("Enter the number of consecutive integers to add: "))
# Initialize the sum
sum = 0
# Use a for loop to iterate through the range of integers
for i in range(1, num+1):
sum += i
# Print the sum
print("The sum of the first", num, "consecutive integers is:", sum)
0
You can also use a while loop to achieve the same result:
Python Code :
# Take input from the user
num = int(input("Enter the number of consecutive integers to add: "))
# Initialize the sum
sum = 0
# Initialize the counter
i = 1
# Use a while loop
while i <= num:
sum += i
i += 1
# Print the sum
print("The sum of the first", num, "consecutive integers is:", sum)