Every programming language has basic elements which are collection of literals,variables and keywords. in this tutorial we will explain what these terms means.
Literals:
It is string or number that directly appears in the program. e.g
15 #Integer literal
21.0 #Floating literal
5j #Complex number literal
'Hello' #String literal
"World" #String literal
'''
First line
Second line ##Triple quoted string literal
Third line
'''
In python you can use both single or double quote to represent string. For multiple line you can use triple quoted string which again can be single quote or double quote.
Variables:
It is use to store data in a program. To set it you choose the variable name and equate it to value of variable. e.g
a = 10
b = "Hello World!!!"
To know the type of the variable you can use type function as follow.
type(a)
A variable can be start with _ (underscore) e.g
_a = 10
It cannot start with number.
Keywords:
Python has 30 keywords which are identifiers that python reserve for special use.Keywords contain lower case only. you cannot use keyword as regular identifiers. Following are some keywords example.
and, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global, if, import, in, is, lambda, not
Comments:
Comments are line used for documentation for other programmer to understand the code flow.
A comment begins by a hash sign (#). All characters after the # and up to the physical line end are part of the comment.
For example,
This program computes area of rectangle
a = b+c # values of b and c are added and stored in a
Printing:
To print on terminal you can use print statement. e.g
print "Hello World"
You can also print the variable value. e.g
a = 10
print "Area of rectangle. "+str(a)
We can use '+' sign to concatenate two string.
Hope you like this tutorial. See you in the next tutorial till then "Happy Coding".
Please join the @labwork team and Up vote,follow and resteem.
Comments are always appreciated.
Congratulations! This post has been upvoted from the communal account, @minnowsupport, by labwork from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.
If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.