Skip to main content

Posts

Showing posts with the label index

List, Tuple and manipulation operation on Python Hunter's blog.

   List   in python are the most flexible datatype in python. Python list looks identical to c++ and java's array (elements separated by ',' coma) but unlike in features. Like c++ and java's array hold only similar types of elements (e.g String, int, double) and these programming languages have limitation to grow the size of their declared array at run time, array size has to defined at compile time (there could be some logic to decide the array size at run by getting the user's input but, after that it will be fixed, but it is not recommended) But Python list is slightly different from c++ and Java's array as it can grow it's size at run time and hold any multiple dataType in one single list (e.g string, int, char, Boolean....... all together in one list ).      # Following are the ways to create list. Output:- ---------------------- Source Code Starts -------------------- 1 2 3 4 5 6 7 8 9 10 1...

Sequential Data Types with Python Hunter

Sequential Data Types A String can be seen as a sequence of characters, which can be expressed in several ways: 1). Single quotes (')     e.g  'This is PythonHunter's Blog' 2). Double quotes (")       e.g " This is PythonHunter's Blog" 3). Triple quotes thisOne (') or thisOne (")         e.g """ This is PythonHunter's Blog""" We use triple quotes to define a string if we have any quotes on our string data.  Sequential data always get stored with indexing and indexing starts from 0. Unlike other programming languages python provides the negative indexing to get  the elements from last indexing.      Source:- myVar = " PythonHunter " print (myVar) len_ = len (myVar) for i in range ( len (myVar)): print (myVar[i] + " is at index " + str (i)) print ( " * " * 25 , " The negative index " + " * " *...