Ujjwal
Ujjwal
Ujjwal
Section:E2
Course:B.C.A
Roll no:01
def replace_space_with_tab(input_string):
return input_string.replace(' ', '\t')
Output:
Name aashutosh Bhardwaj
Section:E2
Course:B.C.A
Roll no:01
# Define a dictionary
my_dict = {'a': 1, 'b': 2, 'c': 3}
Output:
# Define a list with duplicate values
my_list = [1, 2, 3, 4, 2, 3, 5]
unique_list = list(set(my_list))
Output:
def process_tuple(input_tuple):
new_tuple = () for value in input_tuple:
if isinstance(value, int): new_tuple +=
(value,) elif isinstance(value, float):
continue elif isinstance(value, str) and
len(value) == 3: new_tuple += (value,)
return new_tuple
Output:
# Create the dictionary with keys as numbers and values as cubes
cube_dict = {num: num**3 for num in range(1, 11)}
Output:
def count_vowels(string):
vowels = 'aeiouAEIOU'
count = 0 for char in
string: if char in
vowels: count +=
1 return count
if __name__ == "__main__":
main() Output:
if __name__ == "__main__":
main() Output:
if __name__ == "__main__":
main() Output:
# Define the lambda function for multiplication
multiply = lambda x, y: x * y
def print_table(number):
print("Table of", number, ":")
for i in range(1, 11):
result = multiply(number, i)
print(number, "x", i, "=", result)
if __name__ == "__main__":
main() Output:
# Define lambda functions for squaring and
cubing square = lambda x: x ** 2 cube = lambda
x: x ** 3
def square_and_cube(numbers):
squared_numbers = list(map(square, numbers))
cubed_numbers = list(map(cube, numbers))
return squared_numbers, cubed_numbers
def main():
numbers = [int(x) for x in input("Enter a list of integers separated by spaces: ").split()]
squared_numbers, cubed_numbers = square_and_cube(numbers)
print("Original numbers:", numbers)
print("Squared numbers:", squared_numbers)
print("Cubed numbers:", cubed_numbers)
if __name__ == "__main__":
main() Output:
import numpy as np
if __name__ == "__main__":
main()
import numpy as np
x = np.array([1, 2, 3, 4, 5])
y = np.array([1, 0, 3, 4, 6])
positions = find_matching_positions(x, y)
print("Positions where elements are the same:", positions)
import numpy as np