Adding new format st-scripts with questions etc for basic-data-type and
getting started with lists
Objective Questions
-------------------
.. A mininum of 8 questions here (along with answers)
1. How large can an integer in Python be?
Any Size.
2. How do you define a complex number in Python?
Using the following notation.
[Real part] + [Imaginary part] j
example ::
c= 3.2 + 4.6j
3. Look at the following piece of code ::
In []: f or t
Out[]:True
What can you comment about the data type of f and t ?
4. One major diffence between tuples and lists?
Tuples are immutable while lists are not.
5. Look at the following sequence ::
In []:t=true
NameError: name 'true' is not defined
What might be the reason for error here?
In this scenario , it seems the programmer wanted to create a variable t with the boolean value True with a capital T. Since no variable by the name true(small t) is known to the interpreter it gives a NameError.
6. Put the following string in a variable quotation.
"God doesn't play dice" -Albert Einstein
quotation='''"God doesn't play dice" -Albert Einstein'''
7. Given a tuple ::
tup=(7,4,2,1,3,6,5,8)
tup[-2]
5
8. What is the syntax for checking containership in Python?::
element in sequence
'l' in "Hello"
True
9. Split this string on whitespaces? ::
string="Split this string on whitespaces?"
string.split()
10. What is the answer of 5/2 and 5.0/2 . If yes , why.
Yes, There is a difference.
Because one is integer division and other is float division.
Larger Questions
----------------
.. A minimum of 2 questions here (along with answers)
1. Given two lists for example,
list1=[1,2,3,4] and list2=[1,2,3,4,5,6,7] write a program to remove one list from the other.
#. Write a program to check if a string is palindrome?