Discord Server Twitter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable and Strings
#1
----------------------------------------------------------------- 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

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

 
 
Reply
#2
thank you my friend, keep it up Smile

[Image: 0yaXvcy.gif]
We Are Anonymous, We Are Legion, We Do not Forgive, We do not Forget
Expect Us
Reply




Users browsing this thread: 1 Guest(s)