Sổ liên lạc bằng Python

Nhiệm vụ của chúng tôi là triển khai một thư mục điện thoại thông minh thu thập dữ liệu liên hệ từ người dùng cho đến khi người dùng nhắc chương trình. Dữ liệu liên hệ đề cập đến tên, số điện thoại, ngày sinh của liên hệ, danh mục mà liên hệ thuộc về [Bạn bè, Gia đình, Công việc, Khác], địa chỉ email. Người dùng có thể nhập càng nhiều dữ liệu càng tốt vào các nhãn dữ liệu được đề cập. Nếu một số nhãn không có dữ liệu, hãy lưu trữ dưới dạng Không có. Tên và số là bắt buộc để tạo liên hệ. Thực hiện các thao tác sau trên thư mục. Chèn, Xóa, Tìm kiếm, Hiển thị

Tiếp cận
Chúng tôi đã sử dụng khái niệm danh sách 2D và triển khai tương tự trong Python3. Có tổng cộng 8 chức năng được sử dụng trong mã này, cụ thể là.  
 

  • ban đầu_phonebook[]. Chức năng đầu tiên chạy, nó khởi tạo danh bạ
  • thực đơn[]. Nó hiển thị các lựa chọn có sẵn cho người dùng và trả về lựa chọn đã nhập
  • add_contact[]. Nó thêm một số liên lạc mới vào thư mục Danh bạ
  • loại bỏ_hiện có []. Nó xóa một liên hệ hiện có khỏi thư mục Danh bạ
  • xóa hết[]. Nó xóa tất cả các số liên lạc khỏi thư mục Danh bạ
  • display_all[]. Nó hiển thị tất cả các số liên lạc từ thư mục Danh bạ
  • tìm_kiếm_hiện có[]. Nó sẽ tìm kiếm và hiển thị một liên hệ hiện có trong thư mục Danh bạ
  • cảm ơn[]

Giữ trải nghiệm người dùng và giao diện người dùng, chúng tôi đã làm cho mã đơn giản, dễ đọc và tương tác. Bạn có thể hoặc không thể sử dụng tất cả các tính năng chính xác như được mô tả bên dưới. Vui lòng xem qua giải pháp mã
 

Vui lòng thử chạy mã này trên Python IDLE của bạn vì một số lỗi có thể xảy ra nếu bạn chạy ở đây vì yêu cầu đầu vào của người dùng. Bạn cũng có thể mở trang IDE tại GFG và chạy mã của mình ở đó thay vì chạy trực tiếp từ đoạn mã

 

trăn3




# importing the module

import sys

 

# this function will be the first to run as soon as the main function executes

def initial_phonebook[]:

    rows, cols= intimport0_______1_______1import0import3import4import5

    

    import8

    sys0

    sys2_______8_______ sys4

    sys6sys7

    sys9 # this function will be the first to run as soon as the main function executes0# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2# this function will be the first to run as soon as the main function executes3

# this function will be the first to run as soon as the main function executes4_______2_______6import0# this function will be the first to run as soon as the main function executes7 # this function will be the first to run as soon as the main function executes8 # this function will be the first to run as soon as the main function executes9def0def1def2

# this function will be the first to run as soon as the main function executes4_______2_______6import0def6_______4_______7

# this function will be the first to run as soon as the main function executes4_______2_______6_______1_______0_______5_______1_______4_______7

# this function will be the first to run as soon as the main function executes4_______5_______4= sys4

# this function will be the first to run as soon as the main function executes4_______2_______9 initial_phonebook[]:9# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2    2

    3

# this function will be the first to run as soon as the main function executes4_______6_______5

# this function will be the first to run as soon as the main function executes4_______6_______7

    8    9 initial_phonebook[]:9== rows, cols3rows, cols4

rows, cols5rows, cols6rows, cols7_______1_______0import1import0=1=2

rows, cols5

rows, cols5_______8_______5

rows, cols5=7

rows, cols5=9

rows, cols5    9 int2_______8_______= int5int6 int7

    3____9_______9

import00import01def7

    3import04

    3

    8    9 initial_phonebook[]:9== def1rows, cols4

rows, cols5rows, cols6intimport0import1import0import19=2

rows, cols5import22

rows, cols5import24

rows, cols5import26

rows, cols5

    8    9 initial_phonebook[]:9== import33rows, cols4

rows, cols5rows, cols6rows, cols7import0import1import0import41=2

rows, cols5import44

rows, cols5    9 int2_______8_______= int5int6 int7

    3int2= import56

    3

    8    9 initial_phonebook[]:9== import63rows, cols4

rows, cols5rows, cols6rows, cols7_______1_______0import1import0import71_______8_______2

rows, cols5import74

rows, cols5import76

rows, cols5import78

rows, cols5    9 int2_______8_______= int5int6 int7

import87

rows, cols5import44

    3int2= import56

    8    9 initial_phonebook[]:9== import99rows, cols4

rows, cols5rows, cols6

    3rows, cols7import0_______1_______1import0sys08=2

rows, cols5import44

rows, cols5    9 int2_______8_______= sys17sys18 int2== sys22rows, cols4

    3int2= import56

    3

