##Xudoynazarova Iroda ##Masala. Telefon raqamlarni ##va uning egalarnining F. I. O


Download 12.85 Kb.
Sana02.01.2022
Hajmi12.85 Kb.
#198704
Bog'liq
Xudoynazarova Iroda


##Xudoynazarova Iroda

##Masala. Telefon raqamlarni

##va uning egalarnining F.I.O,

##Manzil, elektron pochtalari,

##o‘zida saqlaydigan phonenumbers_dict

##lug‘ati yaratilsin, hamda

##quyidagi amalar bajarilsin.

##Ko‘rsatma, kalit sifatida telefon

##raqami olinsin, hamda, murkkab

##lug‘atlardan foydalanilsin.

##Quyidagi ammalarni bajaring:

##Qo‘shish, o‘chirish, tahrirlash;

##Telefon ramlarni va uning egasining

##F.I.O chiqaradigan funkisya tuzilsin;

##Kiritilgan Familiya bo‘yicha telefon

##raqamlari chiqrilsin;

##Dasturni tuzish jarayonida istisno

##hollatlardan foydalanilsin;

##Manzilning satr ostisi kiritilganda,

##shu satr ositiga ega bo‘lgan raqamlar chiqarilsin.

phonenumbers_dict={}

def AddNumber():

# Calling phonenumbers_dict for local

global phonenumbers_dict

# Creat new phone number

newPhone = {input("Enter new phone number: ") : {

"fio" : {

"fam" : input("Enter last name: "),

"ism" : input("Enter first name: "),

"middle" : input("Enter midle name: ")

},

"address" : {



"place" : input("Enter address: "),

"email" : input("Enter e-mail: ")

} }}

# Adding the number note the new number



phonenumbers_dict.update(newPhone)

print(phonenumbers_dict)

# Func: deleting the needed number

def DeleteNumber():

# Calling phonenumbers_dict for local

global phonenumbers_dict

phonenumbers_dict.popitem()

print(phonenumbers_dict)

# Func: Editing the needed number

def EditNumber():

# Calling phonenumbers_dict for local

global phonenumbers_dict

phonenumbers_dict["address"]={"place":input("Enter adress:"),"email":input("Enter e-mail:")}

print(phonenumbers_dict["address"])

# Func: Editing the needed number

def PrintNumbers():

# Calling phonenumbers_dict for local

global phonenumbers_dict

for item in phonenumbers_dict:

print("Phone number: ", item)

print("" * 20, end='')

print("F.I.O.: ", item["fio"]["fam"],

" | ", item["fio"]["ism"], " | ",

item["fio"]["midle"])

print("Address: ", item["address"]["place"],

" | ", item["address"]["email"])

def SearchByFirstName():

# Calling phonenumbers_dict for local

global phonenumbers_dict

newPhone={"fam":input("Enter last name:"),"phonenumber":input("Enter phonenumber:")}

key="phonenumber"

if key in newPhone:

phonenumbers_dict=newPhone[key]

print(phonenumbers_dict)

else:

print("Element topilmadi!")



def SearchByAddress():

# Calling phonenumbers_dict for local

global phonenumbers_dict

newPhone={"adress":input("Enter adress:"),"phonenumber":input("Enter phonenumber:")}

key="phonenumber"

if key in newPhone:

phonenumbers_dict=newPhone[key]

print(phonenumbers_dict)

else:

print("Element topilmadi!")



while True:

print("Buyruqlar:")

print("1-Yangi raqam qo'shish")

print("2-O'chirish")

print("3-Tarirlash")

print("4-Chop qilish")

print("5-Familiya bo'yicha qidirish")

print("6-Manzil bo'yicha qidirish")

print("0-Chiqish")

# Buyruqni kiritish

command = int(input("Buyruq raqamini kiriting: "))

# Birinchi buyroq funksiyasiga murojat qilish

if command == 1:

AddNumber()

# Keyingi if shartlarni qaramaslik uchun

continue


# 2-buyroq funksiyasiga murojat qilish

if command == 2:

DeleteNumber()

continue


# 3-buyroq funksiyasiga murojat qilish

if command == 3:

EditNumber()

continue


# 4-buyroq funksiyasiga murojat qilish

if command == 4:

PrintNumbers()

continue


# 5-buyroq funksiyasiga murojat qilish

if command == 5:

SearchByFirstName()

continue


# 6-buyroq funksiyasiga murojat qilish

if command == 6:

SearchByAddress()

continue


# 0-buyroq funksiyasiga murojat qilish

if command == 0:



# Exit while

break
Download 12.85 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling