DataScience Project I

Jypyer notebook Important Shortcut Keys

Posted by Nivin Anton Alexis Lawrence on January 2, 2017

Recently by the same author:


Introduction to Functional Programming [Part 2]

Think Functional


Nivin Anton Alexis Lawrence

Human

You may find interesting:


Cybersecurity Project

Online Profile Grader


Datascience Project II

Text Analysis and Entity Resolution

Jypyer notebook Important shortcut keys

Shift + Enter: executes the current cell
Tab: code completion or indent
Shift + Tab: tooltip

Cell Types

Markdown: contains text
Code: contains code

Comments

# one line comment starts with a pound sign
'''
Multi line commnet
Using three 's
'''

print

print 'Hello World'
a = 2
print ("a = " + str(a))

Lists

In python a list can hold obejcts of different types

l = [1, 2, '3', 'Hello']
print l
print l[0] #first item in list
print l[1] #second item in list
print l[-1] #last item in list
print l[-2] #second from last 
l.append('new item')
print l

Dictionaries

Key, value pairs. Unlike lists, dictionaries do not keep any orders for their items and items are accessible using keys. Keya must be unique but values can be repeated.

dict = {'key1': 1, 'key2': "hello", 'key3': 4}
print dict['key2']

#Tuples

Similar to lists but they are immutable. it means that after initializing a tuple its values cannot be changed

t = (1, 2, 3, 4, 1)
len(t) # number of items in t
print ("the frequency of 1 in this tuple is: " + str(t.count(1)))
t[1] # second item
t[1]=2 # error -> tuples are immutable!

Sets

Sets are unordered lists of unique elements. Similar to dictionaries with only keys (no values)

l = [1,1,2,2,3,3,3,4,4] # a list
s = set(l) #repetitive values in l will be removed
print s