Tag Archives: #mastery09

Mastery09 – Basic types and their use in python

the basic types of data that python works with are:

1.- Integer: these are whole numbers from negative to positive, they can be used in the program simply writing the number in the program like 45 and to turn an input into an integer write int before the input.

2.- Float: floats are numbers with decimals like 2.5, to turn an integer into float just write float before it.

3.- strings: a set of letters, number or other characters, these dont hold any value appart from the character itself, a  number written as a string wont be counted as a numeric value. strings are between ” ” to differentiate them.

4.- Tuples: a list with a fixed number of elements, they are use ( ).

5.- List: a list without a fixed number of elements, they use [ ].

6.- Dictionaries: a list of multiple elements that can be adressed by text, they use { }.

reference:

http://en.wikiversity.org/wiki/Python/Basic_data_types

Basic types and their use in Python

Variables in Python are there to store values, there are different types of variables, but the basic ones are integers, floating point, strings (text). The program has five standard data types: numbers, string, list, tuple (the main differences between lists and tuples is that tuples cannot be updated, unlike lists, also you use brackets with lists and parenthesis with tuples) and dictionary (stores data that can be shown pressing the key/phrase that has been assigned to it).

Here’s an example of the use of variables in Python:

Basic types and their use in Python

Basic types and their use in Python

Mastery 09

Hello everybody:

For my mastery 09 I created a PDF tutorial to explain what a variable is and the basic types of variables we can use in C++. I really hope you find it useful.

Here´s the link https://drive.google.com/file/d/0B5CZIHLkZcDzUFpFbFAxMUhlR28/view?usp=sharing

Basic Types in Python and their use

 

there are different types of way that we can store data. In python the  most basic data are numbers and strings.

*First in the numbers we have the integers numbers and float numbers.

-Integers numbers are conformed for all the numbers that are in the range of negative infinity to infinity, e.g., -1, 0, 1, etc.

-Float numbers are  all the numbers that has digits afters their decimal point. For example: 3.3,4.66,5.9, etc.

*Second the strings can be numbers,letters and any others characters, but all of this characters has a simple sintax, if you want to write strings in a code, you has two option:

1)with double quotes example -> x=”hola mundo”

2)with only one quote example -> x= ‘hola mundo’

Mastery09. Basic Types in Python and their use

Data-types are different types of ways we can store data. The most basic Data-types are the numbers (which we can divide in integers and Floating point numbers) and strings.

Numbers:

>>>An integer is a whole number form the range of negative infinity to infinity, e.g., -5, 0, 17, etc.

>>>A floating point number is any number that has digits after a decimal point, e.g., 2.4, 132.8441, 3.333, etc.

Strings:

A string is a piece of text that can be a set of letters, numbers or other characters. To include a string in our program, we have to sorround it with quotes or double quotes. e.g.:

>>> x= “This is a string with double quotes”

>>> y= ‘This is a string with simple quotes’

And the work exactly the same.

 

There are some more complex Data-types such lists, tuples and dictionaries.

Lists:

A list stores a bunch of values and keeps them in order for the user; the user can add, delete or modify any item from the list whenever he wants. A list doesnt have a fixed number of values, the user can modify it as he wants. Lists are characterized because of the square brackets. For example:

x=[1,2,3,4,5]

Tuples:

Tuples are a lot like lists but the do have a fixed number of values that can not be modified. Different from lists, tuples are defined with parentheses instead of square brackets. For example:

x=(1,2,3,4,5)

Dictionaries:

Dictionaries contain a key and a value, so ypu can look up for the value later using the key. We can use dictionaries to build complex nested data structures or just to store values. The syntax is the following:

x={‘key1’: ‘value1’, ‘key2’: ‘value2’}

 

You can learn more about data-types in here: http://www.voidspace.org.uk/python/articles/python_datatypes.shtml

 

#mastery09 #TC1017

Compilers reserve certain terms or keywords (keywords) for the syntactic language use, such as: asm, auto, break, case, char, do, for, etc. While these words are defined for ANSI C, different compilers extend this definition to other terms.

To create a variable in a particular place of a program first write the variable and then the identifier with which we name the variable, followed all a ‘;’. This is referred to define a variable. The general definition is:

 

For example:

 

int number; / * Create the variable number of type integer * /

char letter; / * Create the letter variable, character type * /

float a, b; / * Create two variables a and b, of floating point number * /

 

Basic types and their use in C++

Dentro del lenguaje de c++ existen varios types los mas usados son los tipo char, int, float y double.

El uso de los tipo char es para números pequeños y caracteres de PC.

El uso de los tipo int se usa para números entre el rango: -2,147,483,648 <= X <= 2,147,483,647.

Para saber que tipo de variable debemos usar tenemos que tener en cuenta el tipo de datos que estaremos manejando, para elegir la más conveniente.

Para mayor información puede checarse el siguiente enlace:

http://www.zator.com/Cpp/E2_2_4.htm

 

 

#Mastery09 #TC1017 Basic Types C++

Why is important declared variables?

because in that way you are saying the kind of the data and how that data will be called. 

This is the basic types for C++ so, please be careful when you are using like

int main {}

int

double

// You can use whichever you want but!! following the right variable for the quantity you will recieve!

 

https://www.dropbox.com/s/01wo97zpmjpm4nc/Mastery09.mov?dl=0

ENTEROS
byte   0 -> 255
short   -32,768 -> 32,767
int   -2,147,483,648 –> 2,147,483,647
long  -9,223,372,036,854,775,808 -> 9,223,372,036,854,775,807

• REALES

     decimal

float 1.5 E-45 –> 3.4E38
double 5.0E-3424 –> 1.7E308

• TIPO MONETARIO

decimal 1.0 E-28 –> 7.9E28

• Datos de tipo CARACTER

Char    a    s    N     1     $

• Datos de tipo CADENA DE CARACTERES

String  Alejandra Jacobo

• Boleano

bool     True, False
 
 
Basic Types C++
 

#Mastery09 #TC1017

Lo básico en C++

 

Lo más básico es:

 

Librería iostream

Using Namespace std

El programa principal main

 

Posteriosrmente para definir diferentes tipos de variables (las variables sirven para asignar un valor) contamos con tres diferentes comandos:

     Int: Solo almacena números enteros

     float: Almacena números reales con decimales.

     double: Almacena números reales con decimales.

 

 

Para imprimir esta: “cout” y para recibir esta: “cin”

 

No olvides compilar y correr tu programa!

#Mastery09

En este programa decidí usar el tipo de variable string en lugar de int.

La variable string permite el uso de palabras completas como valor a la variable.

En este caso, en lugar de pedirme un número al usuario, le estoy pidiendo una palabra completa. Éste tiene que decidir en qué medio de transporte quiere viajar para que el programa le de el costo de un boleto para dicho viaje. 

El círculo en rojo que puse indica el lugar donde declaramos int normalmente, pero que lo he cambiado por string para poder introducir el texto.

Por otro lado los círculos azules indican como debo escribir el string para que sea leido.. debe estar entre comillas.

Al estar investigando sobre los strings me di cuenta de que se debe poner la librería <string>, sin embargo yo no la puse y aún así el programa me funciona como quería.