Agenda Introduction Computer Programs Python Variables Assignment

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
INTRODUCTION TO PYTHON PART 2 INPUT AND OUTPUT CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
CIS Computer Programming Logic
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Programming in Python Part I Dr. Fatma Cemile Serçe Atılım University
Computer Science 101 Introduction to Programming.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Variables and Expressions CMSC 201 Chang (rev )
COMP 171: Data Types John Barr. Review - What is Computer Science? Problem Solving  Recognizing Patterns  If you can find a pattern in the way you solve.
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.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
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.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Variables and Expressions CMSC 201. Today we start Python! Two ways to use python: You can write a program, as a series of instructions in a file, and.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
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.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
CMSC201 Computer Science I for Majors Lecture 03 – Variables
Fundamentals of Programming I Overview of Programming
Chapter 1.2 Introduction to C++ Programming
Introducing Python Introduction to Python.
CST 1101 Problem Solving Using Computers
Chapter 1.2 Introduction to C++ Programming
Whatcha doin'? Aims: To start using Python. To understand loops.
CMSC201 Computer Science I for Majors Lecture 02 – Intro to Python
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Introduction to Python
Chapter 2 - Introduction to C Programming
Topic: Python’s building blocks -> Variables, Values, and Types
Lesson 1 An Introduction
Design & Technology Grade 7 Python
Introduction to Programming
Variables, Expressions, and IO
Chapter 2 - Introduction to C Programming
JavaScript.
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to CS Your First C Programs
Introduction to C++ Programming
Chapter 2 - Introduction to C Programming
Loops CIS 40 – Introduction to Programming in Python
Chapter 2 - Introduction to C Programming
Introduction to Programming with Python
Class 2.
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Variables In today’s lesson we will look at: what a variable is
Chapter 2 - Introduction to C Programming
JavaScript: Introduction to Scripting
12th Computer Science – Unit 5
Unit 3: Variables in Java
General Computer Science for Engineers CISC 106 Lecture 03
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 C Programming
Variables and Constants
Hardware is… Software is…
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Computer Programming Fundamentals Introduction to Python

Agenda Introduction Computer Programs Python Variables Assignment The Python shell Variables Assignment A first program

Computer Programs Computer Programs Programming languages Python Web browser Spread sheet Programming languages Human-readable Converted to a form the computer can execute Compiler Interpreter Python An interpreted language

Python shell Python can be used as a command line interpreter Reads ‘commands’ from the console Writes results back Can use this mode to try stuff out

“Hello World!”

Python shell as a calculator

Variables Little bits of the computer’s memory We assign them an identifier so we can refer to them When we put stuff into a variable, the computer will remember it for us Later we can get that stuff back again We can retrieve the variable’s contents at any time

Identifiers and Keywords Names you can make up Must begin with a letter or underscore ( _ ) Can then have letters, numbers and underscores Keywords Words that have a special meaning Cannot use them as identifiers Examples - if , while, for

Identifiers aName 23HighSt _special_ A name HighSt23 joe@somewhere Examples of identifiers: aName 23HighSt _special_ A name HighSt23 joe@somewhere while

Using variables aVariable = 123 X = aVariable aString = "A string" anotherString = 'The value of y is ' a = X + 4 y = a print(anotherString+str(y)) The value of y is 127

Variable type Variables have an associated type This type defines what sort of information the variable contains Examples of variable type: Numbers int, float, complex Strings of characters Boolean values True False

Using the console Writing to the console print("Message ...") Reading input from the console name = input("Enter name:") name now contains the value entered

Writing programs Can store groups of ‘statements’ for execution later We do not have to type them all in again Later we will learn how to control the flow through the stored statements Such a group of statements is a program

A first program ##################################### # First program # print("Starting first program!") enteredValue = input("Enter value:") print("Value entered was - ",end="") print(enteredValue)

Running our first program

Program design Before embarking on the coding process it is usually a good idea to design your program Designing your program means Thinking about how your program is to work Recording the decisions you have made in order to communicate your design to others Many possible ways to record your design Flowcharts Pseudo-code

Flow charts Terminator Input and output Start Start Print message Finish Prompt & Get reply Confirm value Terminator Input and output Start Print message 16

Flow charts print("Starting first program!") message Start Finish Prompt & Get reply Confirm value print("Starting first program!") enteredValue = input("Enter value:") print("Value entered was - ",end="") print(enteredValue) 17

Exercises Exercise 1 Exercise 2 Exercise 3 Exercise 4 Exploring the command line Exercise 2 The famous ‘Hello World!’ program Exercise 3 Using the console Exercise 4 Dealing with ‘types’