Operators in Python, how to use operators in Python
As Like other programming Languages like C, C++, Java, C# etc the Python also supports the series of Operators, These include arithmetic operators, such as +, -, and *, and so on, assignment operators, +=, -=, *=, and so forth.This just means instead of z = z + 1, you can use z += 1.Absent are the increment/decrements operators (++ and --) you may have used in other programming languages. The standard comparison operators, such as <, >=, ==, !=, and so on, are also available,
and you can group clauses together with Boolean AND and OR with and & or, respectively.
There is also a not(!) operator that negates the Boolean value of a comparison.The
following example show you how its use.
display_output = True if display_output and shoo == 1:
print 'Django and %s are used to developed websites %d' % ('Python', shoo)
I assume you are familiar to programming with other programming languages and you know how to separates the one block of code to other block of code with curly braces({}) and terminate a statement with semi colon (;) but, in python there are no need to these symbols each block of code is separated with indentation
Python has an absence of symbols in general.
num2=14
num3=num1+num2
for lettor in "Welcome in Python"
print "current lettor :",lettor
print num3
output
current lettor :W
current lettor :e
current lettor l
current lettor :c
current lettor :o
current lettor :m
current lettor :e
current lettor :i
current lettor :n
current lettor :P
current lettor :y
current lettor :t
current lettor :h
current lettor :o
current lettor :n
24
As Like other programming Languages like C, C++, Java, C# etc the Python also supports the series of Operators, These include arithmetic operators, such as +, -, and *, and so on, assignment operators, +=, -=, *=, and so forth.This just means instead of z = z + 1, you can use z += 1.Absent are the increment/decrements operators (++ and --) you may have used in other programming languages. The standard comparison operators, such as <, >=, ==, !=, and so on, are also available,
and you can group clauses together with Boolean AND and OR with and & or, respectively.
There is also a not(!) operator that negates the Boolean value of a comparison.The
following example show you how its use.
display_output = True if display_output and shoo == 1:
print 'Django and %s are used to developed websites %d' % ('Python', shoo)
I assume you are familiar to programming with other programming languages and you know how to separates the one block of code to other block of code with curly braces({}) and terminate a statement with semi colon (;) but, in python there are no need to these symbols each block of code is separated with indentation
Python has an absence of symbols in general.
- There are no delimiting braces({}) for separation of blocks of codes.
- No trailing semicolon (;) to end lines of code
- No dollar signs ($) for declaring variables like PHP,
- No required parentheses (( )) for conditional statements (such as the preceding if , loops).
num2=14
num3=num1+num2
for lettor in "Welcome in Python"
print "current lettor :",lettor
print num3
output
current lettor :W
current lettor :e
current lettor l
current lettor :c
current lettor :o
current lettor :m
current lettor :e
current lettor :i
current lettor :n
current lettor :P
current lettor :y
current lettor :t
current lettor :h
current lettor :o
current lettor :n
24
{ 0 comments... read them below or add one }
Post a Comment