7 minutes to Learn Python Programming Right Now

Reading Time: 2 minutes

Hi , Its a quick tutorial and I have only 7 minutes of your precious time So lets start without any further ado.

Installing Python :

  • If you are on Linux or Mac Machine Python is already installed on your system .
  • On Windows system Simply to the https://www.python.org/downloads/ and download the version 2.7.x where x can be anything(My case 9) , see the image below for further reference.
  •     Just add Python to you Path on windows using this Link

Hello World Saga :

[python] print("Hello World") [/python]


Data Type , Strings with Syntax

Basic syntax is same any other programming language like Java , The data structures available in python are lists, tuples and dictionaries. Sets module provides classes for constructing and manipulating unordered collections of unique elements. Common uses include removing duplicates from a sequence. 

  • Lists are like one-dimensional arrays (but you can also have lists of other lists). Tuples are immutable one-dimensional arrays
  • Dictionaries are associative arrays (a.k.a. hash tables)
  • Strings  – Strings are immutable in python , Below image shows how you can assign a variable with String value and Concatenate it with other data types like Int , Boolean etc.


## This is how you take a range in python
myrange = range(10)

for item in myrange:
if item in (1,3,5,7,9): ## if item % 2 == 0 for other logic
print("Old Number")
print("Even Number")

item = 1
while item < 10:
item = item+1


[code] Output : range(0, 10) Even Number Old Number Even Number Old Number Even Number Old Number Even Number Old Number Even Number Old Number
1 2 3 4 5 6 7 8 9 [/code]

Functions and Claases

class myClass:
def myFunction(self):
print("Hi I am Function")

def myFunctionWithReturn(self):
myText = "How are you"
return myText

def myFucntionWithArguments(self,number1,number2):
return number1+number2

if __name__== "__main__":
myObj = myClass() ## Creating Object
myValue = myObj.myFucntionWithArguments(1,2)

[code] Hi I am Function




def some_function():
# Division by zero raises an exception
10 / 0
except ZeroDivisionError:
print "Oops, invalid."
# Exception didn’t occur, we’re good.
# This is executed after the code block is run
# and all exceptions have been handled, even
# if a new exception is raised while handling.
print "We’re done with that."

>>> some_function()
Oops, invalid.
We’re done with that.


File I/O

[python]f =open("myFile.txt","w")
>>> f.readline()
‘This is the first line of the file.n’

for line in f:
print line,

More IO operations here

I hope I was able to give you a quick glimpse of Python in 7 minutes. Please leave comments if you believe there is something that could be improved or added or if there is anything else you would like to see.

1 thought on “7 minutes to Learn Python Programming Right Now”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.