The Python Planner A complete beginner's guide to building Python programs in 30 minutes a day By Orthi Rabbane The Python Planner by Orthi Rabbane.
www.ThePythonPlanner.com
2018 Orthi Rabbane Cover by Orthi Rabbane.
All rights reserved. No portion of this book may be reproduced in any form without permission from the author, except as permitted by U.S. copyright law. For permissions contact:
hello@thepythonplanner.com CONTENTS Introduction If you have ever studied abroad in a country where you did not speak the language well, you can agree that there is no faster way to learn a language than to be fully immersed in its culture of origin.
Armed with only the basics of grammar and vocabulary, you learn quickly through necessity and the desire to more deeply experience your new countrys language and culture. Every minute of interaction in this new language is a test of your comprehension, recall, and commitment to keep trying. Learning a programming language works similarly. Your recall and depth of understanding is more significant if you are forced to solve problems regularly in the course of learning. By repeatedly using your newly-learned skills, you can get familiar and confident with them, even if that means initially getting over the barriers of figuring out how to speak to a computer. This book strives to provide you with the same immersive language-learning experience you would gain in visiting a foreign country.
By centering on skill-building and problem-solving, this book will help you get you started in writing useful programs in Python right away. Consider this to be your Python study abroad program. The Python Planner The Python Planner provides a minimal and functional approach to learning Python for the complete beginner. It uses basic, immersive principles of learning that can be applied to understanding any language. Programming requires following the logic and syntax of a computer language to communicate with a computer and tell it what to do. Python is intuitive, user-friendly, and reads like English, so it provides an accessible path to learning to program.
Its users are a large and growing community of professionals of all industries. They use Python as their tool of choice to automate workflow and create web applications, predictive algorithms, and entire research pipelines. The Approach Over the course of a month, you will learn to create useful programs that pull data from the internet, automate routine processes, and more. Each days prompt focuses on a set of skills or a task that takes less than thirty minutes to complete. You will be building your programming skills over four weeks, with your learning divided into four categories which change weekly: Week 1: Skill Week You will learn to apply basic Python syntax and methods through brief lessons. Week 2: Guided Project Week You will use the skills and methods you learned during Skill Week to build complete programs.
Week 3: Library Week You will begin working with Python libraries and get familiar with some of the most popular ones available online. Week 4: Web Project Week You will combine core Python methods and popular libraries to build programs that interact with the web and data. Installation We will use the Anaconda distribution of Python for this book. This installation is pre-packaged with many useful libraries as well as the Spyder editor. Choose the Python 3.6 distribution available for your system: https://www.anaconda.com/download/ You will also need to download and unzip a course materials file which includes the Python programs created in this book. Download the zip file: https://www.thepythonplanner.com/ Now, youre ready for your first lesson! 1.
Skill Week The first week is Skill Week. You will learn the fundamentals of programming necessary to create useful programs. All exercises will build upon these concepts. Lesson Code As you run each line of code in the book, try to predict what the output of the code will be. Exercises For each exercise, you will either be prompted to guess what the output will be or write your own code. In both of these cases, use the materials from the lesson to brainstorm a solution before getting started.
The notes from the section are all you will need to complete these exercises. Solutions Files Each day's lesson is paired with a solution file that you can find in the folder accompanying this guide. Use this file whenever you are stuck in the lessons, ready to check your exercises, and as a reference when you write new code. Explore The vast majority of your Python coding journey will involve researching and learning to use solutions that have already been created and building upon them. The Explore sections of each lesson will require you to use resources outside of this book and become familiar with the Python community. 1.1 Spyder Spyder is an editor included as a part of your Anaconda installation that makes it easy to write and run Python programs. 1.1 Spyder Spyder is an editor included as a part of your Anaconda installation that makes it easy to write and run Python programs.
Find and open Spyder on your system. Menu Bar
We will be using the Run file and Run selection or current line buttons on the menu bar. We can find these by hovering over the buttons. Editor
Python programs are saved as .py files. Use Save As from the File menu to save the current file as skill1.py in the SkillsWeek folder of the directory of files you unzipped. Do this step for each lesson, changing the file name appropriately.
Console
This is the Python console where you can see output from your Python code, either by typing a command directly into the Console or by running a Python program from your editor. Print The print command lets you output text to your console. Type the following command into the Console and hit Enter on your keyboard: print ( 'Hello' ) Notice that the console did not output the quotation marks. You have the same output when you use double quotation marks. Python treats everything within the outermost quotations as text. print ( "Hello" ) Exercise 1
Print the words 'Hello, World', without quotes, by entering a command in the Console.
Typing commands and running them individually can be time-consuming, especially if you want the same output multiple times.
To save time, we can make a program that we can rerun. In the Editor (not the Console), type the following in skill1.py: print ( 'Hello' )
print ( Hi )
print ( Hello, World ) Either click Run or hit F5 on the keyboard to run your program. Notice that each line is given its own line in the output. Exercise 2 Run only the first two lines of your program without deleting any lines. Now, run each line individually by highlighting the line or placing your cursor in the line and clicking the Run Selection button or pressing F9. Note: Placing the cursor will only run a single line at a time; you can highlight-select more than one line.
Exercise 3
Write a print command that has the following output: She says Hello, World.
Explore Play around with the Spyder interface and test some keyboard commands. Jot down a few keyboard commands that you think are useful. 1.2 Data Types, Variables and Operators Objects and Functions A Python object is an instance of information that the computer will use in a command or program. A function performs a single action using objects. In the following command, the print function is used with the object 'Hello' as an input. print ( 'Hello' ) Object Types You can see what type of data an object is in Python by using the type() command in a similar way that you used the print() command. print ( 'Hello' ) Object Types You can see what type of data an object is in Python by using the type() command in a similar way that you used the print() command.
Next page