A Playful Introduction to Programming by Jason R. Briggs

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Introduction to C Programming
Introduction to Python
A First Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Credits: a significant part of.
First Program  Open a file  In Shell  Type into the file: 3  You did it!!! You wrote your first instruction, or code, in python!
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 4: Writing programs.
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Debugging, Escape Command, More Math. It’s your birthday!  Write a program that asks the user for their name and their age.  Figure out what their birth.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
1. Starting 1 Let’s Learn Saenthong School, January – February 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
First Program  Open a file  In Shell  Type into the file: 3  You did it!!! You wrote your first instruction, or code, in python!
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
Few More Math Operators
Thinking about programming
Math operations 9/19/16.
Fundamentals of Programming I Overview of Programming
Introducing Python Introduction to Python.
Development Environment
Whatcha doin'? Aims: To start using Python. To understand loops.
Topics Designing a Program Input, Processing, and Output
Python Let’s get started!.
Introduction to Python
Introduction to Python
Chapter 2 - Introduction to C Programming
Lesson 1 An Introduction
Introduction to Programming
Variables, Expressions, and IO
Thinking about programming
Chapter 2 - Introduction to C Programming
Let's Learn Python and Pygame
Introduction to Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to Java, and DrJava part 1
Chapter 2 - Introduction to C Programming
Learning Outcomes –Lesson 4
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Teaching London Computing
BSc in Digital Media, PSUIC
Introduction to TouchDevelop
Chapter 2 - Introduction to C Programming
Chapter 3 – Introduction to C# Programming
Introduction to Programming
Section 1 Introduction To Programming
Introduction to Java, and DrJava
Python 19 Mr. Husch.
Introduction In today’s lesson we will look at: why Python?
Operations Python code.
Chapter 2 - Introduction to C Programming
Beginning Python Programming
Introduction to Programming
Introduction to Java, and DrJava part 1
Input and Output Python3 Beginner #3.
Introduction to Python
Python 19 Mr. Husch.
Introduction to C Programming
L L Line CSE 420 Computer Games Lecture #3 Introduction to Python.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Presentation transcript:

A Playful Introduction to Programming by Jason R. Briggs Python for Kids A Playful Introduction to Programming by Jason R. Briggs

Computers and Programs A computer is a machine that stores data. A program is a set of instructions that tells a computer what to do with the data.

Why Learn to Program? Makes you a clever user of computers It's fun! You make stuff (programs) that do things Helps you learn problem solving skills Programmers get jobs

Why Learn Python? The Python programming language is aimed at beginners It's easy to learn and use Powerful Lots of program libraries Free Runs on everything Lots of users; lots of help online Used in the real world

Some Companies that Use Python

Starting Python There are two different types of Python windows The Shell – where you run Python commands. These commands are NOT saved as a program IDLE – a Python editor This is the window you type in your program. When you run your program, the results will appear in the shell.

How to Tell if it’s IDLE or the Shell Look at the title bar to see which type of window you are in. The Shell window has the word “Shell” The IDLE window will either say Untitled or have the name of your program

Start IDLE (a Python editor) (on Windows 10)

Inside IDLE I typed help() and <enter> to start "help" I typed quit to leave "help" but still be in the shell

Print() The print() function is used to print out the characters within the parentheses. The message must be in either double quotes, “ “, or single quotes, ‘ ‘ -- You cannot mix the quotes, they both have to be the same.

Simple Program Bring up an IDLE window. On the Shell window, click File  New File

Name Your Program Program names need to be meaningful. Bad program name: stuff Save this program as: first_program.py Python programs end with the extension .py

Type the following - EXACTLY print "Hello World!" print "Hello Again" print "I like typing this." print "This is fun." print 'Yay! Printing.‘ And save your program! Often!!!

Running Your Program To run your program, click Run  Run Module

Output Your output will show up in the shell. Hello World! Hello Again I like typing this. This is fun. Yay! Printing.

Add a line Add another line to your program. Save the program. Run the program.

Pound Sign (hashtag) Put a ‘#’ character at the beginning of a line – any line will do. Save the program Run the program What did the ‘#’ character do?

Comments Comments are very important! Comments tell you what something does in regular English. Comments allow others to easily see what a program does The comment character ‘#’ can be used to disable sections of code.

How to Use Comments # A comment, this is so you can read your program later. # Anything after the # is ignored by python. print ("I can have code.”) # and comments after are ignored # You can also use a comment to "disable" or comment out a # piece of code: # print "This won't run.” print ("This will run.”)

Results I can have code. This will run.

Variables Variables are a container for storing data values. They can be stored within the computer’s memory. Then you can reference the value by using the variable Variable Names Variables can be named almost anything Cannot use Python keywords (more on this later) It’s important to chose meaningful names that reflect the variable’s content

Calculating with Python You can use the Python shell as a calculator The asterisk is the symbol for multiplying >>> 10 * 32.5

Result For the problem: 10 * 32.5 You should have gotten: 325.0

Word Problem Calvin paints pictures and sells them at art shows. He charges $56.25 for a large painting. He charges $25.80 for a small painting. Last month he sold six large paintings and three small paintings. How much did he make in all?

Solving >>> 6 * 56.25 337.5 >>> 3 * 25.80 77.4 >>> 337.5 + 77.4 414.9

Another Way to Solve it – Use Variables >>> a = 6 * 56.25 337.5 >>> b = 3 * 25.80 77.4 >>> a + b 414.9

Python Operators The basic symbols used by Python to perform math operations are called operators.

More Math to Try Try to figure out the answer before typing it in >>> 5 + 3 * 2

More Operators % - modulus // floor division ** exponent < less than > Greater than <= less than or equal to <= greater than or equal to

Modulus Operator This can be a confusing operator The modulus operator divides the first number given by the second number given and returns the remainder. It is NOT a plain division problem The modulus operator is useful in determining whether a number is even or odd

Modulus Example >>> 10 % 3 >>> 3 % 10 >>> 8 % 2 >>> 45 % 8

Results >>> 10 % 3 1 >>> 3 % 10 3 >>> 8 % 2 0 >>> 45 % 8 5 >>>

Floor Division // is the floor division operator It performs just like the / division operator but truncates the results at the decimal point. So instead of seeing an answer like 3.14, you would only get 3