<jupyter_start><jupyter_text>Introduction to Python for Data ScienceActivity 1: Python FundamentalsMaterials made by <NAME> & <NAME>, for the Python Workshop on 12 September, 2018.  Getting StartedLets start by using the print function!<jupyter_code>print('Hello BISA!')<jupyter_output><empty_output><jupyter_text>A variable can hold any value. In the example below, you can store your name (a string) in the variable called "name" (or anything you want).<jupyter_code>name = "xyz" # replace xyz with your name
print("Hello BISA, my name is " + name)<jupyter_output><empty_output><jupyter_text>You can also use Python for simple calculations:<jupyter_code>x = 1 + 2
print (x)
y = 15/4
print (y)<jupyter_output><empty_output><jupyter_text>ListsA list is a sequence of values.<jupyter_code>sponsors = ['EY', 'PwC', 'CBA', 'Deloitte', 'Accenture']
print(sponsors)<jupyter_output><empty_output><jupyter_text>A list can be indexed to extract an element. It is important to note that Python uses zero-based indexing, meaning that the first element is at indexed as zero instead of one.<jupyter_code>sponsors[0] 
sponsors[2]<jupyter_output><empty_output><jupyter_text>IterationThe `for` loop can be used to iterate over a list.<jupyter_code>for name in sponsors:
    print(name)<jupyter_output><empty_output><jupyter_text>Importing Modules/PackagesMost of the fuctionality needed for data science will require importing modules or packages, which must be done every time you run a new notebook. Today we will require the following modules: Numpy, Pandas, Matplotlib, Seaborn.Here, we use the "as" function to shorten the name of the package. So when we need to use package, we can just use the shortened name e.g. `pd` instead of `pandas`... less typing for us!<jupyter_code>import pandas as pd
import numpy as np

import matplotlib.pyplot as plt
import seaborn as sns<jupyter_output><empty_output><jupyter_text>NumPyRecall that we already `import numpy as np`, so we can just call the package using `np`.Below, we use the arrange function from the package to generate an array of 10 numbers starting from 0.<jupyter_code>a = np.arange(10)
print(a)<jupyter_output><empty_output><jupyter_text>You can perform arithmetic operations to the array as well.<jupyter_code>a = a*2
print (a)<jupyter_output><empty_output><jupyter_text>MatplotlibRecall that we already `import matplotlib.pyplot as plt`, so we can just call the package using `plt`.Below, we use the arrange function from the `numpy` package to generate an array of 10 numbers starting from 1 to 10.Then, we use `matplotlib` to plot y = 2x.<jupyter_code>x = np.arange(1,11)
y = 2 * x

print(x)
print(y)

plt.title("Simple plot of y=2x")
plt.xlabel("This is x-axis")
plt.ylabel("This is y-axis")
plt.plot(x, y, 'r') # 'r' is colour of line (red)
plt.show()<jupyter_output><empty_output><jupyter_text>Your Turn!At this stage, we have enough to navigate python and create basic programs. Have a go below! ---**Exercise 1**: <NAME>! - in the cell below, calculate the taxi fare, given the distance travelled and the rate charged by the driver.<jupyter_code>dist = 10
rate = 5
taxi_fare = #your code here!<jupyter_output><empty_output><jupyter_text>---**Exercise 2**: A particular driver has recorded his daily earnings. Help him calculate his total greens for the week. (Hint: you may want to use the `sum()` function and a print statement).<jupyter_code>daily_wage = [85, 70, 90, 75, 180, 420, 360]
#your code here!<jupyter_output><empty_output><jupyter_text>---**Exercise 3**: Given a list of names, add to them a wacky surname and print each name! (Use a For loop to automatically add letters to each name in the list!)<jupyter_code>names = ["Jack", "Daniel", "Barry", "Allen", "Scully", "Hitchcock"] #replace these with your friend's names
#your code here!<jupyter_output><empty_output><jupyter_text>---**Exercise 4**: Let's analyse the data from the Taxi questions. Plot the data from exercise 2 against the days of the week. Remember to import the relevant packagaes first, then follow the scaffold from MatPlotLib demonstration. See any trends?<jupyter_code>#your code here!<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09624639076034648, 'fraction_numerical': 0.013474494706448507, 'mean_word_length': 5.893864013266998, 'pattern_counts': {'":': 0, '<': 60, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '273940', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1299, 'n_words': 516, 'path': 'activity_1.ipynb', 'repo_name': 'jeffreycklo/bisa_python_workshop', 'size': '4171'}