Python IDEs For Data Science. ... IDE stands for Integrated Development Environment. It's a coding tool which allows you to write, test, and debug your code in an easier way, as they typically offer code completion or code insight by highlighting, resource management, debugging tools.
- Hello world
If programming is the act of teaching a computer to have a conversation with a user, it would be most useful to first teach the computer how to speak. In Python, this is accomplished with the print...
- Print Statements
There are two different Python versions. Both Python 2 and Python 3 are used throughout the globe. The most significant difference between the two is how you write a print statement. In Python 3, p..
- Strings
When printing things in Python, we are supplying a text block that we want to be printed. Text in Python is considered a specific type of data called a string. A string, so named because they are..
- Handling Errors
As we get more familiar with the Python programming language, we run into errors and exceptions. These are complaints that Python makes when it does not understand what you want it to do. Everyone r...
- Variables
In Python, and when programming in general, we need to build systems for dealing with data that changes over time. That data could be the location of a plane, or the time of day, or the television...
- Arithmetic
One thing computers are capable of doing exceptionally well is performing arithmetic. Addition, subtraction, multiplication, division, and other numeric calculations are easy to do in most programm..
- Updating Variables
Changing the contents of a variable is one of the essential operations. As the flow of a program progresses, data should be updated to reflect changes that have happened. fish_in_clarks_pond.
- Comments
Most of the time, code should be written in such a way that it is easy to understand on its own. However, if you want to include a piece of information to explain a part of your code, you can use t..
- Numbers
Variables can also hold numeric values. The simplest kind of number in Python is the integer, which is a whole number with no decimal point: int1 = 1 int2 = 10 int3 = -5 A number with a decimal...
- Two types of Divisions
In Python 2, when we divide two integers, we get an integer as a result. When the quotient is a whole number, this works fine: quotient = 6/2 # the value of quotient is now 3, which makes sense Ho...
- Multi line Strings
We have seen how to define a string with single quotes and with double quotes. If we want a string to span multiple lines, we can also use triple quotes: address_string = “””136 Whowho Rd Apt 7 Wh...
- Booleans
Sometimes we have a need for variables that are either true or false. This datatype, which can only ever take one of two values, is called a boolean. In Python, we define booleans using the keyword..
- Value Error
Python automatically assigns a variable the appropriate datatype based on the value it is given. A variable with the value 7 is an integer, 7. is a float, 7 is a string. Sometimes we will want to...
- Review
Great! So far we have looked at: - Print statements - How to create, modify, and use variables - Arithmetic operations like addition, subtraction, division, and multiplication - How to use comments...
PYTHON LISTS AND DICTIONARIES:
- Introduction to lists.
Lists are a datatype you can use to store a collection of different pieces of information as a sequence under a single variable name. (Datatypes you have already learned about include strings, numb...
- Access by Index
You can access an individual item on the list by its index. An index is like an address that identifies the items place in the list. The index appears directly after the list name, in between br..
- New neighbours
A list index behaves like any other variable name! It can be used to access as well as assign values. You saw how to access a list index like this: zoo_animals[0] # Gets the value pangolin.
- Late Arrivals and List Length
A list does not have to have a fixed length. You can add items to the end of a list any time you like! letters = [‘a’, ‘b’, ‘c’] letters.append(‘d’) print len(letters) print letters 1. In the abo…
- List Slicing
Sometimes, you only want to access a portion of a list. Consider the following code: letters=[‘a’, ‘b’, ‘c’, ‘d’, ‘e’] slice = letters[1:3] print slice print letters What is this code doing? F…
- Slicing Lists and Strings
You can slice a string exactly like a list! In fact, you can think of strings as lists of characters: each character is a sequential item in the list, starting from index 0. my_list[:2] # Grabs th..
- Maintaining Order
Sometimes you need to search for an item in a list. animals = [“ant”, “bat”, “cat”] print animals.index(“bat”) 1. First, we create a list called animals with three strings. 2. Then, we print the…
- For one and all
If you want to do something with every item in the list, you can use a for loop. If you have learned about for loops in JavaScript, pay close attention! They are different in Python. for variable in..
- More with "for"
If your list is a jumbled mess, you may need to sort() it. animals = [“cat”, “ant”, “bat”] animals.sort() for animal in animals: print animal 1. First, we create a list called animals with th...
- This Next Part is Key
A dictionary is similar to a list, but you access values by looking up a key instead of an index. A key can be any string or number. Dictionaries are enclosed in curly braces, like so: d = {‘ke…
- New Entries
Like Lists, Dictionaries are mutable. This means they can be changed after they are created. One advantage of this is that we can add new key/value pairs to the dictionary after it is created l..
- Changing your mind
Because dictionaries are mutable, they can be changed in many ways. Items can be removed from a dictionary with the del command: del dict_name[key_name] will remove the key key_name and its asso...
- Remove a few things.
Sometimes you need to remove something from a list. beatles = [“john”,”paul”,”george”,”ringo”,”stuart”] beatles.remove(“stuart”) print beatles This code will print: [“john”,”paul”,”george”,”ri…]