# this function will be the first to run as soon as the main function executes4_______2_______30

# this function will be the first to run as soon as the main function executes4_______2_______32

# this function will be the first to run as soon as the main function executes4_______2_______34

    

    sys6sys7

    sys40 sys2

 

def sys43

    sys45

    sys47

    sys49

    sys6_______1_______0_______2_______53def7

    sys6import0sys58sys59=2_______61def7

    sys6_______1_______0_______2_______53def7

    sys6_______1_______0_______2_______71def7

    sys6import0sys76def7

    sys6import0sys81def7

    sys6import0sys86def7

    sys6_______1_______0sys91def7

    sys6import0sys96def7

    sys6import0# this function will be the first to run as soon as the main function executes01def7

 

    # this function will be the first to run as soon as the main function executes04

    # this function will be the first to run as soon as the main function executes06

    # this function will be the first to run as soon as the main function executes08_______8_______ intimport0_______1_______1import0# this function will be the first to run as soon as the main function executes14def2

    

    sys40 # this function will be the first to run as soon as the main function executes08

 

def # this function will be the first to run as soon as the main function executes21

    # this function will be the first to run as soon as the main function executes23

    # this function will be the first to run as soon as the main function executes25

    # this function will be the first to run as soon as the main function executes27_______8_______ sys4

    sys9 # this function will be the first to run as soon as the main function executes0# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2_______1_______0# this function will be the first to run as soon as the main function executes36# this function will be the first to run as soon as the main function executes37rows, cols3# this function will be the first to run as soon as the main function executes39

# this function will be the first to run as soon as the main function executes4_______6_______9 # this function will be the first to run as soon as the main function executes0== rows, cols3_______7_______4

    8# this function will be the first to run as soon as the main function executes48rows, cols7import0_______1_______1import0# this function will be the first to run as soon as the main function executes53=2

# this function will be the first to run as soon as the main function executes4_______6_______9 # this function will be the first to run as soon as the main function executes0== def1rows, cols4

    8# this function will be the first to run as soon as the main function executes48intimport0import1import0# this function will be the first to run as soon as the main function executes68=2

# this function will be the first to run as soon as the main function executes4_______6_______9 # this function will be the first to run as soon as the main function executes0== import33_______7_______4

    8# this function will be the first to run as soon as the main function executes48rows, cols7import0_______1_______1import0import41=2

# this function will be the first to run as soon as the main function executes4_______6_______9 # this function will be the first to run as soon as the main function executes0== import63rows, cols4

    8# this function will be the first to run as soon as the main function executes48rows, cols7_______1_______0_______1_______1import0import71_______8_______2

# this function will be the first to run as soon as the main function executes4_______6_______9 # this function will be the first to run as soon as the main function executes0== import99rows, cols4

    8# this function will be the first to run as soon as the main function executes48

rows, cols5rows, cols7import0_______1_______1import0sys08=2

    def17

    def19

    sys40 def22

 

def def24

    def26

    4_______28_______8_______ rows, cols7import0

# this function will be the first to run as soon as the main function executes4_______1_______1_______1_______0def35_______4_______2

    def38

    

    initial_phonebook[]:4= rows, cols3

    def45

    

    2_______9 # this function will be the first to run as soon as the main function executes0# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2import0# this function will be the first to run as soon as the main function executes36def54

# this function will be the first to run as soon as the main function executes4_______6_______9 def28_______8__________= def60rows, cols3def62

    8initial_phonebook[]:4_______4_______0= def1

    8def69

    8

    8sys6def73

    8def75

    8

    8sys6import0def80_______4_______7

    8def83

    8def85

    8def87

    8def89

    8

    8sys40 def22

        9 initial_phonebook[]:4_______8_______= rows, cols3rows, cols4

# this function will be the first to run as soon as the main function executes4_______5_______02

# this function will be the first to run as soon as the main function executes4_______5_______04

# this function will be the first to run as soon as the main function executes4_______2_______6initial_phonebook[]:07

    initial_phonebook[]:09_______5_______10 initial_phonebook[]:11 initial_phonebook[]:12

# this function will be the first to run as soon as the main function executes4

# this function will be the first to run as soon as the main function executes4_______2_______40 def22

 

def initial_phonebook[]:18

    initial_phonebook[]:20

    initial_phonebook[]:22

    sys40 initial_phonebook[]:25

 

def initial_phonebook[]:27

    initial_phonebook[]:29

    # this function will be the first to run as soon as the main function executes08= intimport0_______1_______1initial_phonebook[]:36

    5_______38 initial_phonebook[]:39initial_phonebook[]:40_______5_______41initial_phonebook[]:42initial_phonebook[]:43initial_phonebook[]:44initial_phonebook[]:43initial_phonebook[]:46initial_phonebook[]:43initial_phonebook[]:48

    initial_phonebook[]:50

    initial_phonebook[]:52

    

    initial_phonebook[]:4= sys4

    initial_phonebook[]:59_______8_______ initial_phonebook[]:40def1

    

        9 # this function will be the first to run as soon as the main function executes08== def1rows, cols4

    initial_phonebook[]:72

