Storing data Getting data out Data types Ruby as a foundation Program Variables Click icon to hear comments (the download may take a minute)

Slides:



Advertisements
Similar presentations
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
Advertisements

©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Declaring Variables You must first declare a variable before you can use it! Declaring involves: – Establishing the variable’s spot in memory – Specifying.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
JavaScript, Fourth Edition
Chapter 2 Data Types, Declarations, and Displays
Chapter 2: Introduction to C++.
JavaScript, Third Edition
Basic Elements of C++ Chapter 2.
1 Chapter 2 JAVA FUNDAMENTALS CONT’D. 2 PRIMITIVE DATA TYPES Computer programs operate on data values. Values in Java are classified according to their.
Variable & Constants. A variable is a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines.
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects Seventh.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
 Pearson Education, Inc. All rights reserved Formatted Output.
 2005 Pearson Education, Inc. All rights reserved Formatted Output.
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Input, Output, and Processing
Chapter 2: Using Data.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Characters and tokens Characters are the basic building blocks in C program, equivalent to ‘letters’ in English language Includes every printable character.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Computer Science 1620 boolean. Types so far: Integer char, short, int, long Floating Point float, double, long double String sequence of chars.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Variables in Java x = 3;. What is a variable?  A variable is a placeholder in memory used by programmers to store information for a certain amount of.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
ITEC 109 Lecture 7 Operations. Review Variables / Methods Functions Assignments –Purpose? –What provides the data? –What stores the data? –What type of.
Data,information Data and Information 4 Data –Raw, unorganised facts –Ideas or concepts 4 Information –When data is manipulated into a meaningful form.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
1.2 Primitive Data Types and Variables
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
GCSE Computing: Programming GCSE Programming Remembering Python.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
Review by Mr. Maasz, Summary of Chapter 2: Starting Out with Java.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
28 Formatted Output.
Chapter Topics The Basics of a C++ Program Data Types
Topics Designing a Program Input, Processing, and Output
Chapter 2: Introduction to C++
Basic Elements of C++.
TMF1414 Introduction to Programming
EPSII 59:006 Spring 2004.
Multiple variables can be created in one declaration
Chapter 2: Introduction to C++
Variables ,Data Types and Constants
Basic Elements of C++ Chapter 2.
Chapter 2.
IDENTIFIERS CSC 111.
Computers & Programming Languages
WEB PROGRAMMING JavaScript.
Numbers.
Coding Concepts (Data- Types)
Chapter 2: Introduction to C++.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Variables Here we go.
Lexical Elements & Operators
Data Types and Maths Programming Guides.
Variables and Constants
Section 6 Primitive Data Types
Presentation transcript:

Storing data Getting data out Data types Ruby as a foundation Program Variables Click icon to hear comments (the download may take a minute)

Assigning a value to a variable The variable name on the left side of the equal sign gets a value assigned to it. – A value can be assigned to give a name to a number LegalAge = 21 – A variable name may be easier to remember than a number and thus, help to make programming easier – imagine having to remember and type when you want to reference the number of milliliters per pint mlperpint = Click icon to hear comments

Getting data out of variable To use the value stored in a variable, use the name is if it were the value itself – The value might be printed for display purposes PRINT “The legal age is #{LegalAge}” – The value might be used for a calculation legalBirthDate = DateToday - LegalAge – The value be used for a decision IF age < LegalAge Then PRINT “too young” Click icon to hear comments

Numbers or Letters? Because of the way computers store and manipulate data, different types of variables are used. Use a numeric data type for math operations Data type can affect – the amount of memory used – the way decimals are handled – The number of digits that can be stored – how rounding or fractional values are handled Click icon to hear comments

String Data Type The letters, numbers, and symbols on the keyboard are called alphanumeric string is often used as a shorter way of referring to alphanumerics. Quotations marks surrounding text indicates string data. FirstName = “Petulla” In VisualBasic, the words as string are used when the variable is defined. Click icon to hear comments

Data types in Ruby and other languages For simplicity, in Ruby a variable is considered a string type by default if input is from a keyboard – String values need to be converted to numeric before performing math. – Floating point data type can also be specified by assigning a value with a decimal point, otherwise integer is assumed mlPerPint! = – In VisualBasic the words as single are used when the variable is first defined. Click icon to hear comments

Other Data Types in Ruby and symbol used Values too large for Fixnum are automatically converted to Bignum—both are subclasses of integer Integer – Whole numbers up to 1 less than the native machine word are stored as Fixnum Other number bases – Hexadecimal - precede value with 0x – Binary – precede value with 0b – Octal – precede value with 0 Click icon to hear comments

Other Data Types in VisualBasic and symbol used In addition to the data types supported by Ruby, VisualBasic has several, such as: – Boolean - True or False – Char – single Unicode character followed by lowercase c “A”c – Decimal – up to 29 digits followed by D 59.99D – Date – days since year 1 enclosed in # #1/1/2001 1:00 PM# – Double ± followed by R – Object– can store and convert to other types Click icon to hear comments