Wednesday, March 30, 2022

Day 3 Python variable (Hindi and english notes)

 Variable :- Direct Assign value

        Rules : -use only alphabets and _underscore in starting & it is case sensitive .

        example: x = "John" ,x = 'John'

Casting : Specify the datatype of a variable

        X = Str(3)  #it will show x contain integer

Note important function - type(x)  output : <class 'int'>

Cases :- Camel Case : myVariableName = "John"

        Pascal Case : MyVariableName = "John"

        Snake Case : my_variable_name = "John"

    Assign Values

1.   x, y, z = "Orange""Banana""Cherry"
2. x = y = z = "Orange"
3.fruits = ["apple""banana""cherry"]
  x, y, z = fruits


Global Variables : variable created outside of function.(by using Global keyword use can change the vaule.)


Python datatypes:
x = "hello yunus sir "        -    Str
x = 20                        -    int
x = 20.5                      -   float
x = 4j                        -   Complex
x = [ "apple", "banana"]      -    List
x = ("apple", "banana")       -    Tuple
x = range(6)                  -     range
x = True                      -     bool
x = {"apple","banana"}        -    set (no duplicate value)

Note : Random.randrange(1,10) print : 6 any use random Module

No comments:

Post a Comment