Page 224 - Robotics and AI class 10
P. 224

>>> T=tuple(L)

        >>> type(T)
        <class 'tuple'>
        A tuple can be converted into a list by using a built-in function list()
        For example:

        >>> L=[1,2,3,4]

        >>> type(L)
        <class 'list'>
        >>> T=tuple(L)
        >>> type(T)

        <class 'tuple'>
        >>> L2=list(T)
        >>>L2
        [1, 2, 3, 4]
        >>> type(L2)

        <class 'list'>

                 Strings

        String is a sequence of one or more ASCII/Unicode characters. These characters may be alphabets in uppercase or
        lowercase, digits, whitespaces or any other special character.
        It is created by enclosing these characters either in single quotes or double quotes.

        For example:
        >>> s1 = 'Hello children'

        >>> s2 = "Let us do Python"
        If the string is made up of content which extents to more than a line then it can be enclosed in triple quotes as
        shown below:

        >>> s3 = """Python is an interesting
                 Programming language."""
        >>> s4 = '''It is free and open source.
                  Happy Learning!'''


        Creating Strings
        Creating strings is a fundamental concept in Python programming. Strings are used to represent and manipulate
        text data. In Python, strings are enclosed in either single quotes (' ') or double quotes (" "). Creating strings involves
        defining the desired text within these quotation marks. Here's a brief introduction to creating strings in Python:


         Let us now do a small code:
         Input a name and display a welcome message.

         nm=input("enter a name ")
         print("Hello",nm,"Happy Learning !")


              222     Touchpad Robotics & Artificial Intelligence-X
   219   220   221   222   223   224   225   226   227   228   229