# this function will be the first to run as soon as the main function executes4_______4_______28= rows, cols7_______1_______0

    8import1_______1_______0_______5_______81_______4_______2

# this function will be the first to run as soon as the main function executes4_______2_______9 # this function will be the first to run as soon as the main function executes0# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2import0# this function will be the first to run as soon as the main function executes36def54

    8    9 def28_______8_______= def60rows, cols3def62

rows, cols5initial_phonebook[]:59= # this function will be the first to run as soon as the main function executes0

rows, cols5    04

rows, cols5

        07 # this function will be the first to run as soon as the main function executes08== import33rows, cols4

        14

# this function will be the first to run as soon as the main function executes4_______4_______28= intimport0

    8import1_______1_______0    23_______4_______2

# this function will be the first to run as soon as the main function executes4_______2_______9 # this function will be the first to run as soon as the main function executes0# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2import0# this function will be the first to run as soon as the main function executes36def54

    8    9 def28_______8_______= def60def1def62

rows, cols5initial_phonebook[]:59= # this function will be the first to run as soon as the main function executes0

rows, cols5    04

rows, cols5

        07 # this function will be the first to run as soon as the main function executes08== import63rows, cols4

        56

# this function will be the first to run as soon as the main function executes4_______4_______28= rows, cols7_______1_______0import1    63initial_phonebook[]:40    65    66    67

# this function will be the first to run as soon as the main function executes4_______6_______69

# this function will be the first to run as soon as the main function executes4_______2_______9 # this function will be the first to run as soon as the main function executes0# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2import0# this function will be the first to run as soon as the main function executes36def54

    8    9 def28_______8_______= def60import33def62

rows, cols5initial_phonebook[]:59= # this function will be the first to run as soon as the main function executes0

rows, cols5    04

rows, cols5

        07 # this function will be the first to run as soon as the main function executes08== import99rows, cols4

    rows, cols01

# this function will be the first to run as soon as the main function executes4_______4_______28= rows, cols7_______1_______0import1rows, cols08# this function will be the first to run as soon as the main function executes1 rows, cols10initial_phonebook[]:43rows, cols12initial_phonebook[]:43rows, cols14rows, cols15 rows, cols16

    8    69

# this function will be the first to run as soon as the main function executes4_______2_______9 # this function will be the first to run as soon as the main function executes0# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2import0# this function will be the first to run as soon as the main function executes36def54

    8    9 def28_______8_______= def60import63def62

rows, cols5initial_phonebook[]:59= # this function will be the first to run as soon as the main function executes0

rows, cols5    04

rows, cols5

        07 # this function will be the first to run as soon as the main function executes08== import5rows, cols4

    rows, cols50

# this function will be the first to run as soon as the main function executes4_______4_______28= rows, cols7_______1_______0

    8import1_______1_______0rows, cols59def2

# this function will be the first to run as soon as the main function executes4_______2_______9 # this function will be the first to run as soon as the main function executes0# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2import0# this function will be the first to run as soon as the main function executes36def54

    8    9 def28_______8_______= def60import99def62

rows, cols5initial_phonebook[]:59= # this function will be the first to run as soon as the main function executes0

rows, cols5    04

# this function will be the first to run as soon as the main function executes4_______7_______84

# this function will be the first to run as soon as the main function executes4

    rows, cols87rows, cols4

    rows, cols90

# this function will be the first to run as soon as the main function executes4_______2_______6import0rows, cols94def7

# this function will be the first to run as soon as the main function executes4_______2_______40 initial_phonebook[]:40def1

    =01

    

    =04

    =06

    

        9 initial_phonebook[]:59== initial_phonebook[]:40def1_______7_______4

# this function will be the first to run as soon as the main function executes4_______2_______40 initial_phonebook[]:40def1

# this function will be the first to run as soon as the main function executes4_______8_______21

    rows, cols87rows, cols4

# this function will be the first to run as soon as the main function executes4_______8_______26

# this function will be the first to run as soon as the main function executes4_______2_______40 initial_phonebook[]:59

# this function will be the first to run as soon as the main function executes4_______8_______31

# this function will be the first to run as soon as the main function executes4_______8_______33

 

=34

def =36

        9 =39 =40

    =42

    =44

# this function will be the first to run as soon as the main function executes4_______2_______6import0=48def7

    rows, cols87rows, cols4

# this function will be the first to run as soon as the main function executes4_______2_______9 # this function will be the first to run as soon as the main function executes0# this function will be the first to run as soon as the main function executes1 # this function will be the first to run as soon as the main function executes2import0# this function will be the first to run as soon as the main function executes36def54

    8sys6=63

 

def =65

=66

    sys6_______1_______0_______2_______53def7

    sys6import0=75def7

    sys6import0=80def7

    sys6_______1_______0_______2_______53def7

    int9_______8_______89def7

 

=91

sys6import0_______5_______1def7

sys6import0_______8_______98def7

sys6import0_______9_______02def7

sys6import0_______5_______1def7

int08

int09

 

int10= def1

def22_______8_______ int15

int16 int10_______3_______1 import0_______4_______1int21import33int21import63int21import99int21import5int29

Chủ Đề