Python Basics 1.1
This article is the 4th of this series. In this am discussing basics of python basics like keywords, identifiers etc, in addition to that I’ll show how easily you can make programming your cup of tea by explaining and giving a demo on how to write your first code in python and in several other object oriented languages. It will give you a more clear view of Python world and python basics.
So let’s explore it.
For getting the theme of Python, kindly go through my previous article:
Chapter 1 | Python Properties
Chapter 2 | Python VS Other Languages
Chapter 3 | Environment and Setups
Chapter 4 | Python Basics 1.1…
Chapter 5 | Python Basics 1.2
Chapter 6 | Python Strings
Chapter 7 | Python Lists
Chapter 8 | Python Operators
Chapter 9 | Python Decision Making
Chapter 10 | Python Looping
Chapter 11 | Python Loop Control Statements
Chapter 12 | Python Tuples
Chapter 13 | Python Tuple Operations
Chapter 14 | Python Built-in Tuple Functions
Chapter 15 | Python Dictionary
Chapter 16 | Python Dictionary Operations
Chapter 17 | Python Function
Chapter 18 | Python Function Calling Arguments
Chapter 19 | Python Anonymous Function
Chapter 20 | Python Built-in Anonymous Function
In this article am going to take you through some of the basic parts of python that will include these contents:
- Writing Basic Python Snippet
- Python | Identifiers
- Python | Keywords
- Python | Comments
Writing your First Script
Now, without taking any more time am going to show you how easily you can write a Python Script without facing any problem.
I’ll try to explain it by comparing (in terms of structure and statements) with some other, featured Object oriented languages like C++, Java and .NET; so let’s go through it:
GoodBye World | C++
So, let’s take a look at a basic program in C++
GoodBye World | Java
So, let’s take a look at a basic program in JAVA
|public class Main
public static void main(String args)
GoodBye World | .NET
So, let’s take a look at a basic program in .NET
public class Hello2
public static void Main()
GoodBye World | Python
Now, it’s python. Have a look:
|Print “GoodBye World!”|
And it’s still “GoodBye World” guys..
“Now, guys I don’t think I have to write anything, in theory, as all those four code snippets saying it all. Choice is urs..”
Python | Identifiers
An identifiers, in general, programming terms can be defined as:
“A name that can be used for identifying variable, function, class, object, name etc. in a program, is called an Identifier.”
This same definition and concept also flow in python.
Here are some basic details one needs to know about python identifiers (common):
- Must start with upper case (A … Z) or lowercase (a … z) letters
- It can also be started with an underscore ‘_’ , followed by more letters
- It can also be the combination of underscore and numbers
- As python is a Case Sensitive Programming Language; so both ‘Letustweak’ and ‘letustweak‘ are different things for it.
- Python doesn’t allow you to use some special characters (@, #, $, %) in you identifier name.
- Class name starts with a uppercase letter followed by the lowercase.
Python | Keywords
A keyword, in general, programming term can be defined as:
‘These are reserved words that are already used in language for defining some special tasks or functionalities and you can’t use them as a constant or variable name in your code snippet.’
Let’s quickly take a look at those-
Python | Comments
Single Line Comments
I love C# and more than that the symbol ‘#’; so guys if you are .Net developer and you also love that symbol, then trust me you won’t gonna miss that in python because- in python a line that starts with a hash ‘#’ is considered as a comment by python interpreter.
So write comment and enjoy python, write as much as you can but in a limit and trust me it will gonna help you too. How- it will make your code more understandable, readable and it also considered as one of the guidelines of programming. So cheers!
Take a look at this snippet-
# So let’s Print Something- Comment 1
Print “A chunk of text!” # Print- Comment2
No worries, if you want a multiline comment in python. You can easily do that using this structure-
you comments goes here…
This is my multiline comment in python..
Print “A chunk of text!”
This 4th part was for making you comfortable with python that why I make several comparisons above.
Guidelines from our Side
- Do as much as code you can.
- Code anything you want, the best way to learn
- Don’t just study things, try to learn them.
- Work on your Concepts
- Work on the fundamentals of any technology or stuff you want to learn.
“Keep calm and code python”.
I tried to make it interesting and interactive article and wish you guys going to like that, meanwhile if you have any suggestions then your welcome.
Till the next part, keep sharing & Tweaking! 🙂