Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

C Functions. What are they? In general, functions are blocks of code that perform a number of pre-defined commands to accomplish something productive.
16-May-15 Sudden Python Drinking from the Fire Hose.
Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax
Python November 14, Unit 7. Python Hello world, in class.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
 2002 Prentice Hall. All rights reserved. 1 Intro: Java/Python Differences JavaPython Compiled: javac MyClass.java java MyClass Interpreted: python MyProgram.py.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
Introduction to Python and programming Michael Ernst UW CSE 190p Summer 2012.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
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 #001 (January 9, 2015)
Python Programming Using Variables and input. Objectives We’re learning to make use of if statements to enable code to ask questions. Outcomes Build an.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Java Data Types Assignment and Simple Arithmetic.
Building Java Programs Primitive Data and Definite Loops.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Introduction to Python and programming Ruth Anderson UW CSE 140 Winter
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
Solving Linear Equations. Example 1 It’s obvious what the answer is. However, we need to start with the basics and work our way up because we need to.
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.
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
Cosc175/operators1 Algorithms computer as the tool process – algorithm –Arithmetic: addition,subtraction,multiplication,division –Save information for.
Python Let’s get started!.
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.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Primitive Data Types. int This is the type you are familiar with and have been using Stores an integer value (whole number) between -2,147,483,648 (-2.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Course A201: Introduction to Programming 09/09/2010.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
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.
GCSE COMPUTER SCIENCE Practical Programming using Python Lesson 4 - Selection.
Lesson 03: Variables and Types
GCSE COMPUTER SCIENCE Practical Programming using Python
Whatcha doin'? Aims: To start using Python. To understand loops.
A Playful Introduction to Programming by Jason R. Briggs
A basic tutorial for fundamental concepts
Python Let’s get started!.
Introduction to Python
Line Continuation, Output Formatting, and Decision Structures
Building Java Programs
Introduction to Python and programming
Primitive Data, Variables, Loops (Maybe)
Variables, Expressions, and IO
Introduction to C++ October 2, 2017.
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Line Continuation, Output Formatting, and Decision Structures
Introduction to Python and programming
Introduction to Python and programming
Learning Outcomes –Lesson 4
Coding Concepts (Sub- Programs)
Lesson 03: Variables and Types
Introduction to Python and programming
Algorithms computer as the tool process – algorithm
Programming In Lesson 4.
Unit 3: Variables in Java
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Introduction to Python and programming
Class code for pythonroom.com cchsp2cs
Hardware is… Software is…
Presentation transcript:

Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)

- 2 - Objectives Review, review, review, review, review, review; REVIEW Review on world politics, and the effects on the French economy after world war 2 Review on everything we have learned There will be more review after the review Questions & Answers

- 3 - IDLE IDLE, is what’s used to code python, its called IDLE just incase you seemed to of forgotten, It is better than the command line in every way, this is what were using. IDLE. IDLE has 2 modes, one mode is the command line mode. It works just the same as the command line, but is white and has color; the other mode is for writing multi lined programs and saving them. Please never make me have to open IDLE for you again.

- 4 - Everything we know so far These are the things we all should know by now, but we will be going over them with small practices, and less images Data types Arithmetic stuff Variables Boolean type operators If statements Else statements Functions

- 5 - Data types Data type is anything that is represented as a values in Python 10 – int 10.1 – float / double (not really though (but that is for a nother lesson) ) “I am word” – string True - boolean

- 6 - Small exercise Can you name these data types “10.1” 22.0 True “False” -123

- 7 - Converting data types In python you can convert data types to each other here are the example conversion types str() – converts anything to a string int() – converts anything to an integer float() – converts anything to a float bool() – converts anything to a boolean

- 8 - Fun exarcises Here are some intuitive conversions str(12) int(7.5) float(7) int(“-12”) Here are some not so intuitive, try to guess them str(False) Int(True) float(false) bool(0) bool(1) bool(1337)

- 9 - Arithmetic This is a simple one + adds two numbers/strings - subtracts two numbers * multiplies two numbers / divides two numbers and will give decamle ** is an exponent like 2 ^ 2 but with two stars like 2 ** 2 // is divide also but it gives back an integer

Comparative type operators Comparative types operators are just like Arithmetic type operators but with booleans == equals - if both values are the same it returns true <= less than or equal to – compares if the integer in front is less than the second one >= greater than or equal to – compares if the integer in front is more than the second one;

Comparative type operators 2 Comparative types operators are just like Arithmetic type operators but with booleans and And: if both booleans are true it returns true Or Or – if at least one of the booleans are true it returns True, other wise its false

If statements If statements allow for logic In your code, it takes three steps to write an if statement 1 type if 2 put parentheses after the if like if() 3 put a colon after it if(): That’s all it takes to write an if statement, now all you have to do is fill it up with a boolean in the middle

Example if All of these ifs have a boolean inside of it Tell them to type it in their IDLE

Write your own if Write an if that compares if 10 is less than 10.1 and if 1 equals to 1

Ifs I hope yall are good with if statements now, Any questions, if no one says anything and say your good, you better never ask me a question again, and go to MIT to graduate right now with a comp sci degree in Python analitics(I am just kidding of Course)

One Input for functions When you define a function, inside the brackets, you can tell python you want an input by giving it a new variable to use. like

When you define an input As you can see, at the top of the function, specified to python that this function requires one input, (name). This variable is only visible inside the function.

Defining multiple inputs Obviously in python you can define multiple inputs, but to do that all you have to do is create more variables and separate them with commas, and when you use them you call them you give the required inputs to run the function

Lets make an adding function Even though this function will be useless in real world applications, it is still good practice. First we define our function and call it like addSum() or something, then we define 2 inputs, them inside the function, we add them together and store it into a variable, then we print the variable!

Out puts Lets say you want your function to give you a number as an output, instead of printing every thing. All you have to do is type return and give it a variable to return like

Did it do anything? If you typed that out and compiled it, you'll see that nothing “appeared” to of happened. Well something did happen you just can’t see it. When you called the function it returned a number for your to use, all you have to do to get that number is to set it equal to a variable, as you can see it is now treated as a number

Seriously????!!?!?!? Are there any questions, or concerns, would you like me too explain something again, This is the most fundamental part of programming, and is what allows you to do some really awesome things later down the line

Questions & Answers

© 2014 Chris Trenkov