Discord Server Red Security Twitter Donation to Red Security Red Security Youtube Channel Red Security Tumblr Profile
Login or Register to Hide ads and Accessing all features on the forum

Variable and Strings

1 Replies, 2386 Views

----------------------------------------------------------------- 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

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

 
 
(This post was last modified: 11-11-2017, 08:13 PM by Mr.Kurd.)
thank you my friend, keep it up Smile
Rs
* Thankful to Allah *
Kurdy



Users browsing this thread: 1 Guest(s)