ODI Points

 avatar
unknown
python
2 years ago
3.4 kB
5
Indexable
def batter():
  global total
  total1 = 0
  total2 = 0
  total3 = 0
  total4 = 0
  total = 0
  runs = int(input("Enter total number of runs scored: "))
  balls = int(input("Enter total number of balls played: "))
  fours = int(input("Enter total number of 4s: "))
  sixs = int(input("Enter total number of 6s: "))
  t7 = input("Is this a top 8 batter? (y/n): ")
  total1 = runs + fours + 2*sixs

  if runs>=30 and runs<=49:
    total2 = total2 + 4
  elif runs>=50 and runs<=99:
    total2 = total2 + 8
  elif runs>=100:
    total2 = total2 + 16
  else:
    pass

  if t7 and runs == 0:
    total3 = total3 - 3
  else:
    pass

  SR = (runs/balls)*100
  print(f"Strike Rate: {SR}")

  if SR>= 140:
    total4 = total4 + 6
  elif SR>=120 and SR<=139:
    total4 = total4 + 4
  elif SR>= 100 and SR<=119:
    total4 = total4 + 2
  elif SR<=50:
    total4 = total4 - 4
  else:
    pass

  global totalbatting
  totalbatting = 0
  totalbatting = total1 + total2 + total3 + total4
  
  
  print()
  print(f"Points off runs: {total1+total2}, Points cuz of duck: {total3}, Points off SR: {total4} ")
  print("Total points from batting section: ", totalbatting)

def fielding():
  total5 = 0
  keeper = int(input("How many stumpings: "))
  catch = int(input("How many catches taken: "))
  runsout = int(input("How many run outs: "))

  if catch>=3:
    total5 = total5 + 4
  else:
    pass
  
  global totalfielding
  totalfielding = 0
  totalfielding = keeper*12 + catch*8 + runsout*6
  print("Total points from fielding section: ", totalfielding)

def bowling():
  total6 = 0
  total7 = 0
  total8 = 0
  runsgiven = int(input("Enter number of runs given: "))
  oversbowled = int(input("Enter number of overs bowled: "))

  wickets = int(input("Enter number of wickets taken: "))
  ask1 = int(input("How many of them were LBW/Bowled: "))
  ask2 = int(input("How many of the overs were maiden: "))
  total6 = wickets*25 + ask1*8 + ask2*4

  if wickets == 4:
    total7 = total7 + 4
  elif wickets >= 5:
    total7 = total7 + 8
  else:
    pass

  if oversbowled>=2:
    econ = (runsgiven/oversbowled)
    print("Economy is: ", econ)

    if econ>= 7 and econ<=8:
      total8 = total8 - 2
    elif econ>=3.5 and econ<=4.5:
      total8 = total8 + 2
    elif econ>=2.49 and econ<=3.49:
      total8 = total8 + 4
    elif econ<=2.5:
      total8 = total8 + 6
    elif econ>=8.01 and econ<9:
      total8 = total8 - 4
    elif econ>=9:
      total8 = total8 - 6
    else:
      pass

  else:
    pass

  global totalbowling
  totalbowling = 0
  totalbowling = total6 + total7 + total8
  print()
  print(f"Points due to bowling: {total6}, Points due to bonus wickets: {total7}, Points due to Economy: {total8}")
  print("Total points from bowling section: ", totalbowling)

totalbatting = 0
totalfielding = 0
totalbowling = 0

while True:
  print()
  print("1. Batting Points")
  print("2. Bowling Points")
  print("3. Fielding Points")
  print("4. Total Points and Exit")

  choicefinal = int(input("Enter your choice (1/2/3/4): "))

  if choicefinal == 1:
    batter()
  elif choicefinal ==2:
    bowling()
  elif choicefinal ==3:
    fielding()
  elif choicefinal == 4:
    grandtotal = totalbatting + totalbowling + totalfielding
    print("Grand Total of Player: ", grandtotal, "points")
    break
  
Editor is loading...
Leave a Comment