Skip to content
murmot

Results for “python array length example function program 2 site:discuss.python.org code”

  • discuss.python.org

    PEP 695: Type Parameter Syntax - Page 7 - PEPs - Discussions on...

    About Mojo: Mojo is a programming language that extends Python with static typing and Rust-like memory safety. It aims to be an excellent language for specifying high-performance machine-learning models. The project is being led by Chris Lattner, creator of LLVM and Swift.

  • discuss.python.org

    Add int.__length__ method - Ideas - Discussions on Python.org

    Jan 9, 2024 · An int is treated as a fixed width container of flags when performing embedded work in C. That definitely is not a Python integer, though. If you want that sort of integer, numpy has a set of defined-width types, and Python’s own struct module can pack and unpack them. But an integer, in Python, has no defined width and will not wrap around at any point. There are many ways you could define ...

  • discuss.python.org

    numpy array access - Python Discussions

    May 19, 2023 ... That said: for the problem as described, the code that makes the most sense is A = B + C , but without first creating an empty A (as it is ...

  • discuss.python.org

    Setting random NaN in multidimensional numpy array - Python Help...

    Discussions on Python.org. Setting random NaN in multidimensional numpy array.Many thanks for your answer! I didn’t know about the “zip()” function, it seems a good way to perform a mapping between two iterable objects. I have run your code and it works fine!

  • discuss.python.org

    Beginner Question | len () function - Python Help ...

    Aug 7, 2022 · print ("Length of your name is: " + len (length)) I have found the solution. My mistake was that I was trying to concatenate a string with an integer. I have just now learnt that the way to get this done is by converting the integer to a string. So my code should be as below: length = len (input ("Write your name: ")) new_length=str (length)

  • discuss.python.org

    How to support "optimized" 64 MiB JSON parsing and streaming for...

    Writing code is very satisfying, but is there really any more to the app side for a pure Python version, than serialising to json, and piping the text to stdin or stdout? The Python examples in MDN from further down in the link already given, are nice and short...

  • discuss.python.org

    Add option to pre define size of list - Python Help ...

    May 20, 2024 · Just like in C or Java, an option pre define the size and type of list. If we have the need to predefine the size of an array we can achieve this in Java. Java: int [] arr = new int[10] (Create a new array object of type int and size 10) Similarly, to achieve the same in python we have to use the following code. Python: arr: list[int] arr = [None]*10 To avoid this, we can implement a feature ...

  • discuss.python.org

    The len Function - Python Help - Discussions on Python.org

    Oct 17, 2021 · Hey all, it’s me again! Learning about the len function this week in regard to strings (ie. print(len(firstName))). I’m wondering when this would ever be a useful function to use. Obviously it’s a built-in function so it must have some important uses, but as somebody new to programming, I’m not sure I can think of any. Thanks in advance!

  • discuss.python.org

    Store data in arrays - Python discussion

    Jul 12, 2022 ... Global declarations only have a meaning inside functions, so you can remove these useless lines: global Degrees, NMEA1, NMEA2, NMEA3, DDD, ...

  • discuss.python.org

    Add a `__len__` and `__getitem__` ABC to `collections.abc ...

    May 15, 2025 · Checking the length and then accessing items is a fairly common pattern for collections in Python. Currently, typeshed’s custom SupportsLenAndGetItem protocol is used around 30 times in typeshed, although it is likely that more potential uses are hidden in other type annotations, especially Sequence. Currently, the best way to type annotate these items is to use either _typeshed ...