Q: What does the input() function always return?
Anonymous Quiz
10%
a) int
4%
b) float
48%
c) string
38%
d) depends on user input
π2β€1
π Top 10 Python Tuple Operations You Must Know π¦π
1.
βΊ
2.
βΊ
3.
βΊ
4.
βΊ
5.
βΊ
6.
βΊ
7.
βΊ
8. * operator β Repeat tuple
βΊ
9.
βΊ
10.
βΊ
βΊ
π‘ Bonus: Tuples are immutable β they canβt be changed after creation.
tup = (1, 2, 3, 4, 2)
1.
len() β Get length of tuple βΊ
len(tup) β 52.
count() β Count occurrences of a value βΊ
tup.count(2) β 23.
index() β Find index of a value βΊ
tup.index(3) β 24.
in keyword β Check existence βΊ
2 in tup β True5.
for loop β Iterate through elements βΊ
for i in tup: print(i)6.
slicing β Access sub-parts βΊ
tup[1:4] β (2, 3, 4)7.
+ operator β Concatenate tuples βΊ
tup + (5, 6) β (1, 2, 3, 4, 2, 5, 6)8. * operator β Repeat tuple
βΊ
tup * 2 β (1, 2, 3, 4, 2, 1, 2, 3, 4, 2)9.
tuple() β Convert iterable to tuple βΊ
tuple([7, 8]) β (7, 8)10.
min() / max() β Get smallest/largest item βΊ
min(tup) β 1 βΊ
max(tup) β 4π‘ Bonus: Tuples are immutable β they canβt be changed after creation.
Do not forget to React β€οΈ to this Message for More Content Like this
Thanks For Joining All β€οΈβ€5π₯°1
β€3