miércoles, 18 de marzo de 2015

#WSQ11

Click here to see code

This program seen here uses fuctions in a fun way to determine weather a number is a palindrome or not.

in this program the number will count as a palindrome if it can become a palindrome, example:

11 = palindrome 

31= (31+13=44) =palindrome

28=(28+82=110)=(110+011=121)=palindrome

The only way that a number will be considered a non palindrome by this program is if it takes +30 steps to turn into a palindrome.

miércoles, 11 de marzo de 2015

#WSQ10

This program is all about lists. Click here to see the code

It has some fuctions made by me and a couple of while loops to make things easy.

I used the python documentation to help me do it. check python documentation on lists.


jueves, 26 de febrero de 2015

#WSQ09

click here for code

in this program we are doing the factorial multiplication of a number:

I crated a fuction to do so, using a counter and an accumulator within a loop. the program also uses many while and if statements, so the program ca repeat itself until the user wants to stop.


jueves, 19 de febrero de 2015

#Mastery11 how to call a fuction.

Calling a fuction its exactly what it sounds like. You are telling the fuction to act on the values you have stablished.  to call a fuction  first you must have a variable that will get the return value of your fuction.

example:

lets say you crated a fuction called: make_sum.

the fuction would look like this:

def make_sum(x,y):
ans=x+y
   return ans

so in your code you would create a varible, lets say:

the_sum =

then you write the fuction, adding the values that you want it to take.

the_sum = make_sum(2,5)

so: 
make_sum(x,y):
ans=x+y
   return ans
will become:
make_sum(2,5):
ans=2+5
   return ans

and the variable the_sum will receve the return value of:


make_sum(2,5):
ans=2+5
   return ans
wich in this case is 7.

The Fun with numbers code in here shows an example of a program that calls differnt fuctions.

note: is very usefull to create your fuctions in a separate place from the rest of the code.

miércoles, 18 de febrero de 2015

#mastery12 fuctions in python


To define a fuction you write the word def followed by the name you gave your fuction, in parethes you grite the values it will take, a colon ":" and in the folowing lines you write the steps the fuction will follow. at the end you write return and the value that it will end up giving. 

example:
def make_sum(x,y):
ans=x+y
   return ans



this program shown here uses personally made fuctions:

you can copy and paste the code from this link to try it on your own.  


Fun with number, now functions in Python.

#wsq08

this is a remake of the fun with numbers program, but this time using fuctions:

click here to see the code

check out mastery 12 to see how to make your own fuctions.





martes, 10 de febrero de 2015

#Mastery20 'for' loops

"Python’s for statement iterates over the items of any sequence (a list or a string), in the order that they appear in the sequence."(Original text.)

In this case the loop of for prints over the sequence of numbers given by the user. Due to the way that python sets up sequences it was real E-Z to make the user determine the way that the numbers will go up. The range of numbers is exclusive, that means that it wont include the very last númber of the sequence, I represented that in the program with a '>'. 

example: 
for i in range(0,11,5):
     print (i)
In this case the program will loop until every single value of i is printed. i is in range from 0 to 10, and it will go up by 5. Which means that it will appear: 0,5,10.