Python Programming 101 Basic Principles(67%)
[h2]Welcome! I will be explaining a few principles of python programming and how to learn more python.
[list]
[] 1. Intro
[] 2. Variables
[] 4. If Statements
[] 5. Resources
[/list]
What we must grasp first is how Python is written. For instance “Whitespace” is a term referred to the space in code that the computer skips over, but it makes it easier for us humans to read it. For instance:
No whitespace:
x=1 print(x) if(x==1): print "I love you :)\n"
Whitespace:
x = 1
print(x)
if(x==1):
print "I love you :)\n"
Python is a a case sensitive language. So, x is not equal to X. Keep that in mind :)
Ok, we got through Intro! Not too bad.
Variables
Variables are a sometimes hard concept to grasp to beginners.
Variables are placeholders for data. If you passed basic algebra, you should know something like: x = 1. Think about it the same way. Instead of having to figure out the equation, you set it to whatever you like. For this example, I am going to use the “print” syntax to print something on the screen – Self -explanatory – Remember that it is case sensitive. Print, PRINT, pRINT, and so on will not work. Only “print”.
Variable example:
x = "Hello World"
print(x)
In this example, we state that x is equal to “Hello World”, so we stored that bit of information into the variable. So anytime x is called it would be “Hello World”. Of course you can change the variables, as they are dynamic, but that’s a more advanced concept.
Next, we tell the computer to print “x”. The parentheses just allows us to group it together and make it easier to read. print x
would be valid also.
Variable can be manipulated in numerous ways too:
Adding variables together
x=1
y=1
print(x + y)
Subtracting variables
x=5
y=1
print(x - y)
You can also leave a variable blank to set later into the code through and input statement:
print "Hello! Welcome to the crap machine!"
number = input("ENTER A NUMBER> ")
print(number)
input is for numbers, but raw_input is just a string collector. Just think of it that way. You will learn more about this later in your studies after this basic principles.
That was just a brief touch on variables. To learn more about it here: http://www.tutorialspoint.com/python/python_variable_types.htm
IF STATEMENTS!! : D:D:D:D:D:D:D:D
These are conditional statements. For example: (pseudocode) IF Johnny eats 6 candy bars THEN take insulin because he has diabetes.
———————————————-INCOMPLETE PROGRESS: 67%—————————————————————————-
Sail Safe.
Donations if possible: 1Cv4FrNBBF3LLjg6ceBBQQomKRTmzPNPFJ
There is no way to reproduce and you duplicated three hundred times… Just shut up please >_<
Once you’ve learnt C and one object oriented language like C++, you’ve basically learnt every language and the learning curve for a new language is fast.
In the end you can do the same things in Python or C++ but for shell scripting like admin system tools… you will take 5 lines in python where you would have took 500 in C.
Every language has their strengths and weakness; don’t restrict yourself to only one.
By the way for python, I would recommend this: learnpythonthehardway.org
Well, I knew about those languages. Once, I even had to make a lolcode compilator and by then make my own language.
Some knowledge of Extended Backus-Naur form and Code Worker will make you relize all languages are same in definitive because they just have a different “grammar”. Till the time we will use the “All or Nothing” concept this ain’t gonna change.
Thanks for the link Fromwarriors, and thanks to you too Memoria :)
We only do basic at school, so I get bored quicky…
But I know we can programm in Python on the computers we use at school, so why not a little demo to entertain the class? :D
Wont be something great, but most of my mates dont even understand basic :)
Brainfuck is fun to use but hard to read d:
And I agree with @Memoria - if you learned C++ or something like that then you won’t have many problems with other programming languages.
Need help with math homework? Hit me up! I can help out with integral calculus and below.