Monday, May 20, 2024

Happy_moment

 Finished Complex numbers Sharma lesson2 . This last part involved working with polar 

coordinates.


It all really comes down to working with python math and cmath libraries. Which,

incidentally, should not be imported because they are not modules. One just invokes

them, on need.


And, no, complex numbers are not subscriptable so one stays with a + in the output,

and not a coma on complex numbers...


https://docs.python.org/3/library/math.html

https://docs.python.org/3/library/cmath.html

                                              *     *     *

                                                          





                                                         *     *     *

Today is a Bank holiday,  in Quebec Les Patriotes. It is also abormally warm...

Makes me HAPPY!!


                                              *     *     *

Went out for a long walk - and a spot of shopping - this afternoon. Ended

up getting a good exposure to sunlight, my first of the season. Nice feeling...

On coming back, asked Bing to connect me to the new free Chat Gpt.

Asked Chat to xplain to me the python 'is not subscriptable" error with 

repect to complex numbers. Got  very clean answer:

                                                       
When you encounter an error message in Python saying that a complex number is "not subscriptable," it means you're trying to access an index of a complex number using square brackets `[]`, which isn't allowed because complex numbers are not iterable or subscriptable in Python. 
Here's a simple example to illustrate this:
```python
z = 3 + 4j
print(z[0])  # Trying to access the first element of the complex number
```
This will result in an error like
```TypeError: 'complex' object is not subscriptable
```
To work with the real and imaginary parts of a complex number, you can access them directly using the `real` and `imag` attributes, like this:
```python
z = 3 + 4j
print(z.real)  # Output: 3.0
print(z.imag)  # Output: 4.0
```
If you need to access individual components of a complex number, you can do so directly using attributes or functions provided by the complex number type.

That's exactly what the code in question is doing. So I opened GoogleColab on my older

computer and did a copy/paste of the code from the lesson. Behold, it worked perfectly:


Went back to Jupyter Notevook, erased everythhing and did a copy/paste there as well

Working wondefully...

                                                                   
                                                    
                                                         *     *     *
The error:

                                                                   



                                                                     *     *     *
The original for complex exponent on a real:

                                                                               


                                            

No comments: