Both single and double quotation marks in python are used to specify some string data.
For instance
def func():
"""This is a docstring, it's similar to what a comment is!""""
a = 'This is a string'
b = "I am Knuth's fan."
print(a)
print(b)
# Calling the function
func()
# Everything in python is Object, even functions!
print(func)
# Accessing a docstring
print(func.__doc__)
The output shall be
This is a string
I am Knuth's fan.
<function func at 0x7fbc5853cf28>
This is a docstring, it's similar to what a comment is!
As you can see, both a
and b
are examples of strings. By using single quotation marks, you can avoid using the slashes for the double quotes and vice versa.
Everything in python is an object, and so do functions. The third output statement may vary on your computer.
Lastly, 3 double quotations marks are also used in python. These are called Docstrings. These work similar to as comments, but are not used the same way. They are used to give a brief summary of what a module/class/function is going to do, just in the starting of them, and not in the middle of the body. Since docstrings are special, they can be accessed using doc attribute of the object it is associated with.
Coming to your next doubt regarding how to deal with array of integers in python, firstly, array is not a buil-in datatype in Python. We have something called list, which is simply a collection of objects. You may be interested in the array module, which is built-in in the Standard Library.
>>> a = ["Jack", 5, func, [7,8], 10.0]
>>> a
['Jack', 5, <function func at 0x7fbc5853cf28>, [7, 8], 10.0]
>>> from array import array
>>> arr = array('i', [1,5,9,7,8,4,6,3])
>>> arr
array('i', [1, 5, 9, 7, 8, 4, 6, 3])
>>> arr[1]
5
>>> arr[2]
9
>>> arr.append(54)
>>> arr
array('i', [1, 5, 9, 7, 8, 4, 6, 3, 54])
>>> arr.pop()
54
>>> arr.pop()
3
>>> arr.insert(3, 60)
>>> arr.insert(3, 60)
>>> arr
array('i', [1, 5, 9, 60, 60, 7, 8, 4, 6])
>>> arr.count(60)
2
>>> arr.tolist()
[1, 5, 9, 60, 60, 7, 8, 4, 6]
>>> arr.tostring()
b'\x01\x00\x00\x00\x05\x00\x00\x00\t\x00\x00\x00<\x00\x00\x00<\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\x04\x00\x00\x00\x06\x00\x00\x00'
>>> arr.reverse()
>>> arr
array('i', [6, 4, 8, 7, 60, 60, 9, 5, 1])
>>> arr.remove(60)
>>> arr
array('i', [6, 4, 8, 7, 60, 9, 5, 1])
I hope you got your doubt resolved. You can play with the array module, refer to the documentation.