Showing posts with label Anaconda. Show all posts
Showing posts with label Anaconda. Show all posts

Friday, March 30, 2018

How do you define an Array in Python?

Looks like a trick question.

There is no Array in Python but an object List exists which can be used to the same end.
  • The List may contain different list items or same kind of list items.
  • The List is indexed and zero based. The first list item has an index 0.
  • You can retrieve list items using their index. Even negative index is OK.
As defined here lst is a list .

lst=["a", "b", "c", "e"]

The list can have strings like this as well:

lst2=['a', 'b', 'c', 'e']

They both evaluate to the same: ['a', 'b', 'c', 'e']


List may contain different types of List Items as in this definition.


 lst2=["ab", 8, True, 5.8]

Retrieving list items using index
>>> lst[0]
'a'
>>> lst[-1]
'e'
>>> lst2[-2]
True
>>> lst[5]
Traceback (most recent call last):
  File "", line 1, in
IndexError: list index out of range

Negative Index
>>> lst[-1]
'e'
>>> lst2[-2]
True



These evaluations were carried out using Python 3.6.2


Tuesday, March 20, 2018

Does Visual Studio 2017 support Python?

Yes, in a big way. Just the Intellisense support may by itself a great help.

You need to install PTVS (Python Tools for Visual Studio) to have Python support in Visual Studio (2017,2015, 2013 and earlier). In Visual Studio 2015 you need a Python Interpreter (Python 3.5 or earlier, 3.6 and above are not supported). The VS may guide you to install a Python Interpreter.

Python support is not presently available in Visual Studio for Mac, but is available on Mac and Linux through Visual Studio Code.

More here:
https://docs.microsoft.com/en-us/visualstudio/python/installing-python-support-in-visual-studio

Well, here is my personal take. I have Microsoft Visual Studio Community 2017, version 15.5.7 which has the following Python related products:

VS2017Python_1

In the installed templates I can see all of the following that are specific to Python:


VS2017Python_0

What is more. You also get other perks, if you install Visual Studio that I have installed:


VS2017Python_2


Actually, I have other Python stuff as well: