Loading...
Vietnam Geography App
Loading...
Vietnam Geography App
Lưu trữ thông tin thông minh với dictionaries! Bạn sẽ biết cách quản lý dữ liệu dạng key-value, xây dựng hệ thống quản lý học sinh, cấu hình phần mềm và nhiều ứng dụng thực tế khác.
Hệ thống quản lý thông tin học sinh
students = {}
def add_student():
student_id = input("Mã học sinh: ")
if student_id in students:
print("Học sinh đã tồn tại!")
return
name = input("Tên: ")
age = int(input("Tuổi: "))
grades = {}
print("Nhập điểm các môn (enter để kết thúc):")
while True:
subject = input("Môn học: ")
if not subject:
break
grade = float(input("Điểm: "))
grades[subject] = grade
students[student_id] = {
'name': name,
'age': age,
'grades': grades
}
print("Đã thêm học sinh!")
def show_student():
student_id = input("Mã học sinh: ")
if student_id not in students:
print("Không tìm thấy học sinh!")
return
student = students[student_id]
print(f"\n=== THÔNG TIN HỌC SINH ===")
print(f"Mã: {student_id}")
print(f"Tên: {student['name']}")
print(f"Tuổi: {student['age']}")
print("Điểm:")
total = 0
count = 0
for subject, grade in student['grades'].items():
print(f" {subject}: {grade}")
total += grade
count += 1
if count > 0:
average = total / count
print(f"Điểm trung bình: {average:.2f}")
def list_all_students():
if not students:
print("Chưa có học sinh nào!")
return
print("\n=== DANH SÁCH HỌC SINH ===")
for student_id, info in students.items():
grades = info['grades']
avg = sum(grades.values()) / len(grades) if grades else 0
print(f"{student_id}: {info['name']} (TB: {avg:.1f})")
Database records representation
Configuration management
API response handling
Cache implementation
User profiles storage
Settings và preferences