Python tutorial

Python tutorial

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 .

inheritance
inheritance

Python tutorial

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)

Output

Python Tutorial
Swapping Values

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

Output

Python Tutorial
String Reverse

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)

Output

Python Tutorial
Even and Odd Number

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

Output

Python Tutorial
Check for a leap 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")

Output

Python Tutorial
Infinite loop

Download source code

Download project on Github

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 !!!

28 thoughts on “Python tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Considerably, the submit is really the finest on this worthy topic. I agree along with your findings and in addition can thirstily look forward to Your own long term updates. Simply just saying many thanks will not merely you need to be enough, for that fantastic clarity inside your writing. I will straight away grab your rss to remain up-to-date with any kind of improvements. Genuine perform and also a lot success inside your company dealings!

  2. What i do not understood is in reality how you are now not actually much more neatly-preferred than you might be now. You are so intelligent. You realize thus significantly on the subject of this topic, produced me for my part imagine it from a lot of numerous angles. Its like women and men aren’t fascinated except it’s one thing to accomplish with Woman gaga! Your personal stuffs great. Always take care of it up!

  3. I just want to mention I am just very new to blogs and certainly loved your web page. More than likely I’m going to bookmark your website . You surely have very good well written articles. Regards for sharing with us your web page.

  4. Clean website. Do you ever accept guest posts? I am maintaining a site on my latest hobby water filters and wanting to trade some content with good sites. I looked around your blog and you’ve got some good content and I was thinking our readers would both find value. Thanks!

  5. Does your site have a contact page? I’m having problems locating it but, I’d like to shoot you an e-mail. I’ve got some recommendations for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it grow over time.

  6. The next time I read a blog, I hope that it doesnt disappoint me as a lot as this one. I imply, I do know it was my option to read, however I truly thought youd have something attention-grabbing to say. All I hear is a bunch of whining about something that you could repair should you werent too busy in search of attention.

  7. I think this is one of the most significant information for me. And i am glad reading your article. But want to remark on few general things, The site style is great, the articles is really excellent : D. Good job, cheers

  8. Appreciating the time and energy you put into your blog and detailed information you provide. It’s nice to come across a blog every once in a while that isn’t the same old rehashed material. Excellent read! I’ve saved your site and I’m including your RSS feeds to my Google account.

  9. Woah! I’m really enjoying the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s difficult to get that “perfect balance” between superb usability and
    visual appearance. I must say you have done a very good job with this.
    Also, the blog loads super quick for me on Firefox. Outstanding Blog!

  10. What i do not understood is if truth be told how you’re now not actually a lot more well-preferred than you might be now. You are so intelligent. You understand therefore significantly when it comes to this topic, produced me individually believe it from so many numerous angles. Its like men and women are not interested until it is something to accomplish with Lady gaga! Your personal stuffs outstanding. All the time deal with it up!

  11. Does your website have a contact page? I’m having trouble locating it but, I’d like to shoot you an e-mail.
    I’ve got some suggestions for your blog you might be interested in hearing.
    Either way, great site and I look forward to seeing it improve over time.

  12. Hi there just wanted to give you a quick heads up.
    The words in your content seem to be running off the screen in Opera.
    I’m not sure if this is a formatting issue or something to
    do with internet browser compatibility but
    I thought I’d post to let you know. The style and design look
    great though! Hope you get the issue resolved soon. Many thanks

  13. I’d like to thank you for the efforts you’ve put in writing this website.
    I am hoping to check out the same high-grade blog posts
    from you later on as well. In fact, your creative writing abilities has inspired me to get my very own blog now 😉

  14. Great items from you, man. I’ve take into account your stuff prior to and you are just too
    fantastic. I actually like what you have acquired here,
    really like what you’re saying and the way wherein you are saying it.
    You make it enjoyable and you continue to care for to keep it smart.
    I cant wait to read much more from you. That
    is really a wonderful web site.

  15. With havin so much content do you ever run into any issues of plagorism or copyright violation? My website has a lot of unique content I’ve either authored myself or outsourced but it looks like a lot of it is popping it up all over the internet without my agreement. Do you know any techniques to help reduce content from being ripped off? I’d definitely appreciate it.

  16. Hello there,

    My name is Aly and I would like to know if you would have any interest to have your website here at onlinetutorial.co.in promoted as a resource on our blog alychidesigns.com ?

    We are in the midst of updating our broken link resources to include current and up to date resources for our readers. Our resource links are manually approved allowing us to mark a link as a do-follow link as well
    .
    If you may be interested please in being included as a resource on our blog, please let me know.

    Thanks,
    Aly

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.