0% found this document useful (0 votes)
3 views2 pages

Cs Program

The document is a Python script for managing cricketer statistics, allowing users to add, modify, delete, search, and display cricketer data. It prompts for input to gather information such as name, total runs, matches played, and wickets taken. The program runs in a loop until the user chooses to exit, providing a menu for various operations on the cricketer records.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Cs Program

The document is a Python script for managing cricketer statistics, allowing users to add, modify, delete, search, and display cricketer data. It prompts for input to gather information such as name, total runs, matches played, and wickets taken. The program runs in a loop until the user chooses to exit, providing a menu for various operations on the cricketer records.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

cricketers = {}

n = int(input("Enter no of cricketers "))


for i in range(n):
name = input("Enter cricketer name: ")
runs = int(input("Enter total runs: "))
matches = int(input("Enter matches played: "))
wickets = int(input("Enter wickets taken: "))
cricketers[name] = [runs, matches, wickets]
print("Cricketer added successfully!")
while True:
print("\n--- Cricketer Statistics Menu ---")
print("1. Add Cricketer")
print("2. Modify Cricketer")
print("3. Delete Cricketer")
print("4. Search Cricketer")
print("5. Display All Cricketers")
print("6. Exit")

choice = int(input("Enter your choice: "))

if choice == 1:
name = input("Enter cricketer name: ")
runs = int(input("Enter total runs: "))
matches = int(input("Enter matches played: "))
wickets = int(input("Enter wickets taken: "))
cricketers[name] = [runs, matches, wickets]
print("Cricketer added successfully!")

elif choice == 2:
name = input("Enter cricketer name to modify: ")
if name in cricketers:
runs = int(input("Enter new runs: "))
matches = int(input("Enter new matches: "))
wickets = int(input("Enter new wickets: "))
cricketers[name] = [runs, matches, wickets]
print("Cricketer details updated!")
else:
print("Cricketer not found!")

elif choice == 3:
name = input("Enter cricketer name to delete: ")
if name in cricketers:
del cricketers[name]
print("Cricketer deleted!")
else:
print("Cricketer not found!")
elif choice == 4:
name = input("Enter cricketer name to search: ")
if name in cricketers:
print("Runs:", cricketers[name][0])
print("Matches:", cricketers[name][1])
print("Wickets:", cricketers[name][2])
else:
print("Cricketer not found")
elif choice == 5:
if cricketers == {}:
print("No records found!")
else:
for name, stats in [Link]():
print("\nName:", name)
print("Runs:", stats[0])
print("Matches:", stats[1])
print("Wickets:", stats[2])

elif choice == 6:
print("Thank you! Program ended.")
break

else:
print("Invalid choice!")

You might also like