Practical No 8
keys = ['apple', 'banana', 'cherry']
values = [1, 2, 3]
# Map the lists into a dictionary
mapped_dict = dict(zip(keys, values))
# Print the resulting dictionary
print(mapped_dict)
Practical No 9
def count_word_frequency(text):
text = [Link]()
words = [Link]()
word_freq = {}
for word in words:
clean_word = ''.join(char for char in word if [Link]())
if clean_word:
word_freq[clean_word] = word_freq.get(clean_word, 0) + 1
return word_freq
input_string = "Hello world! Hello, OpenAI. OpenAI creates, OpenAI innovates."
frequency = count_word_frequency(input_string)
print(frequency)
Practical No 10
def recursive_length(lst):
if not lst:
return 0
else:
return 1 + recursive_length(lst[1:])
my_list = [10, 20, 30, 40, 50]
print("Length of the list:", recursive_length(my_list))
Practical No 11
import math
class Sphere:
def _init_(self, radius):
[Link] = radius
def diameter(self):
return 2 * [Link]
def circumference(self):
return 2 * [Link] * [Link]
def volume(self):
return (4/3) * [Link] * ([Link] ** 3)
radius = 5
sphere = Sphere(radius)
print("Diameter: {[Link]()}")
print("Circumference: {[Link]()}")
print("Volume: {[Link]()}")