in Education by
I've always laughed to myself when I've looked back at my VB6 days and thought, "What modern language doesn't allow incrementing with double plus signs?": number++ To my surprise, I can't find anything about this in the Python docs. Must I really subject myself to number = number + 1? Don't people use the ++/-- notation? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Python does not support ++ like other languages because once you do ++/-- it becomes a statement, not an operator. In Python, all the namespace modification is in a statement. That's one of the design decisions. And also because integers are immutable, the only way to 'change' a variable is by re-assigning it. To get the value of ++/-- you can work with the following way:- number += 1 and number -= 1

Related questions

0 votes
    I have been using Python more and more, and I keep seeing the variable __all__ set in different __init__.py files. ... what this does? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    What * and ** do for param2 in the following: def foo(param1, *param2): def bar(param1, **param2): Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Coming from a C# background the naming convention for variables and method names are usually either Camel Case or ... for Python? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible ... the underlying database? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    In Python how can I convert an integer to a string? I am trying this: r = 16 r.str() I am trying to ... but there's nothing like that. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I have an array of the shape (100000, 1) with each element in an array of type positive integer and not ... help would be appreciated. Select the correct answer from above options...
asked Jan 8, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: asynchronous python itertools chain multiple generators (2 answers) Closed 2 ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    Is there a way to get functionality similar to mkdir -p on the shell from within Python. I am looking for a ... has already written it? Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    Hi, I am a relatively new programmer and my teacher gave us this problem to fix. Thing is, I have no idea ... wrong with this problem? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I had some Python 2 code as follows (pardon the indentation): def getZacksRating(symbol): c = httplib.HTTPSConnection("www. ... data.split(' ')[1] result = ratingPart.partition("...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    For example I have this 1 ['cancelled:', '7'] And I want to split to only get the integer value ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    For example I have this 1 ['cancelled:', '7'] And I want to split to only get the integer value ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Pandas Merging 101 (6 answers) Closed 3 years ago. Sorry guys, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 23, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Pandas Merging 101 (6 answers) Closed 3 years ago. Sorry guys, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Forming a matrix by summing 2 arrays element-array wise using NumPy ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
...