Red Security

Full Version: Variable and Strings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
----------------------------------------------------------------- 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

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

 
 
thank you my friend, keep it up Smile