<jupyter_start><jupyter_text>List and its Default Functions<jupyter_code># Creating a List of numbers 
List = [10, 20, 14] 
print("\nList of numbers: ") 
print(List) 
# Creating a List of strings and accessing 
# using index 
List = ["shivam", "shubh", "shiv"] 
print("\nList Items: ") 
print(List[0])  
print(List[1])  
print(List[2])  
# Python program to demonstrate  
# Addition of elements in a List 
   
# Creating a List 
List = [1,2,3,4] 
print("Initial List: ") 
print(List) 
# Addition of Element at  
# specific Position 
# (using Insert Method) 
List.insert(3, 12) 
List.insert(0, "guru") 
print("\nList after performing Insert Operation: ") 
print(List)
# Python program to demonstrate  
# Removal of elements in a List 
  
# Creating a List 
List = [1, 2, 3, 4, 5, 6,  
        7, 8, 9, 10, 11, 12] 
print("Intial List: ") 
print(List) 
# Removing elements from List 
# using Remove() method 
List.remove(5) 
List.remove(6) 
print("\nList after Removal of two elements: ") 
print(List)<jupyter_output>List after Removal of two elements: 
[1, 2, 3, 4, 7, 8, 9, 10, 11, 12]<jupyter_text>Dictionary and its Default Functions<jupyter_code># Creating a Dictionary  
# with Integer Keys 
Dict = {1: 'tit', 2: 'For', 3: 'tat'} 
print("\nDictionary with the use of Integer Keys: ") 
print(Dict) 
# Creating an empty Dictionary 
Dict = {} 
print("Empty Dictionary: ") 
print(Dict)<jupyter_output>Empty Dictionary: 
{}<jupyter_text>Sets and its Default Functions<jupyter_code># Create a Set:

thisset = {"ram", "sham", "jaya"}

print(thisset)
# Loop through the set, and print the values:

thisset = {"ram", "sham", "jaya"}

for x in thisset:
  print(x)
# Check if "sham" is present in the set:

thisset = {"ram", "sham", "jaya"}

print("sham" in thisset)

# Add an item to a set, using the add() method:

thisset = {"ram", "sham", "jaya"}

thisset.add("priya")

print(thisset)
# Get the number of items in a set:

thisset = {"ram", "sham", "jaya"}


print(len(thisset))<jupyter_output>3<jupyter_text>Tuple and explore Default Methods<jupyter_code># A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets.
#Create a Tuple:
thistuple=("ram", "sham", "jaya")
print(thistuple)
# Print the third item in the tuple:

thistuple = ("ram", "sham", "jaya")
print(thistuple[2])

# Range of Indexes
#Return the second,third and fourth,  item:

thistuple = ("ram", "sham", "jaya","orange", "riya", "yash", "priya")
print(thistuple[1:3])
# Change Tuple Values
# Convert the tuple into a list to be able to change it:

x = ("ram", "sham", "jaya")
y = list(x)
y[1] = "riya"
x = tuple(y)

print(x)
# Join two tuples:

tuple1 = ("M", "N" , "O")
tuple2 = (11, 22, 33)

tuple3 = tuple1 + tuple2
print(tuple3)

# Print the number of items in the tuple:

thistuple = ("ram", "sham", "jaya","orange", "riya", "yash", "priya")
print(len(thistuple))
# Check if "sham" is present in the tuple:

thistuple = ("ram", "sham", "jaya","orange", "riya", "yash", "priya")
if "sham" in thistuple:
  print("Yes, 'sham' is in the names tuple")<jupyter_output>Yes, 'sham' is in the names tuple<jupyter_text>String and Explore Default Methods<jupyter_code># String Literals
#String literals in python are surrounded by either single quotation marks, or double quotation marks.

# 'hello' is the same as "hello".

# we can display a string literal with the print() function:

print("Hello")

# Assigning a string to a variable is done with the variable name followed by an equal sign and the string:
a = "Hello"
print(a)
# To get the length of a string, use the len() function.

# The len() function returns the length of a string:

a = "Hello, World!"
print(len(a))
# String Methods
# Python has a set of built-in methods that you can use on strings.

# he strip() method removes any whitespace from the beginning or the end:

a = " Hello, World! "
print(a.strip()) # returns "Hello, World!"

# The lower() method returns the string in lower case:

a = "Hello, World!"
print(a.lower())

# The upper() method returns the string in upper case:

a = "Hello, World!"
print(a.upper())

# the split() method splits the string into substrings if it finds instances of the separator:

a = "Hello, World!"
print(a.split(",")) # returns ['Hello', ' World!']<jupyter_output>['Hello', ' World!']
StarcoderdataJupyterStructuredCleanDedup