0
Results 1 to 3 of 3

03172014, 01:53 PM #1
 Join Date
 Mar 2014
 Location
 United Kingdom
 Posts
 16
 Points
 20
[Python tutorial] functions dealing with declared variables
See let's say I take two variables (In this predunction "a and b"), and publicly declare them as integers, there are a large variety of script compouds that I can make, so here is a quick example that I wrote in vim,
a = 1
#As you may see, I have just declared "a" as "1".
Now let's declare "b" as an integer of "1" as well.
b = 1
#Since i have done that at the main of our python (.py) application, you can now use statements (EG: print statements) and start making simple composed functions using our two declared variables.
#So now let's say I want to subtract a from b or b from a and get the integer, your function would look like this,
a = 1 #Or any number.
b = 1 #Or any number.
print a  b
#This function would display "0" because 1  1 (a  b/b  a = 1) = 0. The 'print' function is built in and is used to print on screen text within the current terminal.
#Get it? It is simple encured algebra.
#It's quite simple actually.
Now here is a simple sample program that I made a couple days ago, it shows every number 1  10 to the power of every number 1  10.
Code:#Declared variables a = 1 b = 2 c = 3 d = 4 e = 5 f = 6 g = 7 h = 8 i = 9 j = 10 print "[i*x]Press Enter To Display 1 To The Power Of 1  10.[i*x]" raw_input("") print "[1] To the power of [1] = ", a ** a print "[i*x]Press Enter To Display 2 To The Power Of 1  10.[i*x]" raw_input("") print "[2] To the power of [1] = ", b ** a print "[2] To the power of [2] = ", b ** b print "[2] To the power of [3] = ", b ** c print "[2] To the power of [4] = ", b ** d print "[2] To the power of [5] = ", b ** e print "[2] To the power of [6] = ", b ** f print "[2] To the power of [7] = ", b ** g print "[2] To the power of [8] = ", b ** h print "[2] To the power of [9] = ", b ** i print "[2] To the power of [10] = ", b ** j print "[i*x]Press Enter To Display 3 To The Power Of 1  10.[i*x]" raw_input("") print "[3] To the power of [1] = ", c ** a print "[3] To the power of [2] = ", c ** b print "[3] To the power of [3] = ", c ** c print "[3] To the power of [4] = ", c ** d print "[3] To the power of [5] = ", c ** e print "[3] To the power of [6] = ", c ** f print "[3] To the power of [7] = ", c ** g print "[3] To the power of [8] = ", c ** h print "[3] To the power of [9] = ", c ** i print "[3] To the power of [10] = ", c ** j print "[i*x]Press Enter To Display 4 To The Power Of 1  10.[i*x]" raw_input("") print "[4] To the power of [1] = ", d ** a print "[4] To the power of [2] = ", d ** b print "[4] To the power of [3] = ", d ** c print "[4] To the power of [4] = ", d ** d print "[4] To the power of [5] = ", d ** e print "[4] To the power of [6] = ", d ** f print "[4] To the power of [7] = ", d ** g print "[4] To the power of [8] = ", d ** h print "[4] To the power of [9] = ", d ** i print "[4] To the power of [10] = ", d ** j print "[i*x]Press Enter To Display 5 To The Power Of 1  10.[i*x]" raw_input("") print "[5] To the power of [1] = ", e ** a print "[5] To the power of [2] = ", e ** b print "[5] To the power of [3] = ", e ** c print "[5] To the power of [4] = ", e ** d print "[5] To the power of [5] = ", e ** e print "[5] To the power of [6] = ", e ** f print "[5] To the power of [7] = ", e ** g print "[5] To the power of [8] = ", e ** h print "[5] To the power of [9] = ", e ** i print "[5] To the power of [10] = ", e ** j print "[i*x]Press Enter To Display 6 To The Power Of 1  10.[i*x]" raw_input("") print "[6] To the power of [1] = ", f ** a print "[6] To the power of [2] = ", f ** b print "[6] To the power of [3] = ", f ** c print "[6] To the power of [4] = ", f ** d print "[6] To the power of [5] = ", f ** e print "[6] To the power of [6] = ", f ** f print "[6] To the power of [7] = ", f ** g print "[6] To the power of [8] = ", f ** h print "[6] To the power of [9] = ", f ** i print "[6] To the power of [10] = ", f ** j print "[i*x]Press Enter To Display 7 To The Power Of 1  10.[i*x]" raw_input("") print "[7] To the power of [1] = ", g ** a print "[7] To the power of [2] = ", g ** b print "[7] To the power of [3] = ", g ** c print "[7] To the power of [4] = ", g ** d print "[7] To the power of [5] = ", g ** e print "[7] To the power of [6] = ", g ** f print "[7] To the power of [7] = ", g ** g print "[7] To the power of [8] = ", g ** h print "[7] To the power of [9] = ", g ** i print "[7] To the power of [10] = ", g ** j print "[i*x]Press Enter To Display 8 To The Power Of 1  10.[i*x]" raw_input("") print "[8] To the power of [1] = ", h ** a print "[8] To the power of [2] = ", h ** b print "[8] To the power of [3] = ", h ** c print "[8] To the power of [4] = ", h ** d print "[8] To the power of [5] = ", h ** e print "[8] To the power of [6] = ", h ** f print "[8] To the power of [7] = ", h ** g print "[8] To the power of [8] = ", h ** h print "[8] To the power of [9] = ", h ** i print "[8] To the power of [10] = ", h ** j print "[i*x]Press Enter To Display 9 To The Power Of 1  10.[i*x]" raw_input("") print "[9] To the power of [1] = ", i ** a print "[9] To the power of [2] = ", i ** b print "[9] To the power of [3] = ", i ** c print "[9] To the power of [4] = ", i ** d print "[9] To the power of [5] = ", i ** e print "[9] To the power of [6] = ", i ** f print "[9] To the power of [7] = ", i ** g print "[9] To the power of [8] = ", i ** h print "[9] To the power of [9] = ", i ** i print "[9] To the power of [10] = ", i ** j print "[i*x]Press Enter To Display 10 To The Power Of 1  10.[i*x]" raw_input("") print "[10] To the power of [1] = ", j ** a print "[10] To the power of [2] = ", j ** b print "[10] To the power of [3] = ", j ** c print "[10] To the power of [4] = ", j ** d print "[10] To the power of [5] = ", j ** e print "[10] To the power of [6] = ", j ** f print "[10] To the power of [7] = ", j ** g print "[10] To the power of [8] = ", j ** h print "[10] To the power of [9] = ", j ** i print "[10] To the power of [10] = ", j ** j
#I hope you all liked my tutorial
#Side note that addition = +, subtraction = , multiplication = *, division = /, and to the power of = **.
Last edited by PythonUK; 03172014 at 02:29 PM.

03172014, 02:25 PM #2
Consider using [code]//put code here [/code] tags to make it more readable
0

03172014, 02:29 PM #3
 Join Date
 Mar 2014
 Location
 United Kingdom
 Posts
 16
 Points
 20
oh okay, i get it now. Thanks
0
Bookmarks