1 / 8

PreFinal Exercises -- Sets,Dictionaries , and Object Oriented Programming

PreFinal Exercises -- Sets,Dictionaries , and Object Oriented Programming. Question-1.

Download Presentation

PreFinal Exercises -- Sets,Dictionaries , and Object Oriented Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PreFinal Exercises -- Sets,Dictionaries, and Object Oriented Programming

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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)

  8. 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.

More Related