About 148,000 results
Open links in new tab
  1. python - Why does multiplication repeats the number several …

    If both operands are ints, you will get multiplication of them as int. If one operand is an int and the other is a string, then the string will be repeated the number of times specified by the int.

  2. python - Asterisk for multiplication and duplication - Stack Overflow

    Oct 4, 2019 · It entirely depends on the class that implements the __mul__ method. For e.g. str * n will return str concatinated n times, while int*n will return the arithmetic evaluated value. It …

  3. Python multiplication operator - Stack Overflow

    Mar 30, 2012 · @jpm: Yes, it's in the spec. It's called sequence repetition. See docs.python.org/library/… note (2), and notice that the copies are defined to be shallow copies.

  4. Concatenation (+) and Repetition (*) in Python - codeburst

    Aug 25, 2020 · Sequences datatypes (both mutable and immutable) support a repetition operator * The repetition operator * will make multiple copies of that particular object and combines …

  5. Mastering Mathematical Operations and Repetition Structures in Python

    Nov 29, 2023 · Python offers intuitive symbols for addition (+), subtraction (-), multiplication (*), division (/), modulo (%), and exponentiation (**). These operations empower us to perform …

  6. Concatenation and Replication in Python - Dev Genius

    Oct 22, 2024 · With concatenation and replication, you can seamlessly combine multiple strings or multiply them to create dynamic outputs. These two operations form the backbone of efficient …

  7. Understanding the Different Uses of the Asterisk(*) in Python

    Jun 5, 2023 · We can use an asterisk as a repetition operator, repeating the string or list for a specific number (similar to multiplying them). Let’s understand with an example.

  8. Repetition Operator on List in Python - Online Tutorials Library

    We are accustomed to using the * symbol to represent multiplication, but when the operand on the left side of the * is a list, it becomes the repetition operator. The repetition operator makes …

  9. Lesson 2: The Basic Elements > Overloaded operators | Python ...

    Some operators are not limited to arithmetic operations with numbers. For example, + and * can be used for a different kind of operation when used with str s. Try to guess the output value of …

  10. python - Why does using multiplication operator on list create

    Jan 11, 2012 · It seems that elements of rows list are pointers to the same old ['']*5 list. Why does it work this way and is this a Python feature? The behaviour is not specific to the repetition …

Refresh