Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculate stack value's
#8

  1. what does import operator exactly do
    https://docs.python.org/3/library/operat...e-operator Wrote:The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expression x+y. Many function names are those used for special methods, without the double underscores. For backward compatibility, many of these have a variant with the double underscores kept. The variants without the double underscores are preferred for clarity.

    The functions fall into categories that perform object comparisons, logical operations, mathematical operations and sequence operations.

    The object comparison functions are useful for all objects, and are named after the rich comparison operators they support:

  2. what does the 0 mean in "total = items[0]"
    When you use [] on a list you can get an item by its index, the list is zero index based so this gives the first item contained in the list.

  3. in this line for item in items[1:] what does [1:] do
    this is called slicing the list, it gives parts of the list [from:to] so im getting from index 1 and as i've given no to value it gives the rest of the list.
mylist = [0, 1, 2, 3, 4, 5]
print(mylist[0])
print(mylist[1:])
Output:
0 [1, 2, 3, 4, 5]
Reply


Messages In This Thread
Calculate stack value's - by GFreenD - May-12-2019, 06:15 PM
RE: Calculate stack value's - by michalmonday - May-12-2019, 06:32 PM
RE: Calculate stack value's - by GFreenD - May-12-2019, 06:55 PM
RE: Calculate stack value's - by michalmonday - May-12-2019, 07:15 PM
RE: Calculate stack value's - by GFreenD - May-12-2019, 07:53 PM
RE: Calculate stack value's - by Yoriz - May-12-2019, 08:07 PM
RE: Calculate stack value's - by GFreenD - May-12-2019, 08:40 PM
RE: Calculate stack value's - by Yoriz - May-12-2019, 09:02 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020