Skip to content
murmot

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

  • discuss.python.org

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

    Aug 7, 2022 · length = input ("Write your name: ") 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 ...

  • 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

    Use * operator to type fixed-size collections - Ideas ...

    Nov 12, 2023 · Typing of heterogenous sequences (list [int * 3, str, int * 2]), even it I find that less readable and probably a way less common use case; Bounded iterable size: for example, itertools.tee could have an overload or even, to get back to my example, Some way to denote “at least X” / “at most X” items ?

  • discuss.python.org

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

    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 where we can define the size of list while declaration.

  • 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

    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

    Why the size of object or array always coming same? - Python ...

    Dec 26, 2023 · The sys.getsizeof () function in Python returns the size of an object in bytes. However, it doesn’t account for the full memory footprint of an object. For instance, when I called sys.getsizeof () on MeraList object, it’s returning the constant size of the ctypes.py_object array reference, not the actual data stored in the array.

  • discuss.python.org

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

    I am trying to generate a 4D numpy array that contains a random number of “nan”. I am following a methodology that I have found in this page (How to randomly insert NaN in a matrix with NumPy in Python ? - GeeksforGeeks), concretely “method 2”, that consists in creating a mask.

  • discuss.python.org

    How to type homogenous tuples of a given length - Python Help ...

    Jul 11, 2023 · They don’t have an arbitrary understanding of arbitrary Python code that you might want to put inside a type annotation; any new kind of expression in a type annotation has to have special-case logic manually added to a type checker in order for the type checker to understand it.

  • 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!