80 likes | 139 Views
PreFinal Exercises -- Sets,Dictionaries , and Object Oriented Programming. Question-1.
E N D
PreFinal Exercises -- Sets,Dictionaries, and Object Oriented Programming
Question-1 • Write a function that asks user to enter 10 numbers and inserts the numbers to a Set. The function prints “You already entered the number” if user enters a number that it is entered before. After getting 10 distinct numbers function returns the set. You are allowed to use only Set data structure.
Question-2 • Write a function that gets two lists which contain numbers and returns the common numbers in the lists as a list. Use set data structure.
Question-3 • Write a function that gets four sets (A,B,C,D) and returns union of intersections of (A and B) and (B and D) as a set.
Question-4 • Write a function that gets a word-code dictionary and a string and returns coded string. So your function should return “hallo wereld” for “hello world” string and {hello:hallo, world:wereld} dictionary.
Question-5 • Write a function that gets two dictionaries(d1,d2) which map strings to numbers and returns union of these two dictionaries. If d1 and d2 have keys in common, the function should use the value in d1 in the union dictionary.
Question-6 • Define an Account class which has following private attributes and public methods; • name • ssn • checking_balance • Getters and setters of all attributes • CWithdraw(amount) • CDeposit(amount)
Question-7 • Define a XAccount class which is a subclass of Account class and has following private attributes and public methods; • saving_balance • Getters and setters of saving_balance • savingWithDraw(amount) • savingDeposit(amount) • smart_withdraw(amount) -> Withdraws amount from checking balance but deposits 1% of the amount from checking to saving account. Use Account methods along with relevant XAccount methods.