Mastery 09

Basic types and their use in Python

Just as variables are a basic concept in programming, so are the different types of values that a variable can have. We call these ‘data-types’, because they are different types of ways we can store data. 

 

integers 

Integers are numeric values from negative infinity to infinity, such as 1, 0, -5, etc. and can be stored, manipulated, and expressed inside variables without quotes.

float 

Short for “floating point number,” any rational number, usually used with decimals such as 2.8 or 3.14159.

strings 

A set of letters, numbers, or other characters. They must be in quotes ” ” .

tuples 

A tuple is an unchangeable sequence of values. ie x=(1,2,3) parentheses makes it a tuple.

lists 

A list is a changeable sequence of data. ie x=[1,2,3] square bracketsmakes it a list.

dictionaries 

A type with multiple elements i.e. x = {1: ‘a’,’b’: 2,3: 3} where you address the elements with, e.g., a text. Dictionaries contain a key and a value.

 

 

 

CC BY 4.0 Mastery 09 by Thais Lizeth Santos Acosta is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.