Basic Types

--Originally published at Python

Basic types in Python 3 refers to most common variables that are used to program. These are known as numbers, string (words), List (group of variables), Tuple (similar), and Dictionary (again, very similar to the lists). Here’s a picture showing every basic type in use:

Code:

num = int(5)
print(“Number: “, num)

word = str(‘Hello’)
print(“String: “, word)

list1 = [‘Dog’, ‘Cat’, 9, 15]
print(“List: “, list1)

tuple1 = (‘Cat’, ‘Dog’, 15, 9)
print(“Tuple: “, tuple1)

dict = {‘Animal’ : ‘Dog’, ‘Age’ : 5, ‘Breed’ : ‘Pug’, ‘Name’ : ‘Bono’}
print(“dict[Animal]: ” , dict[‘Animal’])
print(“dic[Name]: ” , dict[‘Name’])

2basic

It may be hard to understand the difference between List, Tuple, and Dictionary by just looking at the program. List stores different types of variables that can be modified later on. Tuple does the same but can’t be changed. Finally, the variables in a Dictionary are accessed through keywords, not the position of the variable itself. Well that’s pretty much it for the basic types, hope you understood.


Post = {Basic types: same but different}

--Originally published at Monty Python and the Blogging Tale

Well, we need to learn the basic types beacuse python. So I am going to explain them the easy way, as always; in python there are these things called variables, that have no personality whatsoever; thus, they need you to define them by assigning them values. In python there are three kinds of values:

Numbers: which are integers (1), floats (1.0), and complex (1j). These are super simple.

Strings: They are words. “Words”

Lists: They can be a list of both strings and numbers.

Tuple: They are basically lists that cannot be modified.

Dictionaty: They consist of a key and a value; it is weird to explain.

And to show you that I have practiced them:

basic

But I need to give credit to the page that actually showed me those basic types (that happens to be the second entry in the google search):

Link: https://www.tutorialspoint.com//python3/python_variable_types.htm