Python Code to Create Dictionary To Check Cricket Record in Test Series

Python Code to Create Dictionary To Check Cricket Record in Test Series 


testscore={}

name=input("Enter Cricket Player name:")

n=int(input("How many test matches you want to store in your dictionary:"))

for i in range(n):

    key=input("Enter test name:")

    value=int(input("Enter score in test match:"))

    testscore[key]=value

totalscore=0

for i in testscore.values():

    totalscore=totalscore+i

print("\n-------------------------------------------------")

print(f"Following is {name}'s performance in {n } test matches")

print("\n---------------------------------------------------")

print(f" {name}'s {n} test series match total score is :",totalscore,end=" ")

name2=input("\nEnter International player name who has made record:")

record=int(input(f"Enter {name2}'s record:"))

if totalscore>record:

    print(f"{name} has created new record in {n} test series and it is {totalscore}")

else:

    print(f"{name} has not broken {name2}'s record")


Output:

Enter Cricket Player name:Dhoni

How many test matches you want to store in your dictionary:5

Enter test name:Test1

Enter score in test match:400

Enter test name:Test2

Enter score in test match:600

Enter test name:Test3

Enter score in test match:200

Enter test name:Test4

Enter score in test match:100

Enter test name:Test5

Enter score in test match:158


-------------------------------------------------

Following is Dhoni's performance in 5 test matches


---------------------------------------------------

 Dhoni's 5 test series match total score is : 1886 

Enter International player name who has made record:Sachin Tendulkar

Enter Sachin Tendulkar's record:1578

Dhoni has created new record in 5 test series and it is 1886

टिप्पणी पोस्ट करा

0 टिप्पण्या