1. Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as:

    All that and more! Registration is quick, simple and absolutely free. Join our community today!

Java Python Tutorial for Beginners

Discussion in 'Coding, Programming' started by DCCS, Mar 6, 2015.

  1. Unang pagkakarinig ko kay Python noong wala pa akong alam sa pag gamit ng language ay "Snake o Ahas" hahaha! Well I'm probably wrong :hilarious:

    What is Python Programming? Go here: Please or Register to view links

    First download Python here: Please or Register to view links

    Let's start:

    And it is that simple (at least for now). Python makes it easy to run single lines of code - one-liner programs. Lets give it a go.

    Opening IDLE

    Go to the start menu, find Python, and run the program labelled 'IDLE' (Stands for Integrated Development Environment.)

    Now you are in the IDLE environment. This is the place you will be spending most time in. Here you can open a new window to write a program, or you can simply mess around with single lines of code, which is what we are going to do. Type the following and press enter: (don't type >>> as it should already be there)


       Sorry you need to Register / Login to see this Codes!    

    What happened? You just created a program, that prints the words 'Hello, World'. The IDLE environment that you are in immediately compiles whatever you have typed in. This is useful for testing things, e.g. define a few variables, and then test to see if a certain line will work. That will come in a later lesson, though.

    Math in Python

    Ngayon subukan mong mag type ng numbers at ipag-Add mo sila and hit enter kung anong lalabas.


       Sorry you need to Register / Login to see this Codes!    

    Ngayon alam mo ng marunong mag add, subtract, divide, multiply and the exponentials ng Python. Eto pa mga example ng basic ng Python


       Sorry you need to Register / Login to see this Codes!    

    Remember that thing called order of operation that they taught in maths? Well, it applies in python, too. Here it is, if you need reminding:

    parentheses ()
    2.exponents **
    3.multiplication *, division \, and remainder %
    4.addition + and subtraction -

    Order of Operations

    Here are some examples that you might want to try, if you're rusty on this:


       Sorry you need to Register / Login to see this Codes!    

    Sa unang example unang ni-calculate ng computer yung 2 * 3 tapos sunod yung + 1.


    Tignan niyo ang Reminder natin. Mas mataas ang priority ng multiplication (which is in number 3) kaysa sa addition (which is in number 4).

    Sa pangalang example natin. unang ni-calculate yung (1 + 2) sunod yung multiply by 3.


    Tiganan niyo ulit ang Reminder. Dahil unang priority ang () o parenthesis (whis is in number 1) at sunod na sa kanya ang addition dahil nasa loob ito ng bracket.

    Also remember that the math is calculated from left to right, UNLESS you put in parentheses. The innermost parentheses are calculated first. Watch these examples:


       Sorry you need to Register / Login to see this Codes!    

    In the first example, 4 -40 is calculated,then - 3 is done.

    In the second example, 40 - 3 is calculated, then it is subtracted from 4.

    Comments, Please

    The final thing you'll need to know to move on to multi-line programs is the comment. Type the following (and yes, the output is shown):

       Sorry you need to Register / Login to see this Codes!    

    Ang pinagkaiba lang niya kay C++ ay "#" ang ginagamit ni Python imbis na "//" para sa comment.

    A comment is a piece of code that is not run. In python, you make something a comment by putting a hash in front of it. A hash comments everything after it in the line, and nothing before it. So you could type this:

       Sorry you need to Register / Login to see this Codes!    

    Comments are important for adding necessary information for another programmer to read, but not the computer. For example, an explanation of a section of code, saying what it does, or what is wrong with it. You can also comment bits of code by putting a # in front of it - if you don't want it to compile, but cant delete it because you might need it later.
    Last edited: Mar 6, 2015
  2. derx

    derx El Vampiro Staff Member Moderator

    Thanks you boss! :geek: (y) :cat:
  3. (y) /msg short
  4. :) hehe.. bat nka java tag to? nkka ewan.
  5. >>> print "thanks ts"
Tags / Keywords:

Share This Page