In this video, I have given detailed explanation about datatypes. what is a numbers, how to store values in variable, how to assign multiple values at the same time. I have covered some arithmetic operation by using the variable name. I have explained how to store a string and explained about string data type. I have used print function and printed a message and also solved spaces issues.

DATATYPES- NUMBERS AND STRINGS

Data types: As mentioned earlier, particular byte is reserved in memory when a variable is declared. This memory location depends on the data types user defines. For example, a person’s name is a string and his age and income in a numeric value.

Python have five standard data types:

  • Numbers
  • String
  • List
  • Tuple
  • Dictionary

Python Numbers: This data type is used to store numeric value. For example:

Age = 25

Income = 25000

Python have four different numeric types with examples are shown below:

  • Int (signed integer): 50, -68, 0x10, -0x250, etc.
  • Float(floating point real values): 13.2, 48.59, 6.0-E15, -85,etc.
  • Long(long integers, can be represented in octal and hexadecimal format): 9876L, -0x21L, 5425426L, etc. uppercase L symbol is used to display or represent long integer.
  • Complex( complex numbers): 12+51j, -87j, 8e+0j, etc. A complex number is usually represented in x+iy format, where x and y are real numbers and j is imaginary unit(j2 = -1).

Python String: This data types is used to store the set of characters which can be represented in single or double quotation marks. For example, Name = “ROCK”. So here, ROCK is a string which is stored in a variable called Name. We can directly use print command as explained in my video with string to concatenate more than one string. For example,

Val1 = “WELCOME”

Val2 = “TO”

Val3 = “ELECTROFUN”

Print(Val1 + Val2 + Val3)

Output: WELCOME TO ELECTROFUN

In my video I have explained how to work on spaces between two strings.

FUNCTIONS: Some predefined functions you can use with strings are:

Str(): Using this function, user can access every single character. For example, Name = “JACK”

Str(Name[0]) will give me J, because indexing always starts with zero. So the output will be J. Similarly, you can access any of the character in a string individually.

Len(): Using this function, user can find out the total length of the string. For example, len(Name) will give me value as 4.

We will come across more string functions in our other videos.