Road To Masterball! (4/4)

--Originally published at Programming Blog

This is the last road to our adventure, i hope everyone liked it, please remember to thank Ken for having this type of course.

The only little problem with our road is.. Red!, (for the ones that don’t know is the person that is after the elite 4 in the games that is stronger than the elite)

So our mission for defeating Red and actually getting the Masterball (Screw you, Red) is the creation and use of ranges in Python and the creation and use of dictionaries.

So our last 2 starts now!

Ranges in Python

http://pythoncentral.io/pythons-range-function-explained/

It starts with the function Range() that generates a list of random numbers, but it must be integers, and parameters can be positive or negative

and it has different entrances for the typing.

Start: Starting number of the sequence (LUL)

Stop: Generate numbers up to, but not include this number

Step: Difference between each number in the sequence.

 ranges

And for extra information you can get more by this video

http://interactivepython.org/courselib/static/thinkcspy/PythonTurtle/TherangeFunction.html

Last but not least

Creation and use of dictionaries in Python

First the syntaxis

{} The braces that contains the dictionary

: The colon separates the key from the value of the key

“A” This is the key, it holds the value next to it

A very important way to organize the values can be with dictionaries, since each element it’s a key with it’s respective value. An example would be the alphabet, and the dictionary starts to get useful the moment that you need a variable for each element of the list.

alphabet = {“A”:0,”B”:0,”C”:0,”D”:0…}

 

And an important function that we need to know is .keys(), this only returns the values as a list, so we can check the key of a value before calling it

.

 

This concludes our journey, i hope everyone liked it, We defeated Red! Congratulations #TC101,

This work was done by:

A01228817 Juan Montero

A01229006 Daniel Arrieta

 

Ash Out!