DEV Community

Vishal J
Vishal J

Posted on

July 10, 2024 Python | DataTypes, Variables, Constants

This is a series of Python learning blog from parottosalna community by kaniyam foundation

This blog is based on this video Python | DataTypes, Variables, Constants | ParottaSalna"

To watch the full series check this youtube playlist

Contents

  1. Datatypes
  2. Variables
  3. Constants
  4. General Notes

Datatypes:

  • 3 Types of Datatypes

    1. Numeric
      1. Integer
      2. Float / Decimal number
      3. Constants
    2. Text
    3. Boolean Types
      • True, False, None
      • Examples:
        • is_active = true
        • no_of_apples = none
  • Command to check the input type type(26) , Output will be int datatype

  • Everything in Python Language is "Object"

  • Command to see functionalities of a Object dir(26) , Output show the available functionalities as a list.

  • str is the short form of String.

  • Addition of Strings

    • "Vishal" + "J" , The Output will be VishalJ

Variables:

  • Variable is a container to hold the values. And Variables will refer to Object / Value / Data.

  • There are some regulations in variable writing

    1. No symbol in-between
    2. Only start with Characters.
  • Command for Multiple assignment

    • name, age = "Vishal", 20
      • Here is a example of tuple data type
  • Command to print the datatype in a program

    • print(type(name))
  • Running inspect - terminal option in browser to use JavaScript program

  • Commenting is useful to denote what is going in a program

    • To comment single line #
    • To comment multiple lines """Hello world """

Constants:

  • Types of Constants styles

    1. PascalCase
    2. Camelcase
    3. snake_case
  • Google Colab uses Jupiter notebook and into include automatic feature to print texts without print function

  • Book recommendation

    • Byte of Python
  • Quiz's and Tasks for Practising

  • File handling commands

    • Command to create a new file "file.txt" in F folder with program of print("Some content")
      • with open("file.txt", "w") as f: print("some content", file=f)
  • Concatenate make to add two strings as metioned in above before

    • print("Hello" + " World" , the Output will be Hello World
    • print("Hello" , "World") , The Output will be Hello World . Here the the , symbol will add some space between the words.

General Notes

  • By using Books you can use to self study and to advance

  • Note: We can paste images in Zoom chat option

  • To learn JavaScript one must have to know HTML

  • Forums to ask questions

    1. Stack overflow
    2. Chennai mailing list
    3. Tamil Linux Community

Top comments (0)