STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

Similar documents
STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

The >>> is a Python prompt indicating that Python is ready for us to give it a command. These commands are called statements.

My First Python Program

Introduction to Computer Programming for Non-Majors CSC 2301, Fall The Department of Computer Science

Top Down Breaking a Problem Down

STEAM Clown Productions. Python lab. Binary Register. STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

Introduction to Computer Programming for Non-Majors

STEAM Clown Productions. Python-Functions. Page 1

STEAM Clown Productions. Python - Conditional. STEAM Clown & Productions Copyright 2018 STEAM Clown. Last Updated: Thursday, January 24, 2019.

Introduction, Programming, Python. Michael Mandel Lecture 1 Methods in Computational Linguistics I The City University of New York, Graduate Center

CS 190C: Introduction to Computational Thinking

Chapter 2 Writing Simple Programs

Programming with Python

Variables, Expressions, and Statements

STEAM Clown Productions. For Loops. STEAM Clown & Productions Copyright 2018 STEAM Clown. Page 1

CMSC 201 Computer Science I for Majors

Python BASICS. Introduction to Python programming, basic concepts: formatting, naming conventions, variables, etc.

SI Networked Computing: Storage, Communication, and Processing, Winter 2009

Introduction to Python

Table of Contents EVALUATION COPY

Jython. secondary. memory

CHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)

Conditional Execution

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2

Lecture 27. Lecture 27: Regular Expressions and Python Identifiers

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)

The current topic: Python. Announcements. Python. Python

Getting Started with Python

Introduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala

Variable and Data Type I

Introduction to Python

Introduction to Problem Solving and Programming in Python.

ENGR 101 Engineering Design Workshop

CSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output

Python: common syntax

Programming to Python

Getting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013

Fundamentals of Programming (Python) Getting Started with Programming

Beyond Blocks: Python Session #1

Python review. 1 Python basics. References. CS 234 Naomi Nishimura

Python for Non-programmers

Chapter 3 : Informatics Practices. Class XI ( As per CBSE Board) Python Fundamentals. Visit : python.mykvs.in for regular updates

Variable and Data Type I

CSCE 110 Programming I

Part III Appendices 165

PROGRAMMING FUNDAMENTALS

What Version Number to Install

STEAM Clown Productions

Introduction to Python! Lecture 2

Decisions, Decisions. Testing, testing C H A P T E R 7

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

CSI Lab 02. Tuesday, January 21st

SD314 Outils pour le Big Data

Python for ArcGIS. Lab 1.

Key Differences Between Python and Java

Basic Syntax - First Program 1

Lecture 1. basic Python programs, defining functions

Lab 1: Course Intro, Getting Started with Python IDLE. Ling 1330/2330 Computational Linguistics Na-Rae Han

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

Python I. Some material adapted from Upenn cmpe391 slides and other sources

nostarch.com/pfk For bulk orders, please contact us at

CME 193: Introduction to Scientific Python Lecture 1: Introduction

Introduction to Programming

The Three Rules. Program. What is a Computer Program? 5/30/2018. Interpreted. Your First Program QuickStart 1. Chapter 1

CDO-1 Certificate Program: Foundations for Chief Data Officers. Data Wrangling Lab. David /WEI DAI. Sept 26-29, 2016 (c)

The Dynamic Typing Interlude

STATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration

Control Structures 1 / 17

Flow Chart & Algorithms

CSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

COMP519 Web Programming Lecture 17: Python (Part 1) Handouts

Algorithms and Programming I. Lecture#12 Spring 2015

Introduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

About Variables in Python F E B 1 1 T H

Senthil Kumaran S

Variables, expressions and statements

CS 1301 Exam 1 Fall 2009

THE IF STATEMENT. The if statement is used to check a condition: if the condition is true, we run a block

MITOCW watch?v=0jljzrnhwoi

Data Handing in Python

CPTS 111, Fall 2011, Sections 6&7 Exam 3 Review

Functions, Scope & Arguments. HORT Lecture 12 Instructor: Kranthi Varala

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Python Unit

EXPRESSIONS, STATEMENTS, AND FUNCTIONS 1

Strings. Chapter 6. Python for Everybody

Python Basics. Lecture and Lab 5 Day Course. Python Basics

Spring Semester 11 Exam #1 Dr. Dillon. (02/15)

Some material adapted from Upenn cmpe391 slides and other sources

Visualize ComplexCities

Accelerating Information Technology Innovation

And Parallelism. Parallelism in Prolog. OR Parallelism

Python Tutorial. CSE 3461: Computer Networking

Introduction to Programming with JES

Transcription:

What to add next time you are updating these slides Update slides to have more animation in the bullet lists Verify that each slide has stand alone speaker notes Page 1

Python 3 Running The Python Interpreter A Python class for my Mechatronics Engineering @ SVCTE. Last Updated for 2017 2018 school year Page 2

Page 3 These slides are an adaption, to better target my SVCTE High School Mechatronics Engineering class, primarily from Dr. Charles R. Severance s Python for Everybody class https://www.py4e.com/ but from other sources as well. See Appendix A See Appendix A, for Licensing Attribution information by-nc-sa-3.0 https://creativecommons.org/licenses/by-nc-sa/3.0/ https://creativecommons.org/faq/#what-does-some-rights-reserved-mean

OK, Remember where to get Resource support? Dr. Charles R. Severance We are going to use a few resources on the internet Bookmark and remember a few sites SVCTE Mechatronics Python Resource link Python Resources Python 4 Everybody - https://www.py4e.com/ Page 4

