Defining variable is very simple in python just use variable name assignment operator and value. No need of type decleartion or any other prfix. Python detects data type by it self.
Python supports various data types some of the important types are listed below.
For storing numeric values, python supports four different types of numeric values.
Sequence of chracters str value can be used in different ways here are some examples of string defining and slicing a string in parts.
Different String functions
There are different functions available to manipulate a string. Some of them are given below.
- len() returns the length of string
- string.endsWith(“value”) return true if string ends with value
- string.count(“c”) count value c in a string
- string.capitalize() capitalize first character of string
- string.upper() upper case a string
- string.lower() lower case a string
- string.find(‘abc’) return index of first occurrence of abc
- string.replace(‘abc’, ‘a’) replace all abc with a in a string
Escape Sequence of Characters
Escaper sequence of characters are just like other languages
- \n new line
- \t tab etc.