 Computer Science 1MD3 Introduction to Programming Michael Liut Brandon Da Silva

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Advertisements

 Computer Science 1MD3 Introduction to Programming Michael Liut Brandon Da Silva
Introduction to Perl Bioinformatics. What is Perl? Practical Extraction and Report Language A scripting language Components an interpreter scripts: text.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Python Crash Course by Monica Sweat. Python Perspective is strongly typed, interpreted language is used to define scripts (Don't even need to define a.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
Recitation 1 Programming for Engineers in Python.
Computer Science 101 Introduction to Programming.
Introduction to Python Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
An Introduction to Textual Programming
INTERNET APPLICATION DEVELOPMENT For More visit:
Introduction to Python
Nael Alian Introduction to PHP
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
Introduction to Programming Peggy Batchelor.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Computer Science 101 Introduction to Programming.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Computer Science 101 Introduction to Programming.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
 Computer Science 1MD3 Introduction to Programming Michael Liut Brandon Da Silva
A First Look at Java Chapter 2 1/29 & 2/2 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
ITM © Port, KazmanVariables - 1 ITM 352 Data types, Variables.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
Strings, output, quotes and comments
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
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.
Python Let’s get started!.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
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.
PHP Form Processing * referenced from
ITM © Port, KazmanVariables - 1 ITM 352 Data types, Variables Class #4.
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.
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
Getting Started With Python Brendan Routledge
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Fundamentals of Programming I Overview of Programming
CST 1101 Problem Solving Using Computers
Whatcha doin'? Aims: To start using Python. To understand loops.
Python Let’s get started!.
Introduction to Python
Design & Technology Grade 7 Python
PHP Introduction.
Engineering Innovation Center
Introduction to Python
File Handling Programming Guides.
Variables ICS2O.
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Introduction to TouchDevelop
Introduction to programming with Python
Introduction to Programming with Python
Tutorial 10: Programming with javascript
Primitive Types and Expressions
Input and Output Python3 Beginner #3.
General Computer Science for Engineers CISC 106 Lecture 03
Hardware is… Software is…
Programming for Business Computing Introduction
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

 Computer Science 1MD3 Introduction to Programming Michael Liut Brandon Da Silva Ming Quan Fu Winter

Introduction  Computer Science Students  Easily Approachable  Office Hours Held By Graduate TA & Professor – TBA  Us!

Class Resources   All announcements, assignments, marks, and course material will be posted here.

Setting up Python  Download the installation file from the web   Click on “Download” on the left  Download the Python installation file  Make sure you are selecting the right file as there are different files for different Operating Systems.  There is a difference between 32- and 64-bit operating systems  Need Help? p/help.cgi p/help.cgi

Using IDLE  To open up IDLE, click…  Start > All Programs > Python 3.3 > IDLE (Python GUI)  To create a new program, click…  File > New Window  To edit a program, click…  File > Open

Text Editors  You may use any you wish. Python has its own text editor.  Others:  Notepad++  TextWrangler  Sublime Text

Who uses Python?  Python is known as a programming language for everyone, as beginners, professionals, and even computer scientists use it for programming  Beginners enjoy Python’s simplicity, and particularly like its ‘batteries included’ appearance, meaning that with one simple download, one has everything they need for basic programming without having to import or download more add-ons.  Professionals and computer scientists often use Python as an alternative to Perl, for its scripting and string manipulation capabilities, yet its syntax is not as cryptic as other languages  Python has been used by companies like IBM, Disney, NASA, Google, Dropbox, Industrial Light and Magic, and Zope Corporation.

How easy is it to learn?  Very easy to learn and experiment with  Interactive Environment  Compatible with many platforms  Designed for beginners and advanced programmers  One of the easiest languages to learn  Python documentation 

 Learning to Program /cs1md3

The Beginning  Two main ways to program in Python, Interactive Mode Programming or Script Mode Programming  We use Script Mode Programming  Basics:  Commenting  # in Python instead of // in Java  New line in text  \n  Tab  \t

Variables NameExample String (holds numbers and text)stringVariable = “Hello world!” Boolean (True or False value)booleanVariable = True *Note: True and False must have the first letter capitalized Integer (a positive or negative whole number) intVariable = 123 Floating-Point Numbers (a positive or negative number with a decimal) floatVariable = 1.0 Imaginary Numbers (square root of - 1, represented by a j ) imaginaryVariable = 12j

Naming Conventions General Naming  Use meaningful names  Use words existing in the terminology of the target domain  AVOID EXCESSIVELY LONG NAMES  Use names relative to what you are assigning

Naming Conventions (ctd) Variable Names  Single word variable names are all lower case  Example: “age”, “gender”, etc.  Multiple word variable names capitalize the first letter of the SECOND word in the variable  Example: “firstName”, “lastName”, “pointScored”

Naming Conventions (ctd) Constants  USE ALL CAPS  Example: “WIDTH”, “LENGTH”, etc.  Multiple words are separated but underscores “_”  Example: “SCREEN_SIZE”, “MAX_AGE”

Declaring Variables firstName is a type string age is a type integer firstName = “Bob” age = 17

Printing Text  As mentioned earlier, Python is known for its “batteries included” appearance, meaning you do not have to import to print text  Example: Printing a string print(“Hello World!”) >> Hello World!

Text and Variables  There are two basic ways to display variables when outputting text in Python  Examples: Printing print(“Here is an example with text and variables: %s %d %f” %(“ABC”, 123, 3.14)) >> Here is an example with text and variables: ABC print(“My name is ” + firstName + “, I am ” + str(age) + “ years old”) >> My name is Bob, I am 17 years old

Common String Functions text = “Hello World!” print(text.count(“l”)) >> 3 Count how many of a letter or word is in the text print(text[6:11]) >>World Extract substrings (reminder that the first letter of the text is 0, like in arrays) print(text.lower()) >> hello world! print(text.upper()) >> HELLO WORLD! Change to lower/upper case print(text.replace("Hello", "Goodbye")) >> Goodbye World! Replace the first world in the brackets, with the second word in the brackets  There are a lot of string functions! Here are a few:

Print Functions  print(“Here is an example with text and variables: %s %d %f” %(“ABC”, 123, 3.14))  The percent signs represent the type of variable being outputted – MUST MATCH  print(“Make a new line\n”)  “\n” at the end of text creates a new line

Keyboard Input  In Python, the input function reads anything that the user inputs as a string Example Keyboard Input number = input (“Insert a number: ”)

If Statements If Statement if number == 1: print(“The number is 1”) elif number > 1: print(“The number is ” + number) else: print(“Please choose a different number”)

While Loop Python 3 Example: counter = 0 go = True while go == True: if counter == 2: go = False print(“Gone”) else: counter += 1 print(“Going…”)

For Loop  In Python, you use something called the for… in… loop  In Python it is set up as:  for in range (,, ):  Example Python for i in range (10, 0, -1): print("T-minus: " + str(i))

Working with Lists in Python grades = [89, 76, 92, 83] grades.append(94) print(grades) >>[89, 76, 92, 83, 94] Appending a number to a list adds it to the end of the list. grades.insert(2, 67) print(grades) >>[89, 76, 67, 92, 83] The first number in the brackets when inserting a number tells Python where in the list you want to put it. Like in Java, the list starts at 0. All the other variables after it get pushed to the right one. print(grades[3]) >> 83 Like in Java, Python can call certain variables from the list

Assignment 1 DUE: THURSDAY JANUARY 30, 2014 BY 11PM

 The End