Python Lesson 2: Variables, Operations, and Types
Thomas Schwarz, SJ Marquette University
Python Lesson 2: Variables, Operations, and Types Thomas Schwarz, - - PowerPoint PPT Presentation
Python Lesson 2: Variables, Operations, and Types Thomas Schwarz, SJ Marquette University Variables and Types All program languages specify how data in memory locations is modified Python: A variable is a handle to a storage location
Thomas Schwarz, SJ Marquette University
locations is modified
location
a 3.14156432 b “a string” a = 3.14156432 b = “a string” a = b a 3.14156432 b “a string”
values to them
and variable b is of type string
names refer to the same value
collected
as any other programming language
depends on the type of operands
numbers:
(*), Division (/), Exponentiation (**)
floating point number
integer
quotation marks
slash with another symbol
\“ for double quotation mark, \\ for backward slash
expression to an expression with a different type but equivalent value
using a type conversion (aka cast)
the user provided input is interpretable as an integer), first as a string and then as a number
English (or Hindi) so giving it a number in other than symbolic form does not help
“123”
the expression having the same type.