-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPF_LAB9.py
More file actions
113 lines (105 loc) · 3.78 KB
/
PF_LAB9.py
File metadata and controls
113 lines (105 loc) · 3.78 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# my_empty_set = set()
# empty_dict = dict()
# empty_dict1 = {}
# print(my_empty_set)
# print(empty_dict)
# print(empty_dict1)
# top = {'bassam', 'usman', 'rafeh', 'ahad', 'wadood', 'yusra'}
# print("Students in our lab are : " + str(len(top)))
# top.add('Bilal')
# print(top)
# top.remove('usman')
# print(top)
# PROGRAMMING EXERCISE
# QUESTION 1
# best_students = set()
# for i in range(5):
# name = input("Enter the name of the student :")
# best_students.add(name)
# print("The names of the best students are : ", best_students)
# QUESTION 2
# friends = {'Ahad', 'Salman', 'Bilal', 'Kashif', 'Danish'}
# print("Initial list of friends : ", friends)
#
# for i in range(2):
# name = input("Enter the names of friends who left NED : ")
# if name in friends:
# friends.remove(name)
# print(name, "has been removed")
# else:
# print(name, "is not in a list")
# print("Updated list of friends: ", friends)
# QUESTION 3
# best_dishes = set()
# for i in range(5):
# dish = input('Enter the name of dish : ')
# best_dishes.add(dish)
# print("Best Dishes : ", best_dishes)
# while best_dishes:
# removed_dish = best_dishes.pop()
# print(f"{removed_dish} has been removed.")
# print("All dishes have been removed. Set is now empty:", best_dishes)
# QUESTION 4
# item_prices = {300, 75, 50, 250, 120}
# print("Prices for items available for purchase: ", item_prices)
# total_amount = 0
# sold_prices = []
# while item_prices:
# price = item_prices.pop()
# print(f"Purchased an item for {price} Rupees.")
# total_amount += price
# sold_prices.append(price)
# max_price = max(sold_prices)
# min_price = min(sold_prices)
# print("Total amount of items sold : ", total_amount)
# print("Maximum price of items sold : ", max_price)
# print("Minimum price of items sold : ", min_price)
# QUESTION 5
# no_of_students = 40
# hockey_players = 21
# both_sports = 10
# only_cricket = no_of_students - hockey_players - both_sports
# print("Number of students who play only cricket : ", only_cricket)
# QUESTION 6
# dog = 83
# cat = 101
# fish = 22
# dog_cat = 31
# dog_fish = 8
# cat_fish = 10
# dog_cat_fish = 6
# other_pets = 34
# only_dog = dog - dog_cat - dog_fish + dog_cat_fish
# only_cat = cat - dog_cat - cat_fish + dog_cat_fish
# dog_or_fish = dog + fish - dog_fish
# total_purchases = dog + cat + fish - dog_fish - dog_cat - cat_fish + dog_cat_fish + other_pets
# print("i. No. of purchases for a dog product only:" ,only_dog)
# print("ii. No. of purchases for a cat product only:" ,only_cat)
# print("iii. No. of purchases for a dog or a fish product:" ,dog_or_fish)
# print("iv. Total no. of purchases:" ,total_purchases)
# QUESTION 7
# only_english = 25
# only_spanish = 10
# only_french = 11
# english_and_spanish_only = 20
# english_and_french_only = 17
# spanish_and_french_only = 9
# all_three_languages = 13
# total_students = 110
# # (a)
# english_and_spanish_but_not_french = english_and_spanish_only
# # (b)
# none = total_students - (only_english+only_french+only_spanish
# +english_and_spanish_only+english_and_french_only
# + spanish_and_french_only+all_three_languages)
# # (c)
# french_only = only_french
# # (d)
# only_one_language = only_french + only_english + only_spanish
# # (e)
# exactly_two = english_and_spanish_only + english_and_french_only + spanish_and_french_only
# print("a. English and Spanish but not French:", english_and_spanish_but_not_french)
# print("b. Neither English, Spanish, nor French:", none)
# print("c. French but neither English nor Spanish:", french_only)
# print("d. Only one of the three languages:", only_one_language)
# print("e. Exactly two of the three languages:", exactly_two)