-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathday10.py
More file actions
50 lines (27 loc) · 988 Bytes
/
day10.py
File metadata and controls
50 lines (27 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'''
In Python, a tuple is an ordered, immutable, and heterogeneous collection of elements. Tuples are similar to lists, but the key difference is that tuples cannot be modified once they are created. Here's how you can create and work with tuples in Python:'''
# mytuple=()
# print(type(mytuple))
# Creating a tuple using parentheses
# my_tuple = (101,101, 102, 103)
# Creating a tuple without parentheses
# another_tuple = 4, 5, 6
# print(type(another_tuple))
# Accessing Elements:
# print(my_tuple[0])
# Slicing:
# sliced_tuple = my_tuple[1:3] # This creates a new tuple (102, 103)
# print(sliced_tuple)
# loop through tuple
# for i in my_tuple:
# print(i)
# Tuple Methods
# print(my_tuple.count(101))
# length of tuple
# print(len(my_tuple))
# print(my_tuple.index(101))
# Join Tuple
# tuple1 = ("Rohit", "Pragati" , "shubham",'karan')
# tuple2 = (1, 2, 3)
# NewTuple = tuple1 + tuple2
# print(NewTuple)