Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

1 C++ Syntax and Semantics The Development Process.
Types and Arithmetic Operators
Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
4. PROLOG Data Objects And PROLOG Arithmetic
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
Javascript Essentials How do I write it??  Start Homesite  Between the start and end BODY tags type: 
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
JavaScript, Fourth Edition
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
CIS Computer Programming Logic
Programming.
Introduction to Python
Variables, Assignment & Math Storing and naming data.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
CPS120: Introduction to Computer Science
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Variables and Expressions CMSC 201 Chang (rev )
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
Programming Fundamental Slides1 Data Types, Identifiers, and Expressions Topics to cover here: Data types Variables and Identifiers Arithmetic and Logical.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
CSC 107 – Programming For Science. The Week’s Goal.
1 homework Due today: hw #1 (mailing list printout) readings to date: chapter 1 and chapter read appendix B (3 pages on DOS) and and.
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
More about Java Chapter 2 9/8 & 9/9 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Variables and Assignment CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
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.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
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.
Python Let’s get started!.
CPS120: Introduction to Computer Science Variables and Constants.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Data Handling in Algorithms. Activity 1 Starter Task: Quickly complete the sheet 5mins!
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
A Sample Program #include using namespace std; int main(void) { cout
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.
Windows Programming Lecture 03. Pointers and Arrays.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
 Type Called bool  Bool has only two possible values: True and False.
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Python Let’s get started!.
Visual Basic Variables
Variables A variable is a placeholder for a value. It is a named memory location where that value is stored. Use the name of a variable to access or update.
Data Types, Identifiers, and Expressions
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Revision Lecture
Variables and Primative Types
Variables and Arithmetic Operators in JavaScript
Lecture 3 Expressions Richard Gesick.
Data Types, Identifiers, and Expressions
Bools and simple if statements
Chapter 2 Edited by JJ Shepherd
C++ Data Types Data Type
Lecture 2 Python Programming & Data Types
The Data Element.
Winter 2019 CISC101 4/28/2019 CISC101 Reminders
The Data Element.
Understanding Variables
Variables in C Topics Naming Variables Declaring Variables
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Identifiers and Assignment Statements

Data structures In any programming language you need to refer to data The simplest way is with the actual data value, like “Joe”, 23.4, True Those are called constants or literals – they stand for themselves More often you give the data a name (think of a variable name) Data also has a type = integer, float, string, Boolean Every piece of data has some space in RAM (an address) A data structure is the collection of the data’s name, its value, its type and its address. We’ll be working with simple variables for a long time, then we’ll add in lists and objects.

Naming things You need an identifier to name something in your program This is most often a variable but it could be a function also Every language has rules for making identifiers An identifier has to being with an alphabetic character or the underscore character _ There can be more characters in the identifier, those can be alphabetic, numeric or the underscore character Upper or lower case alphabetic characters are allowed

Case Sensitivity and meaningful identifiers Python is CASE SENSITIVE – upper case and lower case alphabetic characters are considered different characters Use meaningful identifiers as much as possible. Short ones like T1 and q are not conveying much information Some people like to use the underscore character to “break” the identifier into words “number_students” “total_quality_points” Some people like to use upper case letters to do the same thing “numberStudents”, “totalQualityPoints” Do not use Python keywords as identifiers. Python will sometimes let you but it is confusing!

Assignment statements Syntax is simple identifier = expression Python does allow more than one identifier on the left, see “Simultaneous Assignments” for more information Semantics: evaluate the expression on the right and then assign the value to the identifier on the left The expression can be as simple as a literal or more complex by using function calls, list indexing, arithmetic operators, etc. Simple statement but VERY powerful! Most programs do their work by moving things around in memory. This statement is how it is done!

Simultaneous assignments (Only in Python) If you use more than one identifier on the left hand side of an assignment statement, you can store more than one thing. Example: x, y = 5, 4 Semantics: x gets the 5 and y gets the 4 You have to be careful – If the right hand side does not yield as many values as the left hand side expects, it causes a crash.