Page 122 - Code_GPT_Class_8
P. 122

Factbot


                There are around 700 separate programming languages. Some of the most popular ones are JavaScript,
                Swift, Scala, Python, PHP, Go, Rust, Ruby and C#.



              String Built-in Functions


              Python includes the following built-in functions to manipulate strings:

                  len(): The len() function calculates and returns the length of a string supplied as an argument. The
                  syntax of using the len() function is:
                 len(string_name)

                  lower(): The lower() function converts all uppercase letters to lowercase. The syntax of using the
                  lower() function is:
                 string_name.lower()

                  upper(): The upper() function converts all lowercase letters to uppercase. The syntax of using the
                  upper() function is:

                 string_name.upper()

                  capitalize(): The capitalize() function returns a string with the first character in capital  and the rest
                  in lowercase. The syntax of using capitalize() function is:
                 string_name.capitalize()

              Program 9: To use various string built-in functions

                   Program9.py                                                 Output

                File  Edit  Format   Run   Options   Window    Help         5
                                                                            hello
                str = 'Hello'
                                                                            HELLO
                print(len(str))
                                                                            Hello
                print('Hello'.lower())
                print('hello'.upper())
                print('hello'.capitalize())





                       Topic Flashback                                                   21 st  Century
                                                                                             Skills  #Information Literacy

                     1.  What is a string?


                     2.  What are escape sequences?







                        CodeGPT (Ver. 4.0)-VIII
                120
   117   118   119   120   121   122   123   124   125   126   127