Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 9, 2015)

Slides:



Advertisements
Similar presentations
Jason Howard. Agenda I. How to download robotc II. What is tele-op used for? III. How to build a basic tele-op program IV. Getting the robot to drive.
Advertisements

FORTRAN Short Course Week 1 Kate T-C February 17, 2008.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
C Programming for engineers Teaching assistant: Ben Sandbank Home page:
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
Introduction to Primitives. Overview Today we will discuss: –The eight primitive types, especially int and double –Declaring the types of variables –Operations.
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
Python November 14, Unit 7. Python Hello world, in class.
CS 1 with Robots Variables, Data Types & Math Institute for Personal Robots in Education (IPRE)‏
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Exponents Scientific Notation
This presentation will review different math skills that will help you with every day math problems. Each lesson takes approximately 15 minutes to do.
Binary Arithmetic Math For Computers.
Game Programming © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line L.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
An Introduction to Textual Programming
Introduction to Python
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Input, Output, and Processing
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Unit 6 Math Vocab By: Marshall Lockyer. Constant Term A constant term is a term in an equation that does not change Example: a = 6 + b : In this case,
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
PROGRAMMING In. Objectives  We’re learning to develop basic code with the use of the correct syntax and variables. Outcomes  Explain what syntax is.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)
Overview of c++ Objectives 1. Understanding the use of the following elements in a c++ program variables constants assignment input output 2. Writing a.
Math, Data Types. Python Math Operations OperationOperator Addition + Subtraction – Multiplication * Division (floating point) / Division (integer) //
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.
Python Let’s get started!.
Summer AP Chemistry Homework Math Review
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Variables Continued In the last session we saw how variables are objects that allow us to store values in the RAM of the computer In this session we shall.
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.
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
6th Grade Unit 6 By Drew. Constant term Some ting that stay the same like A+0=A no mater what a is it will be a added to 0 Examples Bx0=0 U-0=U.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
Input, Output and Variables GCSE Computer Science – Python.
Math, Data Types. Python Math Operations OperationOperator Addition + Subtraction – Multiplication * Division (floating point) / Division (integer) //
Math operations 9/19/16.
Development Environment
Whatcha doin'? Aims: To start using Python. To understand loops.
Topics Designing a Program Input, Processing, and Output
User-Written Functions
A Playful Introduction to Programming by Jason R. Briggs
Exponents Scientific Notation
Variables, Expressions, and IO
To write a Python program, you first need to open Pyscripter
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Learning Outcomes –Lesson 4
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Introduction to Primitives
Introduction to Primitives
Unit 3: Variables in Java
Input and Output Python3 Beginner #3.
43 Order of Operations  ( ) + - X.
Setting up home folders and roaming profiles
Input, Variables, and Mathematical Expressions
Python Creating a calculator.
Presentation transcript:

Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 9, 2015)

- 2 - Objectives Download, Installation and Setup Write Your First Program More Maths Different Types of Numbers Questions & Answers

- 3 - Setup When the USB is passed to you plug it in and COPY the Folder on your desktop Wait for my instruction! Seriously if you don’t wait you’ll mess up your computer (in the worst way possible), I’ll go through is slowly and ask me any questions if anything looks different for you then when I’m doing it!

- 4 - CMD / Terminal A Command Prompt / Terminal is an entry point for typing computer commands in the Command Prompt / Terminal window. By typing commands at the Command Prompt / Terminal, you can perform tasks on your computer without using the Windows / Mac graphical interface. Python can run within the CMD / Terminal, but for CMD / Terminal to see Python we have to configure the path variables on your computer.

- 5 - Path Config For Windows Right click your computer and go to Properties

- 6 - Path Config For Windows Press Advanced System Settings

- 7 - Path Config For Windows Press Environment Variables

- 8 - Path Config For Windows Look at the box that says User Variables at the top. Press EDIT now add a ; to the end of the current path and add C:/Python after the ; if you don’t have a path already there just paste C:/Python in it and press ok. Restart Your Command prompt and type python in it, if you see >>> That means you have successfully installed python

