img src : http://appworksinc.com/wp-content/uploads/2014/07/Python.png |
Welcome again to Python Programming for beginners. This is Part 2. In this part, we’ll see some information on Python 2 and Python 3. We’ll see video links on printing “Hello World,” Arithmetic Expressions and Variables in Python.
- There are two major Python versions, Python 2 and Python 3. Python 2 and 3 are quite different. This tutorial uses Python 2, because it’s more widely used and supported. However, Python 3 is more semantically correct, and supports newer features. As I said, this tutorial uses Python 2, but in some cases we’ll work with Python 3.
- One difference between Python 2 and 3 is the “print” statement. In Python 2, the “print” statement is not a function, and therefore it’s invoked without parentheses. However, in Python 3, it’s a function, and must be invoked with parentheses.
Let’s take a look:
1) Printing Hello World – You’ll get the chance to learn about how to print ‘Hello World’ in Python Shell, which is presented in video below. The lab involves Kali Linux Python Shell. Video link: http://youtu.be/LaeJhuDtKCU
Simply, to pring 'hello world' in python, we write following code :
print "Hello World"
2) Arithmetic Expressions – Numbers, Operators and Expressions will be explained in the video below. # Numbers – 2 types – Integers (1,3,-6…) & Decimals (1.0,2.3,-7.2…) # Datatype for integer is int() & for decimal is float() . . .Video link: http://youtu.be/_PAIuw1b08E
3) Variables – A Variable is a placeholder for storing values.
– Once we store values in variable, it helps in avoiding recomputing of same values.
– Assigning variables also helps reader to understand codes.
– Valid variable name consist of: letters, numbers, underscore
– Starts with letter or underscore
– Legal names : gamer, Ethical, g_a_m_e
– Illegal names: 333gaming, 1234
– While assigning value to variable, we use equal to (=) sign.
– Remember, double (= =) equal to sign is used to test equality.
– Assigning variables also helps reader to understand codes.
– Valid variable name consist of: letters, numbers, underscore
– Starts with letter or underscore
– Legal names : gamer, Ethical, g_a_m_e
– Illegal names: 333gaming, 1234
– While assigning value to variable, we use equal to (=) sign.
– Remember, double (= =) equal to sign is used to test equality.
Video link: http://youtu.be/7RTDk9d15a8
Comments
Post a Comment