This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create table people( | |
| ...> ID INTEGER PRIMARY KEY, | |
| ...> first_name VARCHAR, | |
| ...> last_name VARCHAR, | |
| ...> phone_number VARCHAR, | |
| ...> created_at NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| ...> updated_at NOT NULL DEFAULT CURRENT_TIMESTAMP); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Let's use decorators to build a name directory! You are given some information about people. Each person has a first name, last name, age and sex. Print their names in a specific format sorted by their age in ascending order i.e. the youngest person's name should be printed first. For two people of the same age, print them in the order of their input. | |
| For Henry Davids, the output should be: | |
| Mr. Henry Davids | |
| For Mary George, the output should be: | |
| Ms. Mary George | |
| Input Format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| from models import * | |
| from stories import * | |
| class TestStories(unittest.TestCase): | |
| def setUp(self): | |
| self.phone_book = PhoneBook() | |
| self.person_factory = Person | |
| self.add_user_story = AddUserStory(self.phone_book, self.person_factory) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sort_users() | |
| Input(first name | last name | phone number) | |
| validate Input | |
| if input is incorrect print message ('Input is incorrect') and finish the programm | |
| else ask in which order sort phonebook(ascending | descending) | |
| sort users by input |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''Write a Python script to add a key to a dictionary | |
| Sample Dictionary : {0: 10, 1: 20} | |
| Expected Result : {0: 10, 1: 20, 2: 30}''' | |
| dict = {0:10, 1:20} | |
| dict[2] = 30 | |
| for k, v in dict.items(): | |
| print(k, v) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given scores. Store them in a list and find the score of the runner-up. | |
| Input Format | |
| The first line contains . The second line contains an array of integers each separated by a space. | |
| Constraints | |
| Output Format |