Download presentation
Presentation is loading. Please wait.
Published byBruce Mark Green Modified over 8 years ago
1
Python Programming Lecture II
2
Data Data is the raw material that programs manipulate. Data comes in different flavours. The basic ones are called “primitive datatypes” –integer –real numbers –strings –boolean What are the distinguishing features of these different kinds of data?
3
Variables Data is stored in the memory cells of your computer. A variable is a reference to a specific cell somewhere in the computer’s memory that holds some data. In some computer languages a variable must match the type of data that it points to. –integer variable –boolean variable –string variable etc. Any attempt to assign the wrong type of data to such a variable will cause an error.
4
Static Typing Some programmers prefer this type of system, known as static typing because it can prevent some subtle bugs which are hard to detect. However, Python variables are not like this, they are dynamically typed. This means that the variable takes the type of value that is assigned to it.
5
Dynamic Typing >>> q = 7 # q is now a number >>> print q 7 >>> q = "Seven" # reassign q to a string >>> print q Seven Variables typically appear as syntactically distinguished items in programming language. In Python they must begin with an alphanumeric character and may include underscore
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.