Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While loop and dictionary #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,79 +1,19 @@
'''
ogrenciler = {
'120': {
'ad': 'Ali',
'soyad': 'Yılmaz',
'telefon': '532 000 00 01'
},
'125': {
'ad': 'Can',
'soyad': 'Korkmaz',
'telefon': '532 000 00 02'
},
'128': {
'ad': 'Volkan',
'soyad': 'Yükselen',
'telefon': '532 000 00 03'
},
}

1- Bilgileri verilen öğrencileri kullanıcıdan aldığınız bilgilerle
dictionary içinde saklayınız.

2- Öğrenci numarasını kullanıcıdan alıp ilgili öğrenci bilgisini gösterin.
'''

ogrenciler = {}

number = input("öğrenci no: ")
name = input("öğrenci adı: ")
surname = input("öğrenci soyad: ")
phone = input("öğrenci telefon: ")

# ogrenciler[number] = {
# 'ad': name,
# 'soyad': surname,
# 'telefon': phone
# }

ogrenciler.update({
number: {
'ad': name,
'soyad': surname,
'telefon':phone
}
})

number = input("öğrenci no: ")
name = input("öğrenci adı: ")
surname = input("öğrenci soyad: ")
phone = input("öğrenci telefon: ")

ogrenciler.update({
number: {
'ad': name,
'soyad': surname,
'telefon':phone
}
})

number = input("öğrenci no: ")
name = input("öğrenci adı: ")
surname = input("öğrenci soyad: ")
phone = input("öğrenci telefon: ")

ogrenciler.update({
number: {
'ad': name,
'soyad': surname,
'telefon':phone
}
})

print('*'*50)

ogrNo = input('öğrenci no: ')
ogrenci = ogrenciler[ogrNo]
print(ogrenci)

print(f"Aradığınız {ogrNo} nolu öğrencinin adı: {ogrenci['ad']} soyadı: {ogrenci['soyad']} ve telefonu ise {ogrenci['telefon']}")
# 1- Bilgileri verilen öğrencileri kullanıcıdan aldığınız bilgilerle
# dictionary içinde saklayınız.

# 2- Öğrenci numarasını kullanıcıdan alıp ilgili öğrenci bilgisini gösterin.
ögrenciler={}
x=int(input("Kaç öğrenci bilgisini Dictionary sözlük içersine saklamak istiyorsunuz==\n"))
i=0
while i<x:
numara=input("Numaranızı giriniz=")
ad=input("Adınızı giriniz=")
soyad=input("Soyadınız girniz=")
tel=input("TEL=")
ögrenciler.update({numara:{"AD":ad,"Soyad":soyad,"TEL":tel}})
i+=1
# Öğrenci numarasını kullanıcıdan alıp öğrenci bilgilerini gösterin
ogrno=input("Aramak istediğiniz öğrenci numarası giriniz= ")
print(ögrenciler[ogrno])