Python Tutorial :There are so many computer languages in market including Java , PHP , C , C++ etc . Most of the people thinks that programming is very difficult to do. They even thinks it is impossible to learn programming languages by them . But it is not true , i even say everyone can do programming .
Programming vs real life
Let’s take programming language easy and implement / compare these features with real life . Think like you are an object , your parents are your base classes( inheritance) . Your problem in life , where you have to take one decision are the decision making statements (if-else). And your daily routines are the infinite loop (which never ends / repeat after particular sequence). Think in that way programming becomes easy automatically .
Every language has their own speciality and features . But if i have to choose one language among all , then it is Python . It has not only easy syntax but also it is very powerful language . If you are fresher , then you must start with python . It is very user friendly , simple , and powerful languages . As a fresher , if you get started with python , then after experience you can have various choices . Like you can go for website development , data-science , Machine learning etc .
Python is best choice not only for the freshers but also for the experienced one . If you have experience , don’t worry python is very wide , you can go for complex applications like Artificial Intelligence , Machine learning etc , Desktop Applications etc .
Because of python’s features most famous companies use python including Google , Instagram , Dropbox , Facebook , Netflix etc .
Python Programming Example
As python has not very complex syntax , the programming problems are also very easy to solve in python . Here are some common programs which are very easy in python than other languages .
1. Program to swap the values of two variables
x= 10 y=20 print("Before:x=",x,"y=",y) x,y=y,x #Swap values print("After:x=",x,"y=",y)
As you can see in the example above , there is a single line for swapping values of variables .
2. Program to reverse string without using a function .
inp = input("===Enter a string to reverse===\n") for i in range(1,len(inp)+1): print(inp[-i])
3. Program to print even and odd numbers
inp = int(input("=== Enter a Range ===\n")) print("*** EVEN NUMBERS ***") for i in range(inp+1): if i%2 == 0: print(i) print("*** ODD NUMBERS ***") for i in range(inp+1): if i%2: print(i)
4. Program to Check for a leap Year
inp = int(input("=== Enter Year to Check ===\n")) if inp%4==0: if inp%100 == 0: if inp%400 == 0: print("It is a leep Year") else: print("It is Not a leep Year") else: print("It is a leep Year") else: print("It is not a leep Year")
5. Infinite loop
Here is very easy to set a infinite loop in python . Just we have to set while to True . If you want to exit from loop , then you can set break statement . Let’s define infinite loop with previous code .
while True: #Infinite Loop print("Press 0 to exit") inp = int(input("=== Enter Year to Check ===\n")) if inp == 0: break else: if inp%4==0: if inp%100 == 0: if inp%400 == 0: print("It is a leep Year") else: print("It is Not a leep Year") else: print("It is a leep Year") else: print("It is not a leep Year")
Download source code
There are various other examples which proves , python is an very easy programming language . If you have any questions or any programming problem then you can comment here . Thanks !!!