Pmd091023 (11/10/23)

1.Which of the following are immutable?
String
Tuple
Dictionary
List

2.Which of the following are True?

tuples are immutable
dict keys are immutable
set keys are immutable
dict keys are unique

3.Can I add elements into a list present inside a tuple?

Yes
No

4.What data types are eligible for becoming keys in dict?

tuples
list
float
set

5.Where is indexing NOT possible?

list
set
dict
string

6.What will be the output of the following code:

a = 1
b = 1
print(id(a) == id(b))

7.What will be the output of the following code?

a = (1,2,3)
b = (1,2,3)
print(id(a[0]) == id(b[0]))

8.How many Object will be formed in the memory after running this line of Python?

x = [(1,2,3),{1,1,1,2},“This Question is Easy Please don’t skip it”,3.14]

9.Which of the Following is False?

Dict Keys are Unique
Set Keys are Immutable
Tuple inside a list can be edited
List inside a tuple can be edited

10.Type Casting/Data Type Conversion is Possible in both direction from list to tuple and from tuple to list.

True
False

  1. x = [‘Python’ ,‘java’ ,‘c++’,‘Ruby’ ,‘C’]
    find out first element, last element, find a in java, h in python, + in c++?
  1. String, Tuple
  2. All of the above
  3. Yes, as long as the list stays in the tuple
  4. Tuples and Float as they are immutable, hence the best options to have as keys
  5. Set, they don’t have index.
  6. True, same values.
  7. True, same value and index location
  8. Probably 8 but not sure
  9. Tuple inside a list can be edited is false.
  10. Yes, I think so.
  11. First Element = x[0],
    Last Element = x[-1],
    “a” in java = x[1][1],
    “h” in Python = x[0][3]
    “+” in C++ = x[2][1]
1 Like

1.String,Tuple
2. all statements are True
3.Yes-elements can be added to the list inside the tuple but cannot add list with new elements inside tuple once tuple is created
4.tuples,float
5.set
6.True
7.True
8.7
9.Tuple inside a list can be edited
10.True
11.
print(x[0]) - First Element
print(x[-1]) - Last Element
print(x[1][1],x[1][3]) - a in java
print(x[0][3]) - h in python
print(x[2][1],x[2][2]) - + in C++

1 Like
  1. String ,tuple

  2. All True

  3. yes list inside tuple can be edited

  4. tuple and set

  5. set

  6. true

7)true

  1. 8 object

9)list inside a tuple can be edited is false

10)True

  1. print(x[0])
    
    Python
    print(x[-1])
    C
    print(x[1][1])
    a
    print(x[0][3])
    h
    print(x[2][1])
    +
1 Like
  1. String and Tuple are immutable .

  2. All of the above are True .

  3. Yes,
    4.Tuples
    5.Set

  4. True

  5. True

  6. 7

  7. Tuple inside a list can be edited

  8. True

  9. x = [‘Python’, ‘java’, ‘c++’, ‘Ruby’, ‘C’]

    First element
    

first_element = x[0]
Last element
last_element = x[-1]
Check if ‘a’ is in ‘java’
a_in_java = ‘a’ in x[1]
Check if ‘h’ is in ‘python’
h_in_python = ‘h’ in x[0]
Check if ‘+’ is in ‘c++’
plus_in_c_plus_plus = ‘+’ in x[2]

1 Like

1 string ,tuple

2.tuples are immutable
dict keys are immutable
set keys are immutable
dict keys are unique

3.yes

4.tuple, float

5.set

6.true

7.true

  1. three object (not sure)

9.Tuple inside a list can be edited

10.true

11.first element = x[0],
last element = x[-1],
a in java = x[1][1],
h in Python = x[0][3]

  • in C++ = x[2][1]
1 Like
  1. String, Tuple

  2. Tuples are immutable, Dict keys are immutable, Dict keys are unique

  3. No

  4. Tuples, Strings

  5. Set, Dict

  6. True

  7. True

  8. 4

  9. List inside a tuple can be edited is False

  10. True

  11. x = [‘Python’, ‘java’, ‘c++’, ‘Ruby’, ‘C’]
    first_element = x[0]
    last_element = x[-1]
    a_in_java = ‘a’ in x[1]
    h_in_python = ‘h’ in x[0]
    +_in_c++ = ‘+’ in x[2]

The values will be:

  • first_element: ‘Python’
  • last_element: ‘C’
  • a_in_java: True
  • h_in_python: True
  • `+_in_c++: True
1 Like

Question 1
Tuple and string

Question 2
All of them are True

Question 3
Yes

Question 4
float, Tuples

Question 5
Set and Dict

Question 6
True

Question 7
True

Question 8
4 objects

Question 9
Dict keys are unique
Tuple inside a list can be edited
List inside a tuple can be edited

Question 10
True

Question 11
First Element = Python[0]
Last Element = C[4]
Location of a = [1][1]
Location of h = [0][3]
Location of + = [2][1]

1 Like
  1. String, tuple
  2. All True
  3. yes
  4. tuples, float
  5. set
  6. True
  7. True
  8. 5
  9. Tuple inside a list can be edited
  10. True
  11. First Element - print(x[0])
    Last Element - print(x[-1])
    a in Java - print(x[1][1])
    h in python - print(x[0][3])
    • in c++ - print(x[2][1])
1 Like

1.String,Tuple
2. all statements are True
3.Yes-elements can be added to the list inside the tuple but cannot add list with new elements inside tuple once tuple is created
4.tuples,float
5.set
6.True
7.True
8.7
9.Tuple inside a list can be edited
10.True
11.
print(x[0]) - First Element
print(x[-1]) - Last Element
print(x[1][1],x[1][3]) - a in java
print(x[0][3]) - h in python
print(x[2][1],x[2][2]) - + in C++
[/quote]

1 Like

sorry for late submission

1.Tuple, String

2.All True

3.List inside[ tuple()] : yes it editable
but tuple inside() lists[]) : no

4.tuple and float

5.set

6.True

7.True

8.Object:10, name:1

9.Tuple inside a list can be edited : False

10.yes

11.print(x[0], x[-1] ,x[1][1] , x[0][3], x[2][1])

1 Like