What are variables? Using input()

Slides:



Advertisements
Similar presentations
Intro to Python Welcome to the Wonderful world of GIS programing!
Advertisements

Syscall in MIPS Xinhui Hu Yuan Wang.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
Introduction to Python
Munster Programming Training
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Data Types Integer 15 StringHelloThere! Float/Real BooleanYes / No CharP.
Introduction to Computing Using Python Imperative Programming  what is a Python program?  print() statement  input() statement  type conversion statements.
Input, Output, and Processing
Computer Science 101 Introduction to Programming.
Type Conversions Implicit Conversion Explicit Conversion.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
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.
Please log on The. AN INTRODUCTION TO ‘Python is a high-level, general purpose programming language’ Python is one of the many programming languages.
Variables, Expressions and Statements
ECS 15 Variables. Outline  Using IDLE  Building blocks of programs: Text Numbers Variables!  Writing a program  Running the program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
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.
INPUT & VARIABLES.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
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.
ECS 15 Strings, input. Outline  Strings, string operation  Converting numbers to strings and strings to numbers  Getting input  Running programs by.
7. Lists 1 Let’s Learn Saenthong School, January – February 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
1. Starting 1 Let’s Learn Saenthong School, January – February 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
InterestRate Create an InterestRate class and InterestRateViewer client class to do the following: A person is purchasing an item with their credit card.
4. If Statements 1 Let’s Learn Saenthong School, January – February 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
Input, Output and Variables GCSE Computer Science – Python.
4. If Statements 1 Have your program make choices. Depending on a test have a program do different things Computer Programming BSc in Digital.
5. Loops 1 Make a program do things over-and-over-and over again. Counting loops; Conditional loops. Games: guessing, ghost, hangman Computer.
Let’s Learn 12. Packaging a Game Saengthong School, June – August 2016
Fundamentals of Programming I Overview of Programming
Topics Designing a Program Input, Processing, and Output
CSE 220 – C Programming C Fundamentals.
Let’s Learn 2. Installing Pygame
Data Types and Conversions, Input from the Keyboard
Variables, Expressions, and IO
4. If Statements Let's Learn Python and Pygame
What are variables? Using input()
Let's Learn Python and Pygame
Let’s Learn 6. Nested Loops Saenthong School, January – February 2016
8. Starting Pygame Let's Learn Python and Pygame
Learning Outcomes –Lesson 4
6. Lists Let's Learn Python and Pygame
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Lesson Aims Vocabulary In this lesson you are going to:
BSc in Digital Media, PSUIC
7. Functions Computer Programming BSc in Digital Media, PSUIC
7. Functions Let's Learn Python and Pygame
Margaret Derrington KCL Easter 2014
Topics Designing a Program Input, Processing, and Output
Python 19 Mr. Husch.
Variables In today’s lesson we will look at: what a variable is
Topics Designing a Program Input, Processing, and Output
Python Basics with Jupyter Notebook
Topics Designing a Program Input, Processing, and Output
What are variables? Using input()
Input and Output Python3 Beginner #3.
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.
Data Types and Maths Programming Guides.
Python 19 Mr. Husch.
What you need to do… Drag the pieces of code into the correct order like you can see in the EXAMPLE below. print ( “ int input ) = + Hello world chr ord.
Data Types and Expressions
Introduction to Python
Python Creating a calculator.
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

What are variables? Using input() 142-253 Computer Programming BSc in Digital Media, PSUIC Aj. Andrew Davison, CoE, PSU Hat Yai Campus E-mail: ad@fivedots.coe.psu.ac.th 2. Variables What are variables? Using input()

1. What is a Variable? A variable is a "named tag" for data used in your programs "Aj. Andrew" tag data Python treats the tag name teacher as being a different name than Teacher "Teacher" is a string, not the tag name Teacher

Variables Using Number Data

Why are they called "Variables"? a variable can change (the tag is given new data 5 9 first

Many Tags for One Piece of Data Teacher "Aj. Andrew" GreatTeacher

Moving a Tag to New Data changing one variable (tag) does not affect the other variable Great Teacher "Einstein "Aj. Andrew" Teacher

Numbers and Strings + means different things for numbers and strings strings can use "…" or '…'

The New Me the "new" score is the "old" score + 2

2. Have a Program get Input from the User Write the program "SayHello.py" in any text ediror (e.g. Notepad, Notepad++)

Load the Program into IDLE

Run the program in IDLE

the program user types this name the program uses input() to assign the user's data to yourName, and then prints it

Run the Program Many Times the user types in a different name each time

Run the Program in the Command Window Find the program and then run it twice.

input() reads in a string The data for variable x is the string "1234" This data is NOT the number 1234 use int() to change the data from a string to a number

Getting a number as input The data for variable x is an integer The data for variable x is a float (a decimal) If Python wants an integer input, it will be upset if the user enters a float

3. Farenheit to Celsius Converter tempConverter.py means no newline str() changes a number to a string comments to help a reader

Execution the user typed this

Errors in a Program

Where's "line 10"? string() should be str()