# Python For Beginner's Day - 5

\-&gt; **Numeric Data Types Conversion**:

* Conversion is possible using int(), float() and complex() methods, but complex numbers cannot be converted to another number type.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717373692026/f2a99709-4b93-4496-8480-3c9cbf11a215.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717373716157/4fcc3475-f49e-4bec-9653-fb3187c3730a.png align="center")
    
    \-&gt; **Casting**:
    
* Casting can be done using constructor functions, int(), float() and str().
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717374651160/80a58118-b06c-476f-ac2a-8af91f02aaf9.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717374682604/2ba43335-72c6-4cb0-b1ba-82dee49b11eb.png align="center")
    
    \-&gt; **Booleans**:
    
* Any expression can be evaluated and returns either True or false.
    
* bool() function will evaluate any value, and returns any of the value.
    
* Some values are always false, the empty values like (), \[\], {}, "", 0 and None.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717423451991/3eb4c382-fd85-4a99-bbb0-46dc82e1927e.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717423480054/69368cc4-bc8e-4603-a2ac-edf49d9ed4fb.png align="center")
    
    \-&gt; **Strings**:
    
* Strings can be represented by using Single quotes(' ') or double quotes(" ").
    
* Multiline Strings can be represented using 3 Single Quotes or 3 double quotes.
    
* Strings are similar to Arrays, square brackets(\[\]) can be used to access the elements of the string.
    
* To get the length of the string, use len() function.
    
* To check if particular word or character is present in the string, use keyword 'in'
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717426295486/3d2ff3b9-1caa-4c19-909c-0c08dd41196b.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717426637510/aa111c96-92bb-4e8a-a850-f65bcc126fe0.png align="center")
    
    and to check if it is not present in the string, use 'not in'
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717426541008/75936067-3d7a-4d70-89cc-60ac29f1c669.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717426570187/928a1470-1243-4cf3-9ef8-b1176d8c68db.png align="center")
    
    \-&gt; **Slicing**:
    
* It's used to return the part of the string using 'a:b' , here a is the start index and b is the end index(which is not included) and the index starts from 0.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717430661873/de093fbe-4a54-4fb1-8e26-6a9171687192.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717430683493/51ac6035-c1ef-4f33-ad45-aab6efe1c242.png align="center")
    
    Slice from start will start from first character, by leaving start index,
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717430838609/6caf584b-aed1-4a2e-92a5-6f1ffe240edb.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717430864221/4fca1709-332f-4f7f-803b-c0f26574e7df.png align="center")
    
    Slice to the end will go to the end, by leaving end index,
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717431240273/66f28bb4-f021-46c8-9489-238246fc3349.png align="center")
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717431269268/799884e4-047d-4d89-be44-910c587a0143.png align="center")

Use Negative Indexing, to start the slice from end of the string,

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717431516992/999b0745-fb0f-4bbf-9cc6-d81493e720d5.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717431547291/2d1328e8-6a1a-441b-8b97-527edb13b8a1.png align="center")

\-&gt; **Modify Strings:**

* upper() method returns the string in Upper Case.
    
* lower() method returns the string in Lower Case.
    
* strip() method is used to remove the whitespaces at the beginning and/or at the end.
    
* replace() method is used to replace a string with another string.
    
* split() method returns a list where the text between the specified separator becomes the list items.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717432640818/048f261b-469f-4b10-85ae-9ba36eefef97.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717432664952/b0e19fbf-cbdf-4680-872b-9a734f6f7759.png align="center")
    
* Concatenation is used to combine 2 strings using + operator.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717433114253/1a774d1a-64b7-4e4d-b578-767718631e7e.png align="center")
    
* But to combine string and an integer, we can't use + operator instead we can use format() method.
    
* format() method is used to specify the string as f-string, and add curly brackets{} as placeholders.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1717433626940/03099abc-3106-41b0-ab44-86cd7fddd142.png align="center")
    
* The placeholder can contain variables, modifiers, operations and functions to format the value.
