What are variables? Using input()

Slides:



Advertisements
Similar presentations
This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Advertisements

Intro to Python Welcome to the Wonderful world of GIS programing!
Syscall in MIPS Xinhui Hu Yuan Wang.
Python November 14, Unit 7. Python Hello world, in class.
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.
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.
Variables, Expressions and Statements
ECS 15 Variables. Outline  Using IDLE  Building blocks of programs: Text Numbers Variables!  Writing a program  Running the program.
Python Conditionals chapter 5
ITEC 109 Lecture 7 Operations. Review Variables / Methods Functions Assignments –Purpose? –What provides the data? –What stores the data? –What type of.
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.
5. Loops 1 Let’s Learn Saenthong School, January – February 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
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.
Let’s Learn 12. Packaging a Game Saengthong School, June – August 2016
Topics Designing a Program Input, Processing, and Output
Let’s Learn 2. Installing Pygame
Topic: Python’s building blocks -> Statements
Data Types and Conversions, Input from the Keyboard
Variables and Expressions
Learning Intention Learning Intention: To develop understanding of variables, data types, and comments in text based programming languages Context: Sequencing.
Variables, Expressions, and IO
Formatting Output.
Useful String Methods Cont…
5. Loops Let's Learn Python and Pygame
4. If Statements Let's Learn Python and Pygame
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
6. Lists Let's Learn Python and Pygame
BSc in Digital Media, PSUIC
7. Functions Let's Learn Python and Pygame
Margaret Derrington KCL Easter 2014
Variables and Expressions
What are variables? Using input()
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.
Text Copyright (c) 2017 by Dr. E. Horvath
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
Python Creating a calculator.
Presentation transcript:

What are variables? Using input() Let's Learn Python and Pygame 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

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()