Skip to content

Instantly share code, notes, and snippets.

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);
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
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)
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
@samed-mirzayev
samed-mirzayev / add_key.py
Created June 16, 2020 10:10
w3resource python dictionary
'''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)
'''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