- 9 - Path Config For Mac Bust out your terminal, and type python in it. If an error happened... Good. Next type vim /etc/paths Than type the path to your python directory with the python.exe in it, to your /etc/paths Restart your terminal and type python in it.

Write Your First Program Bust open your cmd / terminal and type python in it. You Should see something similar to

Write Your First Program Type in print(“Hello World”) You are now part of the 6% of the population that has ever written a program of any type!

What Did You Just Do? The command that you have just written was called print(). Print is a function in python that allows you to display text to the console. CMD / Terminal acts like a console. A console is a text output device for system processes. Basically it allows getting inputs from the user and display outputs easily from python.

Ok. But What Else Can I Do You can also do arithmetic in python. –You can add / subtract numbers, try typing these in – – 10 –As you can see you can add and subtract multiple numbers together and the console will display its interpreted output

More Maths As you can tell you can also multiply and divide. To multiply two numbers together use the * sign. To divide two numbers use the / sign. Test these out. –2 * 2 –3 / 3 –5 * 2 / 2

Adding and Multiplying As you can probably tell you can add subtract multiply and divide all in the same line. Try these examples and try to guess what the output will be. –2 * –8 / 4 * 2 – 8 –3 + 3 * 3 If you guessed 18 for the last one you might have been surprised to find out that the output was 12. This is because python follows PEMDAS.

Orders of Operations P: Parentheses E: Exponents M: Multiply D: Divide A: Addition S: Subtraction Python was designed to use PEMDAS meaning that is Completes parentheses first, than exponents, than multiplication / division, than addition / subtraction.

SO WH3 dose 3+3*3= 12!!!???!!?!?! Python will follow the steps of PEMDAS so it will look at * 3 and do the multiplication first so no * 3 simplifies to 3 + 9, now as you might see now equals to 12 Lets say you wanted to add first. You can add parentheses around to tell python that you want it to combine those first. –(3 + 3) * 3

Practice Try to guess what the outputs for these math operations –2 + 3 * 4 –( / 5) * 11 –( ( ) * ( / 3) ) * 213

More Math Operations Lets say you wanted to use exponents. For example 2 ⁴. Well because it took me 3 minutes to type ⁴, there is a special sign that means “to the power” of and it is ** so instead of 2 ⁴ we have to type 2**4 but they mean the same thing. Try to guess these outputs keep in mind They still apply to the order of operations. –2 ** –3 ** (1 + 1) –(11 + 1) ** (1 * 3 - 1)

Different Types of Numbers Python has several types of numbers. –(int) Integers: numbers without decimal points and has a range from -9,223,372,036,854,775,807 to 9,223,372,036,854,775,807 aka really big number. –(float) floating point number: It a type of number that contains decimle places and has larger maximum and minimum values. (These numbers are dependent on the type of computer aka 64 bit vs 32 bit)

Int Type Operations Ints by them selves have some specific advantages than floats. Like takes up less memory to store, is faster when running python programs, and can be used for other things that we will get in to later. But keep In mind that when you type any number without decimal places Python will assume its an int 7 #this is considered an int 7.0 #this is not considered an int

Floats Floats are useful in storing really large and small numbers. Also Floats are considered precise meaning that you can have a number like Floats are defined with a decimal place in a number. – #is a float –7.0 #is a float –7. #is a float –7 #is not a float

Even More Maths There are two types of division in python. One defined as / and another defined as //. The first one is the slandered division it will divide 3 / 2 and give out 1.5 no problem but a quirk with using the / sign is that the answer will always be in a float. So if you were to divide 3 / 3 the answer will always be 1.0 just like a float. But lets say you didn’t want the.0 after your answer, your gonna have to use the // sign and it will remove all of the numbers after the decimal place and convert it to an int. So 3 // 3 will equal 1; but also keep in mind that any division operation that will give out a decimal will be ignored. For example 3 / 2 will equal 1.5 but 3 // 2 will equal 1. Try these: –3 / 3 –5 / 1 –12 // 4 –12 // 4 / 3

That’s all Now you should be arithmetic professionals

Questions & Answers

© 2014 Chris Trenkov