#๐Ÿ”’ help

50 messages ยท Page 1 of 1 (latest)

slow zodiac
#

can somone explain to me about prefix sum?

knotty knollBOT
#

@slow zodiac

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

final apex
#

Wdym by prefix sum

lime trench
#

In computer science, the prefix sum, cumulative sum, inclusive scan, or simply scan of a sequence of numbers x0, x1, x2, ... is a second sequence of numbers y0, y1, y2, ..., the sums of prefixes (running totals) of the input sequence:

y0 = x0
y1 = x0 + x1
y2 = x0 + x1+ x2
...
For instance, the prefix sums of the natural numbers are the triangul...

visual tendon
tepid pulsar
final apex
slow zodiac
#

i need python code of it

#

can u help

slow zodiac
#

i need for my exam

visual tendon
slow zodiac
rocky oar
knotty knollBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

slow zodiac
#

bc my teacher said prefix sum will appeared in the exam

#

so i need help understanding it

rocky oar
#

well there are indeed code examples on that wiki page. did your teacher not teeach it to you at all?

slow zodiac
#

but my school teaches js

#

thats the problem

rocky oar
#

so you need to learn python. sounds like you need to start with the basics unless you have some python knowledge already

slow zodiac
#

but it jst some basics

rocky oar
#

so does it make sense to you that a prefix sum is the cumulative sum of all elements in a list at each index of the list?

#

list [1, 1, 1, 1, 1] prefix sum [1, 2, 3, 4, 5]

slow zodiac
#

english is not my mother tongue

#

so im rlly bad

rocky oar
#

well honestly the code to explain it is basically the exact answer to the exam question so lets try a different approach. Are you familiar with for loops?

rocky oar
#

so with the list like [1, 2, 3, 4, 5] how would you itterate over it and print out each number in the list?

slow zodiac
knotty knollBOT
#

Hey @slow zodiac!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
rocky oar
#

ok, and you wrote that yourself? cool. so now what would you do if you wanted to add them all together?

slow zodiac
#

or maybe a sum

rocky oar
#

so you can do it in the same loop
and say you have

x = 1
print(x)```
how would you add 5 to x so that it prints out as `6`?
knotty knollBOT
#

Hey @slow zodiac!

Please edit your message to use a code block

Make sure there are no spaces between the back ticks and py.

Here is an example of how it should look:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
rocky oar
#

Ok now take that knowledge and apply it to the loop for the list of numbers

slow zodiac
rocky oar
knotty knollBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.