data type must be used along with the _____ accordingly
Answers
Explanation:
This section focuses on the "Data Types" of the Python programming. These Multiple Choice Questions (mcq) should be practiced to improve the Python programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. Which statement is correct?
A. List is immutable && Tuple is mutable
B. List is mutable && Tuple is immutable
C. Both are Mutable.
D. Both are Immutable
View Answer
Ans : B
Explanation: List is mutable and Tuple is immutable. A mutable data type means that a python object of this type can be modified. An immutable object can’t. So, Option B is correct.
2. Suppose a list with name arr, contains 5 elements. You can get the 2nd element from the list using:
A. arr[-2]
B. arr[2]
C. arr[-1]
D. arr[1]
View Answer
Ans : D
Explanation: arr[0] will give first element while second element is given by arr[1] So, Option D is correct.
3. How to get last element of list in python? Suppose we have list with name arr, contains 5 elements.
A. arr[0]
B. arr[5]
C. arr[last]
D. arr[-1]
View Answer
Ans : D
Explanation: The arr[-n] syntax gets the nth-to-last element. So arr[-1] gets the last element, arr[-2] gets the second to last, etc. So, Option D is correct.
4. How to copy one list to another in python?
A. l1[] = l2[]
B. l1[] = l2
C. l1[] = l2[:]
D. l1 = l2
View Answer
Ans : C
Explanation: Option A and B syntax is incorrect while D will point both name to same list. Hence C is the best way to copy the one list to another. So, Option C is correct.
Answer:
In computer programming, we use the if statement to control the flow of the program. For
Here, condition is a boolean expression. It returns either true or false.
if condition evaluates to true, statements inside the body of if are executed
if condition evaluates to false, statements inside the body of if are skipped