Understanding Variables

Slides:



Advertisements
Similar presentations
BNF. What is BNF? BNF stands for “Backus-Naur Form,” after the people who invented it BNF is a metalanguage--a language used to describe another language.
Advertisements

Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Objective: Dealing with data in C++ Agenda: Notes Essay Help.
Introduction to Programming with Java, for Beginners Primitive Types Expressions Statements Variables Strings.
JavaScript, Third Edition
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
Variables, Constants and Built-in Data Types Chapter 2: Java Fundamentals.
Representation and Conversion of Numeric Types 4 We have seen multiple data types that C provides for numbers: int and double 4 What differences are there.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
Group practice in problem design and problem solving
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
Python Types Python values are of various “types” Ints, Floats, Strings, Characters, and more Two representations of numbers 1 vs 1.0.
CPS120: Introduction to Computer Science
Chapter 2 Elementary Programming
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Programming Fundamental Slides1 Data Types, Identifiers, and Expressions Topics to cover here: Data types Variables and Identifiers Arithmetic and Logical.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
Variables and Assignment CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
COM S 207 Literal, Operator, and Expression Instructor: Ying Cai Department of Computer Science Iowa State University
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
Variables 1. What is a variable? Something whose value can change over time This value can change more than once over the time period (no limit!) Example:
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
PHP Variables.  Variables are "containers" for storing information. How to Declare PHP Variables  In PHP, a variable starts with the $ sign, followed.
Introduction ABAP Fields and Variables. Slide 2 Fields (Introduction) In ABAP, fields (or data objects) are named locations in memory Variables store.
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Python Programming Lecture II. Data Data is the raw material that programs manipulate. Data comes in different flavours. The basic ones are called “primitive.
Chapter 2. Variable and Data type
Data Handling in Algorithms. Activity 1 Starter Task: Quickly complete the sheet 5mins!
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
JavaScript Variables. Definition A variable is a "container" for information you want to store. A variable's value can change during the script.
Chapter Four Common facilities of procedural languages.
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.
Introduction to Python Lesson 2a Print and Types.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Fundamentals 2.
Egyptian Language School Computer Department
Agenda Introduction Computer Programs Python Variables Assignment
String Methods Programming Guides.
Introduction to Python Data Types and Variables
Data Types, Identifiers, and Expressions
Design & Technology Grade 7 Python
Introduction to the C Language
Data Types, Identifiers, and Expressions
Variables ICS2O.
Numbers.
CIS16 Application Development Programming with Visual Basic
Chapter 2 Variables.
“If you can’t write it down in English, you can’t code it.”
Chapter 2: Java Fundamentals
ICT Programming Lesson 4:
Variables Kevin Harville.
The Linux Command Line Chapter 25
Chapter 2: Java Fundamentals
Chapter 2: Introduction to C++.
Java Basics Data Types in Java.
Primitive Types and Expressions
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.
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
Python Creating a calculator.
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Understanding Variables Python Understanding Variables

Variables What is a variable? Definition A named area of storage in a computer program that can change as the program runs

Are all numbers the same? Content of Variables Words and letters These are known as strings Numbers Boolean Are all numbers the same?

Working with variables The type of information stored in a variable is referred to as its datatype The datatype controls how the program will process the data Eg Arithmetic can’t be performed on strings Numbers can only contain 0-9 and . – Special functions convert between strings and numbers – This is called Casting

Casting a Numeric Variable Numbers typed into Python arrive as a string They must be converted to a number before using in arithmetic number1 “29” 29 number1 number1 “29”

Variable Names A Variable name MUST start with a letter or an underscore NOT a number. Numbers can be included within the name, but not as the first character. A Variable name can be any length but is best to keep it reasonably short. Must consist of a continuous string of characters. That means they CANNOT have any spaces. Identify words by either capitalising the first letter of each word, or by using the underscore character. firstName first_name Only in exceptional circumstances use single letters for variable names Should be meaningful - describe the data they contain