Python Programming 101 Basic Principles(67%)

Genesis [Fromwarriors]
12 years ago

0

[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%—————————————————————————-

8replies
8voices
216views
Anonymous [KSem]
11 years ago

0

I learn C++ because I think I can be more creative in it… Java is good too :)

Pawda [Memoria]
11 years ago

0

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

daMage
11 years ago

0

[quote=Memoria]you’ve basically learnt every language[/quote]
Not quite :)
For example Esoteric languages like Brainfuck are quite different. And that’s by design. And this is probably nitpicking.

Pawda [Memoria]
11 years ago

0

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.

Gremall
11 years ago

0

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 :)

[d3adMaN]
11 years ago

0

Wow , I did not know Brainfuck… I’m learning everyday here, that’s cool :D

J [ColdIV]
11 years ago

0

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.

Honey Boo Boo [Ski900]
11 years ago

0

What the fuck is the internet

You must be logged in to reply to this discussion. Login
1 of 9

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss