Python Jim Eng Vote on class policy In lecture we discussed several ways in which you might show credits for content in the web pages.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

The Web Warrior Guide to Web Design Technologies
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
I210 review Fall 2011, IUB. Python is High-level programming –High-level versus machine language Interpreted Language –Interpreted versus compiled 2.
Computer Science 103 Chapter 3 Introduction to JavaScript.
Intro to Robots Robots are Everywhere. Intro to Robots Various robots in use today lawnmower pet baby seal for convalescents gutter cleaner home security.
Introduction to Python
Chapter 2 Writing Simple Programs
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Variables, Expressions, and Statements
Introduction to JavaScript for Python Programmers
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
Chapter 9 IF Statement Bernard Chen. If Statement The main statement used for selecting from alternative actions based on test results It’s the primary.
Python.
INLS 560 – V ARIABLES, E XPRESSIONS, AND S TATEMENTS Instructor: Jason Carter.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
JavaScript – Part II Data Types and Operations George Mason University June 3, 2010.
CS1022 Computer Programming & Principles Lecture 1.2 A brief introduction to Python.
CPTR 124 Review for Test 1. Development Tools Editor Similar to a word processor Allows programmer to compose/save/edit source code Compiler/interpreter.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Introduction to Computer Systems and the Java Programming Language.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
Variables and Expressions CMSC 201 Chang (rev )
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
HTTP - Forms - AppEngine Jim Eng
Functions Chapter 4 Python for Informatics: Exploring Information
Variables, Expressions, and Statements
9/14/2015BCHB Edwards Introduction to Python BCHB Lecture 4.
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Python Let’s get started!.
Midterm Review Important control structures Functions Loops Conditionals Important things to review Binary Boolean operators (and, or, not) Libraries (import.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
PYTHON VARIABLES : CHAPTER 2 FROM THINK PYTHON HOW TO THINK LIKE A COMPUTER SCIENTIST.
I NTRODUCTION TO PYTHON - GETTING STARTED ( CONT )
Python Basics  Values, Types, Variables, Expressions  Assignments  I/O  Control Structures.
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Python Files and Lists. Files  Chapter 9 actually introduces you to opening up files for reading  Chapter 14 has more on file I/O  Python can read.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
PHP using MySQL Database for Web Development (part II)
Chapter 2 Writing Simple Programs
CMSC201 Computer Science I for Majors Lecture 02 – Intro to Python
CS1022 Computer Programming & Principles
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Python Let’s get started!.
Presented By S.Yamuna AP/IT
Variables, Expressions, and Statements
JavaScript.
Chapter 10 Programming Fundamentals with JavaScript
More Selections BIS1523 – Lecture 9.
IDLE Hints To re-load a module after making changes:
Lecture 2 Python Programming & Data Types
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Practice with loops! What is the output of each function below?
Variables, Expressions, and Statements
Introduction to Python
Introduction to Programming
Lecture 2 Python Programming & Data Types
Python for Informatics: Exploring Information
Variables, Expressions, and Statements
Unit 3: Variables in Java
Introduction to Programming
Hardware is… Software is…
CMPT 120 Lecture 4 – Unit 1 – Chatbots
COMPUTING.
Presentation transcript:

Python Jim Eng

Vote on class policy In lecture we discussed several ways in which you might show credits for content in the web pages you submit in this course. Please vote for the option below you most favor as the standard way in which credit for images (your own and from other sources) and other content should be shown in your assignments. 31 votes (out of 65)

A credit should be shown in the webpage with each image and with any text or other content from other sources. Credit for each image and for any text or other content from other sources should be shown as comments within the HTML file so they can be seen by viewing the HTML source. Credit for each image and for any text or other content from other sources should be shown in "alt" or "title" attributes within the HTML file so they can be seen by hovering over the element. Credit for each image and for any text or other content from other sources should be collected in a text file to be uploaded along with the other files when submitting an assignment.

A credit should be shown in the webpage with each image and with any text or other content from other sources. 13 Credit for each image and for any text or other content from other sources should be shown as comments within the HTML file so they can be seen by viewing the HTML source. 7 Credit for each image and for any text or other content from other sources should be shown in "alt" or "title" attributes within the HTML file so they can be seen by hovering over the element. 7 Credit for each image and for any text or other content from other sources should be collected in a text file to be uploaded along with the other files when submitting an assignment. 4

Patterns in programming - 1 Sequential steps Conditional steps Repeated steps Stored and reused steps

add 300 grams of flour add 100 ml of milk add an egg if altitude > 2000: add an egg add 30 grams of salt while there are too many lumps: beat mixture with a fork open and add provided flavor packet

add 300 grams of flour add 100 ml of milk add an egg if altitude > 2000: add an egg add 30 grams of salt while there are too many lumps: beat mixture with a fork open and add provided flavor packet

Patterns in programming - 2 Input Processing Output usf = input("Enter the US Floor Number: ") wf = usf - 1 print "Non-US Floor Number is ",wf

print "Your guess is", guess answer = 42 if guess < answer : print "Your guess is too low" if guess == answer : print "Congratulations!" if guess > answer : print "Your guess is too high"

print "Your guess is", guess answer = 42 if guess < answer : print "Your guess is too low" if guess == answer : print "Congratulations!" if guess > answer : print "Your guess is too high" Logical expressionsTrue or false?

print "Your guess is", guess answer = 42 if guess == answer : print "Good guess" else: print "Bad guess"

print “Bad guess” true false answer = 42 print “Good Guess” guess == answer

print "Your guess is", guess answer = 42 if guess == answer : print "Congratulations!" else: if guess < answer : print "Your guess is too low" else: print "Your guess is too high"

print "Your guess is", guess answer = 42 if guess == answer : print "Congratulations!" else: if guess < answer : print "Your guess is too low" else: print "Your guess is too high" Nested if-else statement

true false answer = 42 print “Congratulations” guess == answer print “Too High” true false print “Too low” guess < answer

print "Your guess is", guess answer = 42 if guess == answer : print "Congratulations!" elif guess < answer : print "Your guess is too low" else: print "Your guess is too high"

print “Congrats” true false answer = 42 guess == answer true false guess < answer print “Too low” print “Too high”

Variables A way of assigning a name for an area of memory A way of saving data temporarily Called a “variable” because contents can change Value of variable remains the same until it is changed or discarded

Assignment statements Sets the value of a variable Assign the value 42 into the variable named ‘answer’ Assignment operator (‘=’) not equality operator (‘==’) answer = 42 guess == answer

Elevator-floor conversion example Two variables Two assignment statements Input function Expression usf = input("Enter the US Floor Number: ") wf = usf - 1 print "Non-US Floor Number is ",wf

Expressions (usf - 1) is an expression (usf - 1) means retrieve the value of usf and subtract one from it oh, yeah, and save it in the variable wf wf = usf - 1

Elevator-floor conversion example usf = input("Enter the US Floor Number: ") print "Non-US Floor Number is ",(usf - 1) an expression can appear anywhere a variable can

Variable names in Python Must start with a letter or underscore Consist of letters, underscores, numbers Case-sensitive ( myVariable is not the same as myvariable ) Choose meaningful, mnemonic variable names

Reserved words and del from not whileas elif global or withassert else if pass yieldbreak except import printclass exec in raisecontinue finally is returndef for lambda try Have special meanings Cannot be used as variable names, function names, etc

Constants Values that never change usf = input("Enter the US Floor Number: ") wf = usf - 1 print "Non-US Floor Number is ",wf

print "Your guess is", guess answer = 42 msg = "" if guess == answer : msg = "Congratulations!" elif guess < answer : msg = "Your guess is too low" else: msg = "Your guess is too high" print msg

Strings - 1 txt = "guess=25" print txt[0] print txt[5] print txt[2:4] print txt[:5] print txt[6:] print txt[8]

Strings - 2 think = "happy" + "thoughts" print think think = "happy" + " " +"thoughts" print think

Defining functions - 1 def noParamsNoReturn():print "This function has no parameters and no return"returndef noParamsReturn(): print "This function has no parameters"return 123 noParamsNoReturn() print noParamsReturn()

Defining functions - 2 def paramsNoReturn(num):print "This function received a parameter of ",numreturndef paramsReturn(num): print "This function received a parameter of ",num return num * 5 paramsNoReturn(54) paramsReturn(20)

More examples Strings, String functions, Concatenation Types and Conversion Lists, List functions Integers and Floats Your own functions