Red Security
Variable and Strings - Printable Version

+- Red Security (https://redsecurity.info/cc)
+-- Forum: Programming (https://redsecurity.info/cc/forumdisplay.php?fid=5)
+--- Forum: Python (https://redsecurity.info/cc/forumdisplay.php?fid=9)
+--- Thread: Variable and Strings (/showthread.php?tid=345)



Variable and Strings - Mr. Nobody - 11-10-2017

----------------------------------------------------------------- VARIABLES & STRINGS   -------------------------------------------------------------------------------


Always keep in mind in python everything is an object. (Everything)

In python it is not statically typed. It means in python there is no need to declare variables before using it in code .

NUMBERS :

Python supports,

1> Integer Numbers
2> Floating Numbers
3> Complex Numbers

Ex. Print any number     
 myint = 9             // You can use myfloat = 9.0 and print(myfloat) //
 print(myint)


STRINGS :

Strings in the python can be defined either by single quote or double quotes.

Ex. Print string "Hello"

mystring = "Hello"  // You can use mystring = 'Hello' //
print(mystring)

We can use string and numbers to make some logical code too.

Ex. one = 1
    two = 2
    three = one + two
    print(three)

We can also add two string using python as ...

Ex. Add "Hello" and "Word"

strng1 = "hello"
strng2 = "world"
strng = hello + " " + world   // This is whitespace ==> " " //
print(strng)

We can also assign value to variable in python like,

a , b = 3, 4
print(a,b)

********************** Note you can't add string and numbers in python *******************************

Ex. one = 1
    two = 2
    strng = "Hello"
    print(one + two + strng)

It gives you error....! Angry

*****************************************************************************************************

 
 


RE: Variable and Strings - Mr.Kurd - 11-12-2017

thank you my friend, keep it up Smile