Start To Learn Python Right Now EP04: Python Variables & Basics


In Episode 03 we talk about a good IDE for starting Python programming. Now, I'm going to start the first learning point of Python. Every programming language has its own variable format so Python also has one. Also, these variables are the base of programming on one side. 

Variables are used to store a changing value in programming. Not like other languages in Python variables you can change even the type of variable inside anywhere in your program. In every programming language, they have the same variable types, these are the common variable types used in Python,

  •      int - int means integer, this variable type using to numbers in Python
  •      str - str means string, this variable type using to text in Python
  •      bool - bool means boolean, this variable type used to store conditional types True and False are the only thing that can be stored in Python bool.
  •     hex - hex means Hexa values, this variable used to store Hexa values in Python
  •     float - float is used to represent decimal numbers. 
  •     complex - this is used to create complex value variables like a mix of letters and numbers

Also, we can use Python Arrays as a Python variable, I'll talk more about Python arrays in a future post. 

Creating Variables

 There are a few ways to make variables in Python. Another basic thing I need to teach is the "print()" statement. This "print()" statement using to print a result or something in Python. Also, the "#" symbol is used before a statement to create a comment in Python.

Note: Python is a case-sensitive language. By default, upper case or numbers are not allowed in the begging of Python variables. 
      1.You can make variables by specifing the variable type
       ex: s = str(100)
             s = int(100)
             s = float(100)
             s = bool(True, False)

     
2. You can make variables without specifying a format, but it will choose a default type according to the value you assign
      ex: s = 10
            s = "softexs.com"
            s = 5.8


Now you have a problem, How to check the type of variable, to find the type of variable you can simply use the "type()" statement. That statement represents the type of variable you created
ex: softexs  = "www.softexs.com"
      print(softexs.com)
      print(type(softexs))

Post a Comment

If you have any doubt, Let us know

Previous Post Next Post