Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1.

1 {1,3,5,7}
1.2 TRUE
1.3 TRUE

result_union_method = x.union(y)

{“google”, “banana”, “microsoft”, “apple”}

4. result_intersection_method = setx.intersection(sety)

{“blue”}

5. 3

6. [3,4,5,’a’]

7 Lists allow duplicate elements. You can have the same values multiple times in a list. Sets do now allow
duplicate elements. Each element un a set is unique

8. SET – b, LIST – a

9. pear

10. Nothing

11. print(fruits[1])

user_list = []

name = input("Enter your name: ")

age = input("Enter your age: ")

country = input("Enter your country of birth: ")

user_list.append(name)

user_list.append(age)

user_list.append(country)
print("\nUser Information:")

print("Name:", user_list[0])

print("Age:", user_list[1])

print("Country of Birth:", user_list[2])

12.

numbers_str = input("Enter a list of numbers separated by spaces: ")

numbers = [int(num) for num in numbers_str.split()]

if not numbers:

print("Please enter at least one number.")

else:

max_num = numbers[0] # Assume the first element is the maximum

max_index = 0

for i in range(1, len(numbers)):

if numbers[i] > max_num:

max_num = numbers[i]

max_index = i

print("Maximum Number:", max_num)

print("Index of Maximum Number:", max_index)

You might also like