Python Tutorial - Dive into Python

Welcome to This Course: A Journey Through Data Science with Python

Welcome to this course where you will begin your journey through data science. My name is Hilary Green Lerman, and I'll be your guide to the wonderful world of Python. The purpose of this course is to gently introduce you to programming and data science by playing with some simple data sets. This course is intended for learners with no coding experience, and my aim is to answer all of your questions as we move through the course.

In this course, you'll learn how to write and execute Python code, load data from a spreadsheet file into Python, and turn that loaded data into beautiful plots. By the end of this course, you'll be familiar with Python syntax and ready to learn more while we learn. We'll be solving a mystery using data, someone has kidnapped Bay's Data Camps prize-winning golden retriever. The kidnapper has left clues that we can analyze, and we'll use techniques like chemical analysis and letter frequency to pick the correct suspect.

Before we can solve our mystery, we need to get familiar with how code is written. There are two ways of executing code on Data Camp: the iPython shell located in the bottom right of each exercise, which is sometimes called the console; and the script editor located in the top right of each exercise. The iPython shell allows us to type a single line of code and use the return key to execute that line. This is a good place to experiment with new ideas.

The second way we can enter code is the script editor, which lets us write multiple lines of code as well as comments, which aligns beginning with a pound or hash symbol. When we are ready to execute all of the code in the script editor, we can click "Run Code" when we think our code is correct. We can also click Submit Answer. Now that we know where to write code, let's dive into our first concept: Modules.

Modules Help Group Together Related Tools in Python

Modules help group together related tools in Python. For example, we might want to group together all of the tools that make different types of charts, such as bar charts, line charts, and histograms. Some common examples of modules are matplotlib, which creates charts; pandas, which loads tabular data; scikit-learn, which performs machine learning; sie pi, which contains statistics and NLT K, which works with text data.

We must import any modules that we plan on using before we can write any other code. We do this at the top of the script editor. If we don't import modules, we can't use the tools that they contain. In this example, by importing the modules pandas and matplotlib, we're able to unbox the tools necessary to create a graph in this case, handes gives us the tools to read data from a file and matplotlib gives us the tools to plot the data.

Importing a Module: How It Works

To import a module, simply type "import" followed by a space and then the module name. Oftentimes, module names are long, so we can shorten them by using an alias. To give your module an alias, just add `as` and a shorter name to your original import statement. This statement will alias pandas as PD.

Let's Practice What We've Learned

Now that we've learned about modules, let's practice what we've learned using the console and script editor.

"WEBVTTKind: captionsLanguage: enwelcome to this course where you will begin your journey through data science my name is hilary green Lerman and i'll be your guide to the wonderful world of python the purpose of this course is to gently introduce you to programming and data science by playing with some simple data sets this course is intended for learners with no coding experience all aim to answer all of your questions as we move through the course in this course you'll learn how to write an execute Python code with data camp load data from a spreadsheet file into Python and turn that loaded data into beautiful plots by the end of this course you'll be familiar with Python syntax and ready to learn more while we learn we'll be solving a mystery using data someone has kidnapped Bay's data camps prize-winning golden retriever the kidnapper has left clues that we can analyze we'll use techniques like chemical analysis and letter frequency to pick the correct suspect before we can solve our mystery we need to get familiar with how code is written there are two ways of executing code on data camp the first is the ipython shell located in the bottom right of each exercise in the Python shell which is sometimes called the console we can type a single line of code and use the return key to execute that line this is a good place to experiment with new ideas the second place we can enter code is the script editor located in the top right of each exercise the script editor lets us write multiple lines of code as well as comments which aligns beginning with a pound or hash symbol when we are ready to execute all of the code in the script editor we can click run code when we think our code is correct we can click Submit answer now that we know where to write code let's dive into our first concept modules modules help group together related tools in Python for example we might want to group together all of the tools that make different types of charts bar charts line charts and histograms some common examples of modules are matplotlib which creates charts pandas which loads tabular data scikit-learn which performs machine learning sie pi which contains statistics and NLT k which works with text data we must import any modules that we plan on using before we can write any other code we do this at the top of the script editor if we don't import modules we can't use the tools that they contain in this example by importing the modules pandas and matplotlib we're able to unbox the tools necessary to create a graph in this case handes gives us the tools to read data from a file and matplotlib gives us the tools to plot the data to import a module simply type import followed by a space and then the module name oftentimes module names are long so we can shorten them by using an alias to give your module an alias just add as and a shorter name to your original import statement this statement will alias pandas as PD let's practice what we've learned using the console and script editorwelcome to this course where you will begin your journey through data science my name is hilary green Lerman and i'll be your guide to the wonderful world of python the purpose of this course is to gently introduce you to programming and data science by playing with some simple data sets this course is intended for learners with no coding experience all aim to answer all of your questions as we move through the course in this course you'll learn how to write an execute Python code with data camp load data from a spreadsheet file into Python and turn that loaded data into beautiful plots by the end of this course you'll be familiar with Python syntax and ready to learn more while we learn we'll be solving a mystery using data someone has kidnapped Bay's data camps prize-winning golden retriever the kidnapper has left clues that we can analyze we'll use techniques like chemical analysis and letter frequency to pick the correct suspect before we can solve our mystery we need to get familiar with how code is written there are two ways of executing code on data camp the first is the ipython shell located in the bottom right of each exercise in the Python shell which is sometimes called the console we can type a single line of code and use the return key to execute that line this is a good place to experiment with new ideas the second place we can enter code is the script editor located in the top right of each exercise the script editor lets us write multiple lines of code as well as comments which aligns beginning with a pound or hash symbol when we are ready to execute all of the code in the script editor we can click run code when we think our code is correct we can click Submit answer now that we know where to write code let's dive into our first concept modules modules help group together related tools in Python for example we might want to group together all of the tools that make different types of charts bar charts line charts and histograms some common examples of modules are matplotlib which creates charts pandas which loads tabular data scikit-learn which performs machine learning sie pi which contains statistics and NLT k which works with text data we must import any modules that we plan on using before we can write any other code we do this at the top of the script editor if we don't import modules we can't use the tools that they contain in this example by importing the modules pandas and matplotlib we're able to unbox the tools necessary to create a graph in this case handes gives us the tools to read data from a file and matplotlib gives us the tools to plot the data to import a module simply type import followed by a space and then the module name oftentimes module names are long so we can shorten them by using an alias to give your module an alias just add as and a shorter name to your original import statement this statement will alias pandas as PD let's practice what we've learned using the console and script editor\n"