Interpreter vs Compiler Page 5 Compiled language like C++ Write source code Human readable Then you compile the code to an executable (.exe) Double click the.exe and it will run Interpreted language like Python Run source code directly, because you are running with/through the Python interpreter Actually running the Python program and passing it your source code Not Stand alone. Requires the Python interpreter to be installed or accessed

Open a Cygwin terminal Open a Cygwin terminal $ ls $ pwd Page 6

Start Python3 Page 7

Remember Hello World? The >>> is a Python prompt indicating that Python is ready for us to give it a command. These commands are called statements Page 8 >>> print("hello World ) Hello World >>> print(2+3) 5 >>> print("2+3=", 2+3) 2+3= 5 >>>

Python does it s best to Interpret At The >>> prompt, Python will make a lot of assumptions about what you are trying to do or infer Here it is assuming integer math Page 9 >>> 2+3 5 >>> 2+3*3 11 >>> (2+3)*3 15

Types of results as we do Math Integer Float Long >>> 2+3 5 >>> 2+3.14 5.15 >>> 10**100 Page 10

Reserved Words Page 11 You cannot use reserved words as variable names / identifiers False class return is finally None if for lambda continue True def from while nonlocal and del global not with as elif try or yield assert else import pass break except in raise

Parts of Speech x = 2 x = x + 2 print(x) Assignment statement Assignment with expression Print statement Variable Operator Constant Function Page 12

Objects Everything in Python is an object that has: an identity (id) a type a value (mutable or immutable) Page 13

Value Mutable: When you alter the item, the id is still the same. Variables, Dictionary, List a=a+1 Page 14 Immutable: String, Integer, Tuple 5 3.14 Hello, X, C 4

Lab#1.1 Do some math Make some variable assignments >>>i=90 >>>print i*(i+10) 9000 Can you run more than 1 line of code? Page 15

Python Function You can mix types in evaluations You can create structures like an If statement >>> x = 34 23 >>> y = "Hello >>> z = 3.45 >>> if z == 3.45 or y == "Hello":... x = x + 1... y = y + " World >>> print(x)??? >>> print(y)??? Page 16 >>>

Python Function Usually we want to execute several statements together that solve a common problem. One way to do this is to use a function >>> def hello(): print("hello") print("computers are Fun") Page 17 >>>

Parsing a function >>> def hello(): print("hello") print("computers are Fun") >>> The first line tells Python we are defining a new function called hello The following lines are indented to show that they are part of the hello function The blank line (hit enter twice) lets Python know the definition is finished Page 18

Running a python function >>> def hello(): print("hello") print("computers are Fun") >>> Nothing has happened yet! We ve defined the function, but we haven t told Python to run the function! A function is invoked by typing its name Page 19 >>> hello() Hello Computers are Fun >>>

Passing Parameters or Variables What s the deal with the () s? Commands can have changeable parts called parameters that are placed between the () s >>> def greet(name): print("hello",name) print ("I m Sorry",name,"I'm afraid I can't do that") Page 20 >>> https://www.youtube.com/watch?v=arj8cagm6je

Calling a Function with a parameter >>> greet("terry") Hello Terry I m Sorry, I can t do that Terry >>> greet("paula") Hello Paula I m Sorry, I can t do that Paula >>> Page 21 When we use parameters, we can customize the output of our function

Lab#1.2 Create a Function That takes a int variable and a string variable Do some math and string concatenation Print some results Page 22

The Magic of python When we exit the Python prompt, the functions we ve defined cease to exist! Programs are usually composed of functions, modules, or scripts that are saved on disk so that they can be used again and again A module file is a text file created in text editing software (saved as plain text ) that contains function definitions. A programming environment is designed to help programmers write programs and usually includes automatic indenting, highlighting, etc Page 23

Why is the python run time interpreter? Great for testing some code really quick If you want to debug some code See if you have the syntax right But you would not want to use it for complex or lots of lines of code Page 24

Summary int, float, long, string Functions Making Code Modular Passing Variable Next Steps? Running code outside the >>> Interpreter Page 25

Appendix Page 26

Appendix A: License Attribution These slides are an adaption, primarily from Dr. Charles R. Severance s Python for Everybody class https://www.py4e.com/ Additionally this interpretation is primarily the Intellectual Property of Jim Burnham, Top STEAM Clown, at www.steamclown.org contact @ topclown@steamclown.org This presentation and content is distributed under the Creative Commons License CC-by-nc-sa-3.0 My best attempt to properly attribute, or reference any other sources or work I have used are listed in Appendix B Page 27

Appendix B: Attribution for Sources Used Charles R. Severance slides can be found on the https://www.py4e.com/ site are Copyright 2010- Charles R. Severance (www.dr-chuck.com) of the University of Michigan School of Information and made available under a Creative Commons Attribution 4.0 License. Please maintain this last slide in all copies of the document to comply with the attribution requirements of the license. If you make a change, feel free to add your name and organization to the list of contributors on this page as you republish the materials. Initial Development: Charles Severance, University of Michigan School of Information Modifications and Adaptions by Jim Burnham, Top Clown @ www.steamclown.org Another great Python site is Barbara Saurette AKA mechanicalgirl and her Github site Additionally used some content from slide deck from Mr Ganesh Bhosale found https://github.com/gdbhosale/python-rpi/blob/master/python1.pdf Page 28

Reference Slides Page 29

Page 30

Page 31