
Programming Data Structures and Identifiers Overview
Learn about identifiers, assignment statements, data structures, naming conventions, case sensitivity, and assignment syntax in programming. Understand the importance of meaningful identifiers and simultaneous assignments in Python. Dive into the basics of variables, constants, literals, and data types.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
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.